authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-24 16:41:17+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-24 16:41:37+01:00
log7e9f321f53b53dcefaf3b771720c9c25529c39ef
tree7c1dd7625c1a06e24671f83a6860e6edfdd88e53
parent9b39e824cdd523ec32b33d630ea9a58ca6fd4103

Builder: fix bitcode widths


1 files changed, 12 insertions(+), 15 deletions(-)

src/codegen/llvm/Builder.zig+12-15
......@@ -12945,14 +12945,8 @@ fn debugConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata {
1294512945pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]const u32 {
1294612946 const BitcodeWriter = bitcode_writer.BitcodeWriter(&.{ Type, FunctionAttributes });
1294712947 var bitcode = BitcodeWriter.init(allocator, &.{
12948 if (self.type_items.items.len > 0)
12949 std.math.log2_int_ceil(usize, self.type_items.items.len)
12950 else
12951 undefined,
12952 if (self.type_items.items.len > 0)
12953 std.math.log2_int_ceil(usize, self.function_attributes_set.count())
12954 else
12955 undefined,
12948 std.math.log2_int_ceil(usize, self.type_items.items.len),
12949 std.math.log2_int_ceil(usize, 1 + self.function_attributes_set.count()),
1295612950 });
1295712951 errdefer bitcode.deinit();
1295812952
......@@ -13340,7 +13334,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1334013334 const group_index = attributes_set.getIndex(.{
1334113335 .attributes = attributes,
1334213336 .index = @intCast(i),
13343 }) orelse unreachable;
13337 }).?;
1334413338 record.appendAssumeCapacity(@intCast(group_index));
1334513339 }
1334613340
......@@ -13426,7 +13420,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1342613420 if (!gop.found_existing) {
1342713421 try module_block.writeAbbrev(Module.String{
1342813422 .code = 5,
13429 .string = variable.section.slice(self) orelse unreachable,
13423 .string = variable.section.slice(self).?,
1343013424 });
1343113425 }
1343213426 break :blk gop.index + 1;
......@@ -13473,7 +13467,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1347313467 if (!gop.found_existing) {
1347413468 try module_block.writeAbbrev(Module.String{
1347513469 .code = 5,
13476 .string = func.section.slice(self) orelse unreachable,
13470 .string = func.section.slice(self).?,
1347713471 });
1347813472 }
1347913473 break :blk gop.index + 1;
......@@ -13649,7 +13643,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1364913643 if (str == .none) {
1365013644 try constants_block.writeAbbrev(Constants.Null{});
1365113645 } else {
13652 const slice = str.slice(self) orelse unreachable;
13646 const slice = str.slice(self).?;
1365313647 if (slice.len > 0 and slice[slice.len - 1] == 0)
1365413648 try constants_block.writeAbbrev(Constants.CString{ .string = slice[0 .. slice.len - 1] })
1365513649 else
......@@ -13791,8 +13785,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1379113785 => |tag| {
1379213786 const extra = self.constantExtraData(Constant.Assembly, data);
1379313787
13794 const assembly_slice = extra.assembly.slice(self) orelse unreachable;
13795 const constraints_slice = extra.constraints.slice(self) orelse unreachable;
13788 const assembly_slice = extra.assembly.slice(self).?;
13789 const constraints_slice = extra.constraints.slice(self).?;
1379613790
1379713791 try record.ensureUnusedCapacity(self.gpa, 4 + assembly_slice.len + constraints_slice.len);
1379813792
......@@ -14341,7 +14335,10 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1434114335 return switch (Ty) {
1434214336 Value => @enumFromInt(adapter.getOffsetValueIndex(value)),
1434314337 Constant => @enumFromInt(adapter.getOffsetConstantIndex(value)),
14344 FunctionAttributes => @enumFromInt(if (value == .none) 0 else (adapter.constant_adapter.builder.function_attributes_set.getIndex(value) orelse unreachable) + 1),
14338 FunctionAttributes => @enumFromInt(switch (value) {
14339 .none => 0,
14340 else => 1 + adapter.constant_adapter.builder.function_attributes_set.getIndex(value).?,
14341 }),
1434514342 else => value,
1434614343 };
1434714344 }