authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-25 21:44:10-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-02-25 21:44:10-08:00
log9dda2eb1abe675a99ff5d7ad85454b1cc5946c95
treea50f2d52e8a0745ce1f72bae25d609c448a485e6
parent91fb211faa3f37d08da55b0c8df92a6475624316
parented026b5dffd116d36aa51508e3eefa8c36838c07
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #19080 from jacobly0/llvm-per-mod-strip

llvm: implement per-module stripping

3 files changed, 119 insertions(+), 56 deletions(-)

src/Sema.zig+2-2
......@@ -6407,8 +6407,6 @@ fn zirDbgVar(
64076407 inst: Zir.Inst.Index,
64086408 air_tag: Air.Inst.Tag,
64096409) CompileError!void {
6410 if (block.is_comptime or block.ownerModule().strip) return;
6411
64126410 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
64136411 const operand = try sema.resolveInst(str_op.operand);
64146412 const name = str_op.getStr(sema.code);
......@@ -6422,6 +6420,8 @@ fn addDbgVar(
64226420 air_tag: Air.Inst.Tag,
64236421 name: []const u8,
64246422) CompileError!void {
6423 if (block.is_comptime or block.ownerModule().strip) return;
6424
64256425 const mod = sema.mod;
64266426 const operand_ty = sema.typeOf(operand);
64276427 const val_ty = switch (air_tag) {
src/codegen/llvm.zig+38-30
......@@ -837,11 +837,10 @@ pub const Object = struct {
837837 const gpa = comp.gpa;
838838 const target = comp.root_mod.resolved_target.result;
839839 const llvm_target_triple = try targetTriple(arena, target);
840 const strip = comp.root_mod.strip;
841840
842841 var builder = try Builder.init(.{
843842 .allocator = gpa,
844 .strip = strip,
843 .strip = comp.config.debug_format == .strip,
845844 .name = comp.root_name,
846845 .target = target,
847846 .triple = llvm_target_triple,
......@@ -1052,7 +1051,10 @@ pub const Object = struct {
10521051 const mod = o.module;
10531052 const errors_len = mod.global_error_set.count();
10541053
1055 var wip = try Builder.WipFunction.init(&o.builder, llvm_fn.ptrConst(&o.builder).kind.function);
1054 var wip = try Builder.WipFunction.init(&o.builder, .{
1055 .function = llvm_fn.ptrConst(&o.builder).kind.function,
1056 .strip = true,
1057 });
10561058 defer wip.deinit();
10571059 wip.cursor = .{ .block = try wip.block(0, "Entry") };
10581060
......@@ -1181,6 +1183,10 @@ pub const Object = struct {
11811183 }
11821184 }
11831185
1186 const target_triple_sentinel =
1187 try self.gpa.dupeZ(u8, self.builder.target_triple.slice(&self.builder).?);
1188 defer self.gpa.free(target_triple_sentinel);
1189
11841190 const emit_asm_msg = options.asm_path orelse "(none)";
11851191 const emit_bin_msg = options.bin_path orelse "(none)";
11861192 const post_llvm_ir_msg = options.post_ir_path orelse "(none)";
......@@ -1200,6 +1206,7 @@ pub const Object = struct {
12001206
12011207 const bitcode = try self.builder.toBitcode(self.gpa);
12021208 defer self.gpa.free(bitcode);
1209 self.builder.clearAndFree();
12031210
12041211 if (options.pre_bc_path) |path| {
12051212 var file = try std.fs.cwd().createFile(path, .{});
......@@ -1247,16 +1254,13 @@ pub const Object = struct {
12471254 };
12481255 defer context.dispose();
12491256
1250 const target_triple_sentinel =
1251 try self.gpa.dupeZ(u8, self.builder.target_triple.slice(&self.builder).?);
1252 defer self.gpa.free(target_triple_sentinel);
12531257 var target: *llvm.Target = undefined;
12541258 var error_message: [*:0]const u8 = undefined;
12551259 if (llvm.Target.getFromTriple(target_triple_sentinel, &target, &error_message).toBool()) {
12561260 defer llvm.disposeMessage(error_message);
12571261
12581262 log.err("LLVM failed to parse '{s}': {s}", .{
1259 self.builder.target_triple.slice(&self.builder).?,
1263 target_triple_sentinel,
12601264 error_message,
12611265 });
12621266 @panic("Invalid LLVM triple");
......@@ -1372,6 +1376,7 @@ pub const Object = struct {
13721376 air: Air,
13731377 liveness: Liveness,
13741378 ) !void {
1379 const comp = zcu.comp;
13751380 const func = zcu.funcInfo(func_index);
13761381 const decl_index = func.owner_decl;
13771382 const decl = zcu.declPtr(decl_index);
......@@ -1440,7 +1445,10 @@ pub const Object = struct {
14401445 function_index.setSection(try o.builder.string(section), &o.builder);
14411446
14421447 var deinit_wip = true;
1443 var wip = try Builder.WipFunction.init(&o.builder, function_index);
1448 var wip = try Builder.WipFunction.init(&o.builder, .{
1449 .function = function_index,
1450 .strip = owner_mod.strip,
1451 });
14441452 defer if (deinit_wip) wip.deinit();
14451453 wip.cursor = .{ .block = try wip.block(0, "Entry") };
14461454
......@@ -1459,8 +1467,6 @@ pub const Object = struct {
14591467 .unsigned => try attributes.addRetAttr(.zeroext, &o.builder),
14601468 };
14611469
1462 const comp = zcu.comp;
1463
14641470 const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(zcu) and
14651471 comp.config.any_error_tracing;
14661472
......@@ -1645,7 +1651,7 @@ pub const Object = struct {
16451651
16461652 function_index.setAttributes(try attributes.finish(&o.builder), &o.builder);
16471653
1648 const file, const subprogram = if (!o.builder.strip) debug_info: {
1654 const file, const subprogram = if (!wip.strip) debug_info: {
16491655 const file = try o.getDebugFile(namespace.file_scope);
16501656
16511657 const line_number = decl.src_line + 1;
......@@ -4614,7 +4620,10 @@ pub const Object = struct {
46144620 function_index.setAttributes(try attributes.finish(&o.builder), &o.builder);
46154621 gop.value_ptr.* = function_index.ptrConst(&o.builder).global;
46164622
4617 var wip = try Builder.WipFunction.init(&o.builder, function_index);
4623 var wip = try Builder.WipFunction.init(&o.builder, .{
4624 .function = function_index,
4625 .strip = true,
4626 });
46184627 defer wip.deinit();
46194628 wip.cursor = .{ .block = try wip.block(0, "Entry") };
46204629
......@@ -4684,23 +4693,23 @@ pub const DeclGen = struct {
46844693
46854694 fn genDecl(dg: *DeclGen) !void {
46864695 const o = dg.object;
4687 const mod = o.module;
4696 const zcu = o.module;
46884697 const decl = dg.decl;
46894698 const decl_index = dg.decl_index;
46904699 assert(decl.has_tv);
46914700
4692 if (decl.val.getExternFunc(mod)) |extern_func| {
4701 if (decl.val.getExternFunc(zcu)) |extern_func| {
46934702 _ = try o.resolveLlvmFunction(extern_func.decl);
46944703 } else {
46954704 const variable_index = try o.resolveGlobalDecl(decl_index);
46964705 variable_index.setAlignment(
4697 decl.getAlignment(mod).toLlvm(),
4706 decl.getAlignment(zcu).toLlvm(),
46984707 &o.builder,
46994708 );
4700 if (mod.intern_pool.stringToSliceUnwrap(decl.@"linksection")) |section|
4709 if (zcu.intern_pool.stringToSliceUnwrap(decl.@"linksection")) |section|
47014710 variable_index.setSection(try o.builder.string(section), &o.builder);
47024711 assert(decl.has_tv);
4703 const init_val = if (decl.val.getVariable(mod)) |decl_var| decl_var.init else init_val: {
4712 const init_val = if (decl.val.getVariable(zcu)) |decl_var| decl_var.init else init_val: {
47044713 variable_index.setMutability(.constant, &o.builder);
47054714 break :init_val decl.val.toIntern();
47064715 };
......@@ -4712,12 +4721,15 @@ pub const DeclGen = struct {
47124721 const line_number = decl.src_line + 1;
47134722 const is_internal_linkage = !o.module.decl_exports.contains(decl_index);
47144723
4715 if (dg.object.builder.strip) return;
4724 const namespace = zcu.namespacePtr(decl.src_namespace);
4725 const owner_mod = namespace.file_scope.mod;
47164726
4717 const debug_file = try o.getDebugFile(mod.namespacePtr(decl.src_namespace).file_scope);
4727 if (owner_mod.strip) return;
4728
4729 const debug_file = try o.getDebugFile(namespace.file_scope);
47184730
47194731 const debug_global_var = try o.builder.debugGlobalVar(
4720 try o.builder.metadataString(mod.intern_pool.stringToSlice(decl.name)), // Name
4732 try o.builder.metadataString(zcu.intern_pool.stringToSlice(decl.name)), // Name
47214733 try o.builder.metadataStringFromString(variable_index.name(&o.builder)), // Linkage name
47224734 debug_file, // File
47234735 debug_file, // Scope
......@@ -4733,7 +4745,7 @@ pub const DeclGen = struct {
47334745 debug_global_var,
47344746 debug_expression,
47354747 );
4736 if (!is_internal_linkage or decl.isExtern(mod))
4748 if (!is_internal_linkage or decl.isExtern(zcu))
47374749 variable_index.setGlobalVariableExpression(debug_global_var_expression, &o.builder);
47384750 try o.debug_globals.append(o.gpa, debug_global_var_expression);
47394751 }
......@@ -6568,7 +6580,6 @@ pub const FuncGen = struct {
65686580 }
65696581
65706582 fn airDbgStmt(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6571 if (self.wip.builder.strip) return .none;
65726583 const dbg_stmt = self.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt;
65736584 self.prev_dbg_line = @intCast(self.base_line + dbg_stmt.line + 1);
65746585 self.prev_dbg_column = @intCast(dbg_stmt.column + 1);
......@@ -6591,7 +6602,6 @@ pub const FuncGen = struct {
65916602 }
65926603
65936604 fn airDbgInlineBegin(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6594 if (self.wip.builder.strip) return .none;
65956605 const o = self.dg.object;
65966606 const zcu = o.module;
65976607
......@@ -6658,7 +6668,6 @@ pub const FuncGen = struct {
66586668 }
66596669
66606670 fn airDbgInlineEnd(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
6661 if (self.wip.builder.strip) return .none;
66626671 const o = self.dg.object;
66636672
66646673 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
......@@ -6675,7 +6684,6 @@ pub const FuncGen = struct {
66756684 }
66766685
66776686 fn airDbgBlockBegin(self: *FuncGen) Allocator.Error!Builder.Value {
6678 if (self.wip.builder.strip) return .none;
66796687 const o = self.dg.object;
66806688
66816689 try self.scope_stack.append(self.gpa, self.scope);
......@@ -6691,13 +6699,11 @@ pub const FuncGen = struct {
66916699 }
66926700
66936701 fn airDbgBlockEnd(self: *FuncGen) !Builder.Value {
6694 if (self.wip.builder.strip) return .none;
66956702 self.scope = self.scope_stack.pop();
66966703 return .none;
66976704 }
66986705
66996706 fn airDbgVarPtr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6700 if (self.wip.builder.strip) return .none;
67016707 const o = self.dg.object;
67026708 const mod = o.module;
67036709 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
......@@ -6730,7 +6736,6 @@ pub const FuncGen = struct {
67306736 }
67316737
67326738 fn airDbgVarVal(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6733 if (self.wip.builder.strip) return .none;
67346739 const o = self.dg.object;
67356740 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
67366741 const operand = try self.resolveInst(pl_op.operand);
......@@ -8817,7 +8822,7 @@ pub const FuncGen = struct {
88178822 const arg_val = self.args[self.arg_index];
88188823 self.arg_index += 1;
88198824
8820 if (self.wip.builder.strip) return arg_val;
8825 if (self.wip.strip) return arg_val;
88218826
88228827 const inst_ty = self.typeOfIndex(inst);
88238828 if (needDbgVarWorkaround(o)) return arg_val;
......@@ -9664,7 +9669,10 @@ pub const FuncGen = struct {
96649669 function_index.setAttributes(try attributes.finish(&o.builder), &o.builder);
96659670 gop.value_ptr.* = function_index;
96669671
9667 var wip = try Builder.WipFunction.init(&o.builder, function_index);
9672 var wip = try Builder.WipFunction.init(&o.builder, .{
9673 .function = function_index,
9674 .strip = true,
9675 });
96689676 defer wip.deinit();
96699677 wip.cursor = .{ .block = try wip.block(0, "Entry") };
96709678
src/codegen/llvm/Builder.zig+79-24
......@@ -3797,6 +3797,7 @@ pub const Function = struct {
37973797 instructions: std.MultiArrayList(Instruction) = .{},
37983798 names: [*]const String = &[0]String{},
37993799 value_indices: [*]const u32 = &[0]u32{},
3800 strip: bool,
38003801 debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{},
38013802 debug_values: []const Instruction.Index = &.{},
38023803 extra: []const u32 = &.{},
......@@ -4890,6 +4891,7 @@ pub const WipFunction = struct {
48904891 blocks: std.ArrayListUnmanaged(Block),
48914892 instructions: std.MultiArrayList(Instruction),
48924893 names: std.ArrayListUnmanaged(String),
4894 strip: bool,
48934895 debug_locations: std.AutoArrayHashMapUnmanaged(Instruction.Index, DebugLocation),
48944896 debug_values: std.AutoArrayHashMapUnmanaged(Instruction.Index, void),
48954897 extra: std.ArrayListUnmanaged(u32),
......@@ -4922,31 +4924,35 @@ pub const WipFunction = struct {
49224924
49234925 pub const Instruction = Function.Instruction;
49244926
4925 pub fn init(builder: *Builder, function: Function.Index) Allocator.Error!WipFunction {
4927 pub fn init(builder: *Builder, options: struct {
4928 function: Function.Index,
4929 strip: bool,
4930 }) Allocator.Error!WipFunction {
49264931 var self: WipFunction = .{
49274932 .builder = builder,
4928 .function = function,
4933 .function = options.function,
49294934 .prev_debug_location = .no_location,
49304935 .debug_location = .no_location,
49314936 .cursor = undefined,
49324937 .blocks = .{},
49334938 .instructions = .{},
49344939 .names = .{},
4940 .strip = options.strip,
49354941 .debug_locations = .{},
49364942 .debug_values = .{},
49374943 .extra = .{},
49384944 };
49394945 errdefer self.deinit();
49404946
4941 const params_len = function.typeOf(self.builder).functionParameters(self.builder).len;
4947 const params_len = options.function.typeOf(self.builder).functionParameters(self.builder).len;
49424948 try self.ensureUnusedExtraCapacity(params_len, NoExtra, 0);
49434949 try self.instructions.ensureUnusedCapacity(self.builder.gpa, params_len);
4944 if (!self.builder.strip) {
4950 if (!self.strip) {
49454951 try self.names.ensureUnusedCapacity(self.builder.gpa, params_len);
49464952 }
49474953 for (0..params_len) |param_index| {
49484954 self.instructions.appendAssumeCapacity(.{ .tag = .arg, .data = @intCast(param_index) });
4949 if (!self.builder.strip) {
4955 if (!self.strip) {
49504956 self.names.appendAssumeCapacity(.empty); // TODO: param names
49514957 }
49524958 }
......@@ -4967,7 +4973,7 @@ pub const WipFunction = struct {
49674973 try self.blocks.ensureUnusedCapacity(self.builder.gpa, 1);
49684974
49694975 const index: Block.Index = @enumFromInt(self.blocks.items.len);
4970 const final_name = if (self.builder.strip) .empty else try self.builder.string(name);
4976 const final_name = if (self.strip) .empty else try self.builder.string(name);
49714977 self.blocks.appendAssumeCapacity(.{
49724978 .name = final_name,
49734979 .incoming = incoming,
......@@ -5828,7 +5834,7 @@ pub const WipFunction = struct {
58285834 }
58295835
58305836 pub fn debugValue(self: *WipFunction, value: Value) Allocator.Error!Metadata {
5831 if (self.builder.strip) return .none;
5837 if (self.strip) return .none;
58325838 return switch (value.unwrap()) {
58335839 .instruction => |instr_index| blk: {
58345840 const gop = try self.debug_values.getOrPut(self.builder.gpa, instr_index);
......@@ -6015,7 +6021,7 @@ pub const WipFunction = struct {
60156021 value_index += 1;
60166022 function.instructions.appendAssumeCapacity(argument);
60176023 names[@intFromEnum(new_argument_index)] = try wip_name.map(
6018 if (self.builder.strip) .empty else self.names.items[@intFromEnum(old_argument_index)],
6024 if (self.strip) .empty else self.names.items[@intFromEnum(old_argument_index)],
60196025 ".",
60206026 );
60216027 if (self.debug_locations.get(old_argument_index)) |location| {
......@@ -6333,7 +6339,7 @@ pub const WipFunction = struct {
63336339 },
63346340 }
63356341 function.instructions.appendAssumeCapacity(instruction);
6336 names[@intFromEnum(new_instruction_index)] = try wip_name.map(if (self.builder.strip)
6342 names[@intFromEnum(new_instruction_index)] = try wip_name.map(if (self.strip)
63376343 if (old_instruction_index.hasResultWip(self)) .empty else .none
63386344 else
63396345 self.names.items[@intFromEnum(old_instruction_index)], ".");
......@@ -6356,6 +6362,7 @@ pub const WipFunction = struct {
63566362 function.blocks = blocks;
63576363 function.names = names.ptr;
63586364 function.value_indices = value_indices.ptr;
6365 function.strip = self.strip;
63596366 function.debug_locations = debug_locations;
63606367 function.debug_values = debug_values;
63616368 }
......@@ -6503,19 +6510,19 @@ pub const WipFunction = struct {
65036510 ) Allocator.Error!Instruction.Index {
65046511 const block_instructions = &self.cursor.block.ptr(self).instructions;
65056512 try self.instructions.ensureUnusedCapacity(self.builder.gpa, 1);
6506 if (!self.builder.strip) {
6513 if (!self.strip) {
65076514 try self.names.ensureUnusedCapacity(self.builder.gpa, 1);
65086515 try self.debug_locations.ensureUnusedCapacity(self.builder.gpa, 1);
65096516 }
65106517 try block_instructions.ensureUnusedCapacity(self.builder.gpa, 1);
65116518 const final_name = if (name) |n|
6512 if (self.builder.strip) .empty else try self.builder.string(n)
6519 if (self.strip) .empty else try self.builder.string(n)
65136520 else
65146521 .none;
65156522
65166523 const index: Instruction.Index = @enumFromInt(self.instructions.len);
65176524 self.instructions.appendAssumeCapacity(instruction);
6518 if (!self.builder.strip) {
6525 if (!self.strip) {
65196526 self.names.appendAssumeCapacity(final_name);
65206527 if (block_instructions.items.len == 0 or
65216528 !std.meta.eql(self.debug_location, self.prev_debug_location))
......@@ -8389,6 +8396,50 @@ pub fn init(options: Options) Allocator.Error!Builder {
83898396 return self;
83908397}
83918398
8399pub fn clearAndFree(self: *Builder) void {
8400 self.module_asm.clearAndFree(self.gpa);
8401
8402 self.string_map.clearAndFree(self.gpa);
8403 self.string_indices.clearAndFree(self.gpa);
8404 self.string_bytes.clearAndFree(self.gpa);
8405
8406 self.types.clearAndFree(self.gpa);
8407 self.next_unique_type_id.clearAndFree(self.gpa);
8408 self.type_map.clearAndFree(self.gpa);
8409 self.type_items.clearAndFree(self.gpa);
8410 self.type_extra.clearAndFree(self.gpa);
8411
8412 self.attributes.clearAndFree(self.gpa);
8413 self.attributes_map.clearAndFree(self.gpa);
8414 self.attributes_indices.clearAndFree(self.gpa);
8415 self.attributes_extra.clearAndFree(self.gpa);
8416
8417 self.function_attributes_set.clearAndFree(self.gpa);
8418
8419 self.globals.clearAndFree(self.gpa);
8420 self.next_unique_global_id.clearAndFree(self.gpa);
8421 self.aliases.clearAndFree(self.gpa);
8422 self.variables.clearAndFree(self.gpa);
8423 for (self.functions.items) |*function| function.deinit(self.gpa);
8424 self.functions.clearAndFree(self.gpa);
8425
8426 self.constant_map.clearAndFree(self.gpa);
8427 self.constant_items.shrinkAndFree(self.gpa, 0);
8428 self.constant_extra.clearAndFree(self.gpa);
8429 self.constant_limbs.clearAndFree(self.gpa);
8430
8431 self.metadata_map.clearAndFree(self.gpa);
8432 self.metadata_items.shrinkAndFree(self.gpa, 0);
8433 self.metadata_extra.clearAndFree(self.gpa);
8434 self.metadata_limbs.clearAndFree(self.gpa);
8435 self.metadata_forward_references.clearAndFree(self.gpa);
8436 self.metadata_named.clearAndFree(self.gpa);
8437
8438 self.metadata_string_map.clearAndFree(self.gpa);
8439 self.metadata_string_indices.clearAndFree(self.gpa);
8440 self.metadata_string_bytes.clearAndFree(self.gpa);
8441}
8442
83928443pub fn deinit(self: *Builder) void {
83938444 self.module_asm.deinit(self.gpa);
83948445
......@@ -8723,11 +8774,14 @@ pub fn addFunctionAssumeCapacity(
87238774) Function.Index {
87248775 assert(ty.isFunction(self));
87258776 const function_index: Function.Index = @enumFromInt(self.functions.items.len);
8726 self.functions.appendAssumeCapacity(.{ .global = self.addGlobalAssumeCapacity(name, .{
8727 .addr_space = addr_space,
8728 .type = ty,
8729 .kind = .{ .function = function_index },
8730 }) });
8777 self.functions.appendAssumeCapacity(.{
8778 .global = self.addGlobalAssumeCapacity(name, .{
8779 .addr_space = addr_space,
8780 .type = ty,
8781 .kind = .{ .function = function_index },
8782 }),
8783 .strip = undefined,
8784 });
87318785 return function_index;
87328786}
87338787
......@@ -14396,16 +14450,17 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1439614450 return @intCast(switch (value.unwrap()) {
1439714451 .instruction => |instruction| instruction.valueIndex(adapter.func) + adapter.firstInstr(),
1439814452 .constant => |constant| adapter.constant_adapter.getConstantIndex(constant),
14399 .metadata => |metadata| if (!adapter.metadata_adapter.builder.strip) blk: {
14453 .metadata => |metadata| {
14454 assert(!adapter.func.strip);
1440014455 const real_metadata = metadata.unwrap(adapter.metadata_adapter.builder);
1440114456 if (@intFromEnum(real_metadata) < Metadata.first_local_metadata)
14402 break :blk adapter.metadata_adapter.getMetadataIndex(real_metadata) - 1;
14457 return adapter.metadata_adapter.getMetadataIndex(real_metadata) - 1;
1440314458
1440414459 return @intCast(@intFromEnum(metadata) -
1440514460 Metadata.first_local_metadata +
1440614461 adapter.metadata_adapter.builder.metadata_string_map.count() - 1 +
1440714462 adapter.metadata_adapter.builder.metadata_map.count() - 1);
14408 } else unreachable,
14463 },
1440914464 });
1441014465 }
1441114466
......@@ -14452,7 +14507,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1445214507 var adapter = FunctionAdapter.init(constant_adapter, metadata_adapter, &func);
1445314508
1445414509 // Emit function level metadata block
14455 if (!self.strip and func.debug_values.len != 0) {
14510 if (!func.strip and func.debug_values.len > 0) {
1445614511 const MetadataBlock = ir.FunctionMetadataBlock;
1445714512 var metadata_block = try function_block.enterSubBlock(MetadataBlock);
1445814513
......@@ -14913,7 +14968,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1491314968 },
1491414969 }
1491514970
14916 if (!self.strip) {
14971 if (!func.strip) {
1491714972 if (func.debug_locations.get(@enumFromInt(instr_index))) |debug_location| {
1491814973 switch (debug_location) {
1491914974 .no_location => has_location = false,
......@@ -14937,7 +14992,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1493714992 }
1493814993
1493914994 // VALUE_SYMTAB
14940 if (!self.strip) {
14995 if (!func.strip) {
1494114996 const ValueSymbolTable = ir.FunctionValueSymbolTable;
1494214997
1494314998 var value_symtab_block = try function_block.enterSubBlock(ValueSymbolTable);
......@@ -14959,7 +15014,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1495915014 }
1496015015
1496115016 // METADATA_ATTACHMENT_BLOCK
14962 if (!self.strip) blk: {
15017 if (!func.strip) blk: {
1496315018 const dbg = func.global.ptrConst(self).dbg;
1496415019
1496515020 if (dbg == .none) break :blk;