aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorantlilja <liljaanton2001@gmail.com>2024-01-20 00:13:08 +0100
committerantlilja <liljaanton2001@gmail.com>2024-02-21 16:24:59 +0100
commitc57b4e70b06cae022793ffe0aa025de31a0ff1c5 (patch)
tree8c1f881dbe64e3ce5ea6326f5f9cd83057c22e63 /src/codegen
parent52e843402224e43141a63e406432643b4304b507 (diff)
downloadzig-c57b4e70b06cae022793ffe0aa025de31a0ff1c5.tar.gz
zig-c57b4e70b06cae022793ffe0aa025de31a0ff1c5.zip
Builder: Add function_attributes_set
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm/Builder.zig12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig
index 72e49738ec..30186333e2 100644
--- a/src/codegen/llvm/Builder.zig
+++ b/src/codegen/llvm/Builder.zig
@@ -37,6 +37,8 @@ attributes_map: std.AutoArrayHashMapUnmanaged(void, void),
attributes_indices: std.ArrayListUnmanaged(u32),
attributes_extra: std.ArrayListUnmanaged(u32),
+function_attributes_set: std.AutoArrayHashMapUnmanaged(FunctionAttributes, void),
+
globals: std.AutoArrayHashMapUnmanaged(String, Global),
next_unnamed_global: String,
next_replaced_global: String,
@@ -8248,6 +8250,8 @@ pub fn init(options: Options) InitError!Builder {
.attributes_indices = .{},
.attributes_extra = .{},
+ .function_attributes_set = .{},
+
.globals = .{},
.next_unnamed_global = @enumFromInt(0),
.next_replaced_global = .none,
@@ -8385,6 +8389,8 @@ pub fn deinit(self: *Builder) void {
self.attributes_indices.deinit(self.gpa);
self.attributes_extra.deinit(self.gpa);
+ self.function_attributes_set.deinit(self.gpa);
+
self.globals.deinit(self.gpa);
self.next_unique_global_id.deinit(self.gpa);
self.aliases.deinit(self.gpa);
@@ -8825,12 +8831,16 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr
}
pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {
- return @enumFromInt(try self.attrGeneric(@ptrCast(
+ try self.function_attributes_set.ensureUnusedCapacity(self.gpa, 1);
+ const function_attributes: FunctionAttributes = @enumFromInt(try self.attrGeneric(@ptrCast(
fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|
last + 1
else
0],
)));
+
+ _ = self.function_attributes_set.getOrPutAssumeCapacity(function_attributes);
+ return function_attributes;
}
pub fn addGlobal(self: *Builder, name: String, global: Global) Allocator.Error!Global.Index {