| ... | @@ -822,8 +822,8 @@ pub const Object = struct { | ... | @@ -822,8 +822,8 @@ pub const Object = struct { |
| 822 | /// This is denormalized data. | 822 | /// This is denormalized data. |
| 823 | struct_field_map: std.AutoHashMapUnmanaged(ZigStructField, c_uint), | 823 | struct_field_map: std.AutoHashMapUnmanaged(ZigStructField, c_uint), |
| 824 | | 824 | |
| 825 | /// Values for `@llvm.compiler.used`. | 825 | /// Values for `@llvm.used`. |
| 826 | compiler_used: std.ArrayListUnmanaged(Builder.Constant), | 826 | used: std.ArrayListUnmanaged(Builder.Constant), |
| 827 | | 827 | |
| 828 | const ZigStructField = struct { | 828 | const ZigStructField = struct { |
| 829 | struct_ty: InternPool.Index, | 829 | struct_ty: InternPool.Index, |
| ... | @@ -978,7 +978,7 @@ pub const Object = struct { | ... | @@ -978,7 +978,7 @@ pub const Object = struct { |
| 978 | .error_name_table = .none, | 978 | .error_name_table = .none, |
| 979 | .null_opt_usize = .no_init, | 979 | .null_opt_usize = .no_init, |
| 980 | .struct_field_map = .{}, | 980 | .struct_field_map = .{}, |
| 981 | .compiler_used = .{}, | 981 | .used = .{}, |
| 982 | }; | 982 | }; |
| 983 | return obj; | 983 | return obj; |
| 984 | } | 984 | } |
| ... | @@ -1110,11 +1110,11 @@ pub const Object = struct { | ... | @@ -1110,11 +1110,11 @@ pub const Object = struct { |
| 1110 | try o.genCmpLtErrorsLenFunction(); | 1110 | try o.genCmpLtErrorsLenFunction(); |
| 1111 | try o.genModuleLevelAssembly(); | 1111 | try o.genModuleLevelAssembly(); |
| 1112 | | 1112 | |
| 1113 | if (o.compiler_used.items.len > 0) { | 1113 | if (o.used.items.len > 0) { |
| 1114 | const array_llvm_ty = try o.builder.arrayType(o.compiler_used.items.len, .ptr); | 1114 | const array_llvm_ty = try o.builder.arrayType(o.used.items.len, .ptr); |
| 1115 | const init_val = try o.builder.arrayConst(array_llvm_ty, o.compiler_used.items); | 1115 | const init_val = try o.builder.arrayConst(array_llvm_ty, o.used.items); |
| 1116 | const compiler_used_variable = try o.builder.addVariable( | 1116 | const compiler_used_variable = try o.builder.addVariable( |
| 1117 | try o.builder.strtabString("llvm.compiler.used"), | 1117 | try o.builder.strtabString("llvm.used"), |
| 1118 | array_llvm_ty, | 1118 | array_llvm_ty, |
| 1119 | .default, | 1119 | .default, |
| 1120 | ); | 1120 | ); |
| ... | @@ -1317,7 +1317,8 @@ pub const Object = struct { | ... | @@ -1317,7 +1317,8 @@ pub const Object = struct { |
| 1317 | // Zig emits its own PC table instrumentation. | 1317 | // Zig emits its own PC table instrumentation. |
| 1318 | .PCTable = false, | 1318 | .PCTable = false, |
| 1319 | .NoPrune = false, | 1319 | .NoPrune = false, |
| 1320 | .StackDepth = false, | 1320 | // Workaround for https://github.com/llvm/llvm-project/pull/106464 |
| | 1321 | .StackDepth = true, |
| 1321 | .TraceLoads = false, | 1322 | .TraceLoads = false, |
| 1322 | .TraceStores = false, | 1323 | .TraceStores = false, |
| 1323 | .CollectControlFlow = false, | 1324 | .CollectControlFlow = false, |
| ... | @@ -1686,7 +1687,10 @@ pub const Object = struct { | ... | @@ -1686,7 +1687,10 @@ pub const Object = struct { |
| 1686 | // The void type used here is a placeholder to be replaced with an | 1687 | // The void type used here is a placeholder to be replaced with an |
| 1687 | // array of the appropriate size after the POI count is known. | 1688 | // array of the appropriate size after the POI count is known. |
| 1688 | | 1689 | |
| 1689 | const counters_variable = try o.builder.addVariable(.empty, .void, .default); | 1690 | // Due to error "members of llvm.compiler.used must be named", this global needs a name. |
| | 1691 | const anon_name = try o.builder.strtabStringFmt("__sancov_gen_.{d}", .{o.used.items.len}); |
| | 1692 | const counters_variable = try o.builder.addVariable(anon_name, .void, .default); |
| | 1693 | try o.used.append(gpa, counters_variable.toConst(&o.builder)); |
| 1690 | counters_variable.setLinkage(.private, &o.builder); | 1694 | counters_variable.setLinkage(.private, &o.builder); |
| 1691 | counters_variable.setAlignment(comptime Builder.Alignment.fromByteUnits(1), &o.builder); | 1695 | counters_variable.setAlignment(comptime Builder.Alignment.fromByteUnits(1), &o.builder); |
| 1692 | counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder); | 1696 | counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder); |
| ... | @@ -1741,17 +1745,15 @@ pub const Object = struct { | ... | @@ -1741,17 +1745,15 @@ pub const Object = struct { |
| 1741 | | 1745 | |
| 1742 | const array_llvm_ty = try o.builder.arrayType(f.pcs.items.len, .ptr); | 1746 | const array_llvm_ty = try o.builder.arrayType(f.pcs.items.len, .ptr); |
| 1743 | const init_val = try o.builder.arrayConst(array_llvm_ty, f.pcs.items); | 1747 | const init_val = try o.builder.arrayConst(array_llvm_ty, f.pcs.items); |
| 1744 | const pcs_variable = try o.builder.addVariable(.empty, array_llvm_ty, .default); | 1748 | // Due to error "members of llvm.compiler.used must be named", this global needs a name. |
| | 1749 | const anon_name = try o.builder.strtabStringFmt("__sancov_gen_.{d}", .{o.used.items.len}); |
| | 1750 | const pcs_variable = try o.builder.addVariable(anon_name, array_llvm_ty, .default); |
| | 1751 | try o.used.append(gpa, pcs_variable.toConst(&o.builder)); |
| 1745 | pcs_variable.setLinkage(.private, &o.builder); | 1752 | pcs_variable.setLinkage(.private, &o.builder); |
| 1746 | pcs_variable.setMutability(.constant, &o.builder); | 1753 | pcs_variable.setMutability(.constant, &o.builder); |
| 1747 | pcs_variable.setAlignment(Type.usize.abiAlignment(zcu).toLlvm(), &o.builder); | 1754 | pcs_variable.setAlignment(Type.usize.abiAlignment(zcu).toLlvm(), &o.builder); |
| 1748 | pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder); | 1755 | pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder); |
| 1749 | try pcs_variable.setInitializer(init_val, &o.builder); | 1756 | try pcs_variable.setInitializer(init_val, &o.builder); |
| 1750 | | | |
| 1751 | try o.compiler_used.appendSlice(gpa, &.{ | | |
| 1752 | f.counters_variable.toConst(&o.builder), | | |
| 1753 | pcs_variable.toConst(&o.builder), | | |
| 1754 | }); | | |
| 1755 | } | 1757 | } |
| 1756 | | 1758 | |
| 1757 | try fg.wip.finish(); | 1759 | try fg.wip.finish(); |