| ... | @@ -13114,7 +13114,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13114,7 +13114,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13114 | | 13114 | |
| 13115 | // TYPE_BLOCK | 13115 | // TYPE_BLOCK |
| 13116 | { | 13116 | { |
| 13117 | var type_block = try module_block.enterSubBlock(ir.Type); | 13117 | var type_block = try module_block.enterSubBlock(ir.Type, true); |
| 13118 | | 13118 | |
| 13119 | try type_block.writeAbbrev(ir.Type.NumEntry{ .num = @intCast(self.type_items.items.len) }); | 13119 | try type_block.writeAbbrev(ir.Type.NumEntry{ .num = @intCast(self.type_items.items.len) }); |
| 13120 | | 13120 | |
| ... | @@ -13221,7 +13221,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13221,7 +13221,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13221 | { | 13221 | { |
| 13222 | const ParamattrGroup = ir.ParamattrGroup; | 13222 | const ParamattrGroup = ir.ParamattrGroup; |
| 13223 | | 13223 | |
| 13224 | var paramattr_group_block = try module_block.enterSubBlock(ParamattrGroup); | 13224 | var paramattr_group_block = try module_block.enterSubBlock(ParamattrGroup, true); |
| 13225 | | 13225 | |
| 13226 | for (self.function_attributes_set.keys()) |func_attributes| { | 13226 | for (self.function_attributes_set.keys()) |func_attributes| { |
| 13227 | for (func_attributes.slice(self), 0..) |attributes, i| { | 13227 | for (func_attributes.slice(self), 0..) |attributes, i| { |
| ... | @@ -13424,7 +13424,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13424,7 +13424,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13424 | // PARAMATTR_BLOCK | 13424 | // PARAMATTR_BLOCK |
| 13425 | { | 13425 | { |
| 13426 | const Paramattr = ir.Paramattr; | 13426 | const Paramattr = ir.Paramattr; |
| 13427 | var paramattr_block = try module_block.enterSubBlock(Paramattr); | 13427 | var paramattr_block = try module_block.enterSubBlock(Paramattr, true); |
| 13428 | | 13428 | |
| 13429 | for (self.function_attributes_set.keys()) |func_attributes| { | 13429 | for (self.function_attributes_set.keys()) |func_attributes| { |
| 13430 | const func_attributes_slice = func_attributes.slice(self); | 13430 | const func_attributes_slice = func_attributes.slice(self); |
| ... | @@ -13627,7 +13627,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13627,7 +13627,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13627 | // CONSTANTS_BLOCK | 13627 | // CONSTANTS_BLOCK |
| 13628 | { | 13628 | { |
| 13629 | const Constants = ir.Constants; | 13629 | const Constants = ir.Constants; |
| 13630 | var constants_block = try module_block.enterSubBlock(Constants); | 13630 | var constants_block = try module_block.enterSubBlock(Constants, true); |
| 13631 | | 13631 | |
| 13632 | var current_type: Type = .none; | 13632 | var current_type: Type = .none; |
| 13633 | const tags = self.constant_items.items(.tag); | 13633 | const tags = self.constant_items.items(.tag); |
| ... | @@ -13953,7 +13953,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13953,7 +13953,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13953 | // METADATA_KIND_BLOCK | 13953 | // METADATA_KIND_BLOCK |
| 13954 | if (!self.strip) { | 13954 | if (!self.strip) { |
| 13955 | const MetadataKindBlock = ir.MetadataKindBlock; | 13955 | const MetadataKindBlock = ir.MetadataKindBlock; |
| 13956 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock); | 13956 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true); |
| 13957 | | 13957 | |
| 13958 | inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| { | 13958 | inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| { |
| 13959 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ | 13959 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ |
| ... | @@ -14006,7 +14006,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14006,7 +14006,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14006 | // METADATA_BLOCK | 14006 | // METADATA_BLOCK |
| 14007 | if (!self.strip) { | 14007 | if (!self.strip) { |
| 14008 | const MetadataBlock = ir.MetadataBlock; | 14008 | const MetadataBlock = ir.MetadataBlock; |
| 14009 | var metadata_block = try module_block.enterSubBlock(MetadataBlock); | 14009 | var metadata_block = try module_block.enterSubBlock(MetadataBlock, true); |
| 14010 | | 14010 | |
| 14011 | const MetadataBlockWriter = @TypeOf(metadata_block); | 14011 | const MetadataBlockWriter = @TypeOf(metadata_block); |
| 14012 | | 14012 | |
| ... | @@ -14411,6 +14411,34 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14411,6 +14411,34 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14411 | try metadata_block.end(); | 14411 | try metadata_block.end(); |
| 14412 | } | 14412 | } |
| 14413 | | 14413 | |
| | 14414 | // Block info |
| | 14415 | { |
| | 14416 | const BlockInfo = ir.BlockInfo; |
| | 14417 | var block_info_block = try module_block.enterSubBlock(BlockInfo, true); |
| | 14418 | |
| | 14419 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionBlock.id}); |
| | 14420 | inline for (ir.FunctionBlock.abbrevs) |abbrev| { |
| | 14421 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14422 | } |
| | 14423 | |
| | 14424 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionValueSymbolTable.id}); |
| | 14425 | inline for (ir.FunctionValueSymbolTable.abbrevs) |abbrev| { |
| | 14426 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14427 | } |
| | 14428 | |
| | 14429 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionMetadataBlock.id}); |
| | 14430 | inline for (ir.FunctionMetadataBlock.abbrevs) |abbrev| { |
| | 14431 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14432 | } |
| | 14433 | |
| | 14434 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.MetadataAttachmentBlock.id}); |
| | 14435 | inline for (ir.MetadataAttachmentBlock.abbrevs) |abbrev| { |
| | 14436 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14437 | } |
| | 14438 | |
| | 14439 | try block_info_block.end(); |
| | 14440 | } |
| | 14441 | |
| 14414 | // FUNCTION_BLOCKS | 14442 | // FUNCTION_BLOCKS |
| 14415 | { | 14443 | { |
| 14416 | const FunctionAdapter = struct { | 14444 | const FunctionAdapter = struct { |
| ... | @@ -14500,7 +14528,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14500,7 +14528,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14500 | | 14528 | |
| 14501 | if (func.instructions.len == 0) continue; | 14529 | if (func.instructions.len == 0) continue; |
| 14502 | | 14530 | |
| 14503 | var function_block = try module_block.enterSubBlock(FunctionBlock); | 14531 | var function_block = try module_block.enterSubBlock(FunctionBlock, false); |
| 14504 | | 14532 | |
| 14505 | try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len }); | 14533 | try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len }); |
| 14506 | | 14534 | |
| ... | @@ -14509,7 +14537,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14509,7 +14537,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14509 | // Emit function level metadata block | 14537 | // Emit function level metadata block |
| 14510 | if (!func.strip and func.debug_values.len > 0) { | 14538 | if (!func.strip and func.debug_values.len > 0) { |
| 14511 | const MetadataBlock = ir.FunctionMetadataBlock; | 14539 | const MetadataBlock = ir.FunctionMetadataBlock; |
| 14512 | var metadata_block = try function_block.enterSubBlock(MetadataBlock); | 14540 | var metadata_block = try function_block.enterSubBlock(MetadataBlock, false); |
| 14513 | | 14541 | |
| 14514 | for (func.debug_values) |value| { | 14542 | for (func.debug_values) |value| { |
| 14515 | try metadata_block.writeAbbrev(MetadataBlock.Value{ | 14543 | try metadata_block.writeAbbrev(MetadataBlock.Value{ |
| ... | @@ -14978,7 +15006,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14978,7 +15006,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14978 | .column = location.column, | 15006 | .column = location.column, |
| 14979 | .scope = @enumFromInt(metadata_adapter.getMetadataIndex(location.scope)), | 15007 | .scope = @enumFromInt(metadata_adapter.getMetadataIndex(location.scope)), |
| 14980 | .inlined_at = @enumFromInt(metadata_adapter.getMetadataIndex(location.inlined_at)), | 15008 | .inlined_at = @enumFromInt(metadata_adapter.getMetadataIndex(location.inlined_at)), |
| 14981 | .is_implicit = false, | | |
| 14982 | }); | 15009 | }); |
| 14983 | has_location = true; | 15010 | has_location = true; |
| 14984 | }, | 15011 | }, |
| ... | @@ -14995,7 +15022,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14995,7 +15022,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14995 | if (!func.strip) { | 15022 | if (!func.strip) { |
| 14996 | const ValueSymbolTable = ir.FunctionValueSymbolTable; | 15023 | const ValueSymbolTable = ir.FunctionValueSymbolTable; |
| 14997 | | 15024 | |
| 14998 | var value_symtab_block = try function_block.enterSubBlock(ValueSymbolTable); | 15025 | var value_symtab_block = try function_block.enterSubBlock(ValueSymbolTable, false); |
| 14999 | | 15026 | |
| 15000 | for (func.blocks, 0..) |block, block_index| { | 15027 | for (func.blocks, 0..) |block, block_index| { |
| 15001 | const name = block.instruction.name(&func); | 15028 | const name = block.instruction.name(&func); |
| ... | @@ -15020,7 +15047,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -15020,7 +15047,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 15020 | if (dbg == .none) break :blk; | 15047 | if (dbg == .none) break :blk; |
| 15021 | | 15048 | |
| 15022 | const MetadataAttachmentBlock = ir.MetadataAttachmentBlock; | 15049 | const MetadataAttachmentBlock = ir.MetadataAttachmentBlock; |
| 15023 | var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock); | 15050 | var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false); |
| 15024 | | 15051 | |
| 15025 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{ | 15052 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{ |
| 15026 | .kind = ir.MetadataKind.dbg, | 15053 | .kind = ir.MetadataKind.dbg, |