| ... | ... | @@ -12945,14 +12945,8 @@ fn debugConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata { |
| 12945 | 12945 | pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]const u32 { |
| 12946 | 12946 | const BitcodeWriter = bitcode_writer.BitcodeWriter(&.{ Type, FunctionAttributes }); |
| 12947 | 12947 | 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()), |
| 12956 | 12950 | }); |
| 12957 | 12951 | errdefer bitcode.deinit(); |
| 12958 | 12952 | |
| ... | ... | @@ -13340,7 +13334,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13340 | 13334 | const group_index = attributes_set.getIndex(.{ |
| 13341 | 13335 | .attributes = attributes, |
| 13342 | 13336 | .index = @intCast(i), |
| 13343 | | }) orelse unreachable; |
| 13337 | }).?; |
| 13344 | 13338 | record.appendAssumeCapacity(@intCast(group_index)); |
| 13345 | 13339 | } |
| 13346 | 13340 | |
| ... | ... | @@ -13426,7 +13420,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13426 | 13420 | if (!gop.found_existing) { |
| 13427 | 13421 | try module_block.writeAbbrev(Module.String{ |
| 13428 | 13422 | .code = 5, |
| 13429 | | .string = variable.section.slice(self) orelse unreachable, |
| 13423 | .string = variable.section.slice(self).?, |
| 13430 | 13424 | }); |
| 13431 | 13425 | } |
| 13432 | 13426 | break :blk gop.index + 1; |
| ... | ... | @@ -13473,7 +13467,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13473 | 13467 | if (!gop.found_existing) { |
| 13474 | 13468 | try module_block.writeAbbrev(Module.String{ |
| 13475 | 13469 | .code = 5, |
| 13476 | | .string = func.section.slice(self) orelse unreachable, |
| 13470 | .string = func.section.slice(self).?, |
| 13477 | 13471 | }); |
| 13478 | 13472 | } |
| 13479 | 13473 | break :blk gop.index + 1; |
| ... | ... | @@ -13649,7 +13643,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13649 | 13643 | if (str == .none) { |
| 13650 | 13644 | try constants_block.writeAbbrev(Constants.Null{}); |
| 13651 | 13645 | } else { |
| 13652 | | const slice = str.slice(self) orelse unreachable; |
| 13646 | const slice = str.slice(self).?; |
| 13653 | 13647 | if (slice.len > 0 and slice[slice.len - 1] == 0) |
| 13654 | 13648 | try constants_block.writeAbbrev(Constants.CString{ .string = slice[0 .. slice.len - 1] }) |
| 13655 | 13649 | else |
| ... | ... | @@ -13791,8 +13785,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13791 | 13785 | => |tag| { |
| 13792 | 13786 | const extra = self.constantExtraData(Constant.Assembly, data); |
| 13793 | 13787 | |
| 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).?; |
| 13796 | 13790 | |
| 13797 | 13791 | try record.ensureUnusedCapacity(self.gpa, 4 + assembly_slice.len + constraints_slice.len); |
| 13798 | 13792 | |
| ... | ... | @@ -14341,7 +14335,10 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14341 | 14335 | return switch (Ty) { |
| 14342 | 14336 | Value => @enumFromInt(adapter.getOffsetValueIndex(value)), |
| 14343 | 14337 | 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 | }), |
| 14345 | 14342 | else => value, |
| 14346 | 14343 | }; |
| 14347 | 14344 | } |