| ... | @@ -13060,7 +13060,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13060,7 +13060,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13060 | | 13060 | |
| 13061 | // TYPE_BLOCK | 13061 | // TYPE_BLOCK |
| 13062 | { | 13062 | { |
| 13063 | var type_block = try module_block.enterSubBlock(ir.Type); | 13063 | var type_block = try module_block.enterSubBlock(ir.Type, true); |
| 13064 | | 13064 | |
| 13065 | try type_block.writeAbbrev(ir.Type.NumEntry{ .num = @intCast(self.type_items.items.len) }); | 13065 | try type_block.writeAbbrev(ir.Type.NumEntry{ .num = @intCast(self.type_items.items.len) }); |
| 13066 | | 13066 | |
| ... | @@ -13167,7 +13167,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13167,7 +13167,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13167 | { | 13167 | { |
| 13168 | const ParamattrGroup = ir.ParamattrGroup; | 13168 | const ParamattrGroup = ir.ParamattrGroup; |
| 13169 | | 13169 | |
| 13170 | var paramattr_group_block = try module_block.enterSubBlock(ParamattrGroup); | 13170 | var paramattr_group_block = try module_block.enterSubBlock(ParamattrGroup, true); |
| 13171 | | 13171 | |
| 13172 | for (self.function_attributes_set.keys()) |func_attributes| { | 13172 | for (self.function_attributes_set.keys()) |func_attributes| { |
| 13173 | for (func_attributes.slice(self), 0..) |attributes, i| { | 13173 | for (func_attributes.slice(self), 0..) |attributes, i| { |
| ... | @@ -13370,7 +13370,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13370,7 +13370,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13370 | // PARAMATTR_BLOCK | 13370 | // PARAMATTR_BLOCK |
| 13371 | { | 13371 | { |
| 13372 | const Paramattr = ir.Paramattr; | 13372 | const Paramattr = ir.Paramattr; |
| 13373 | var paramattr_block = try module_block.enterSubBlock(Paramattr); | 13373 | var paramattr_block = try module_block.enterSubBlock(Paramattr, true); |
| 13374 | | 13374 | |
| 13375 | for (self.function_attributes_set.keys()) |func_attributes| { | 13375 | for (self.function_attributes_set.keys()) |func_attributes| { |
| 13376 | const func_attributes_slice = func_attributes.slice(self); | 13376 | const func_attributes_slice = func_attributes.slice(self); |
| ... | @@ -13573,7 +13573,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13573,7 +13573,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13573 | // CONSTANTS_BLOCK | 13573 | // CONSTANTS_BLOCK |
| 13574 | { | 13574 | { |
| 13575 | const Constants = ir.Constants; | 13575 | const Constants = ir.Constants; |
| 13576 | var constants_block = try module_block.enterSubBlock(Constants); | 13576 | var constants_block = try module_block.enterSubBlock(Constants, true); |
| 13577 | | 13577 | |
| 13578 | var current_type: Type = .none; | 13578 | var current_type: Type = .none; |
| 13579 | const tags = self.constant_items.items(.tag); | 13579 | const tags = self.constant_items.items(.tag); |
| ... | @@ -13899,7 +13899,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13899,7 +13899,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13899 | // METADATA_KIND_BLOCK | 13899 | // METADATA_KIND_BLOCK |
| 13900 | if (!self.strip) { | 13900 | if (!self.strip) { |
| 13901 | const MetadataKindBlock = ir.MetadataKindBlock; | 13901 | const MetadataKindBlock = ir.MetadataKindBlock; |
| 13902 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock); | 13902 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true); |
| 13903 | | 13903 | |
| 13904 | inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| { | 13904 | inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| { |
| 13905 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ | 13905 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ |
| ... | @@ -13952,7 +13952,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -13952,7 +13952,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13952 | // METADATA_BLOCK | 13952 | // METADATA_BLOCK |
| 13953 | if (!self.strip) { | 13953 | if (!self.strip) { |
| 13954 | const MetadataBlock = ir.MetadataBlock; | 13954 | const MetadataBlock = ir.MetadataBlock; |
| 13955 | var metadata_block = try module_block.enterSubBlock(MetadataBlock); | 13955 | var metadata_block = try module_block.enterSubBlock(MetadataBlock, true); |
| 13956 | | 13956 | |
| 13957 | const MetadataBlockWriter = @TypeOf(metadata_block); | 13957 | const MetadataBlockWriter = @TypeOf(metadata_block); |
| 13958 | | 13958 | |
| ... | @@ -14357,6 +14357,34 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14357,6 +14357,34 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14357 | try metadata_block.end(); | 14357 | try metadata_block.end(); |
| 14358 | } | 14358 | } |
| 14359 | | 14359 | |
| | 14360 | // Block info |
| | 14361 | { |
| | 14362 | const BlockInfo = ir.BlockInfo; |
| | 14363 | var block_info_block = try module_block.enterSubBlock(BlockInfo, true); |
| | 14364 | |
| | 14365 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionBlock.id}); |
| | 14366 | inline for (ir.FunctionBlock.abbrevs) |abbrev| { |
| | 14367 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14368 | } |
| | 14369 | |
| | 14370 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionValueSymbolTable.id}); |
| | 14371 | inline for (ir.FunctionValueSymbolTable.abbrevs) |abbrev| { |
| | 14372 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14373 | } |
| | 14374 | |
| | 14375 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.FunctionMetadataBlock.id}); |
| | 14376 | inline for (ir.FunctionMetadataBlock.abbrevs) |abbrev| { |
| | 14377 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14378 | } |
| | 14379 | |
| | 14380 | try block_info_block.writeUnabbrev(BlockInfo.set_block_id, &.{ir.MetadataAttachmentBlock.id}); |
| | 14381 | inline for (ir.MetadataAttachmentBlock.abbrevs) |abbrev| { |
| | 14382 | try block_info_block.defineAbbrev(&abbrev.ops); |
| | 14383 | } |
| | 14384 | |
| | 14385 | try block_info_block.end(); |
| | 14386 | } |
| | 14387 | |
| 14360 | // FUNCTION_BLOCKS | 14388 | // FUNCTION_BLOCKS |
| 14361 | { | 14389 | { |
| 14362 | const FunctionAdapter = struct { | 14390 | const FunctionAdapter = struct { |
| ... | @@ -14445,7 +14473,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14445,7 +14473,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14445 | | 14473 | |
| 14446 | if (func.instructions.len == 0) continue; | 14474 | if (func.instructions.len == 0) continue; |
| 14447 | | 14475 | |
| 14448 | var function_block = try module_block.enterSubBlock(FunctionBlock); | 14476 | var function_block = try module_block.enterSubBlock(FunctionBlock, false); |
| 14449 | | 14477 | |
| 14450 | try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len }); | 14478 | try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len }); |
| 14451 | | 14479 | |
| ... | @@ -14454,7 +14482,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14454,7 +14482,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14454 | // Emit function level metadata block | 14482 | // Emit function level metadata block |
| 14455 | if (!self.strip and func.debug_values.len != 0) { | 14483 | if (!self.strip and func.debug_values.len != 0) { |
| 14456 | const MetadataBlock = ir.FunctionMetadataBlock; | 14484 | const MetadataBlock = ir.FunctionMetadataBlock; |
| 14457 | var metadata_block = try function_block.enterSubBlock(MetadataBlock); | 14485 | var metadata_block = try function_block.enterSubBlock(MetadataBlock, false); |
| 14458 | | 14486 | |
| 14459 | for (func.debug_values) |value| { | 14487 | for (func.debug_values) |value| { |
| 14460 | try metadata_block.writeAbbrev(MetadataBlock.Value{ | 14488 | try metadata_block.writeAbbrev(MetadataBlock.Value{ |
| ... | @@ -14940,7 +14968,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14940,7 +14968,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14940 | if (!self.strip) { | 14968 | if (!self.strip) { |
| 14941 | const ValueSymbolTable = ir.FunctionValueSymbolTable; | 14969 | const ValueSymbolTable = ir.FunctionValueSymbolTable; |
| 14942 | | 14970 | |
| 14943 | var value_symtab_block = try function_block.enterSubBlock(ValueSymbolTable); | 14971 | var value_symtab_block = try function_block.enterSubBlock(ValueSymbolTable, false); |
| 14944 | | 14972 | |
| 14945 | for (func.blocks, 0..) |block, block_index| { | 14973 | for (func.blocks, 0..) |block, block_index| { |
| 14946 | const name = block.instruction.name(&func); | 14974 | const name = block.instruction.name(&func); |
| ... | @@ -14965,7 +14993,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co | ... | @@ -14965,7 +14993,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14965 | if (dbg == .none) break :blk; | 14993 | if (dbg == .none) break :blk; |
| 14966 | | 14994 | |
| 14967 | const MetadataAttachmentBlock = ir.MetadataAttachmentBlock; | 14995 | const MetadataAttachmentBlock = ir.MetadataAttachmentBlock; |
| 14968 | var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock); | 14996 | var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false); |
| 14969 | | 14997 | |
| 14970 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{ | 14998 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{ |
| 14971 | .kind = ir.MetadataKind.dbg, | 14999 | .kind = ir.MetadataKind.dbg, |