Skip to content

Commit a558885

Browse files
committed
LLVM backend: fixes
* delete dead code * don't access stack trace too early * revert unintended edit
1 parent 041bcbd commit a558885

File tree

3 files changed

+3
-43
lines changed

3 files changed

+3
-43
lines changed

src/Sema.zig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9705,7 +9705,6 @@ fn funcCommon(
97059705
func_inst,
97069706
cc_src,
97079707
is_noinline,
9708-
is_generic,
97099708
);
97109709
}
97119710

@@ -9745,7 +9744,6 @@ fn funcCommon(
97459744
func_inst,
97469745
cc_src,
97479746
is_noinline,
9748-
is_generic,
97499747
);
97509748
}
97519749

@@ -9762,7 +9760,6 @@ fn funcCommon(
97629760
func_inst,
97639761
cc_src,
97649762
is_noinline,
9765-
is_generic,
97669763
);
97679764
}
97689765

@@ -9779,14 +9776,11 @@ fn finishFunc(
97799776
func_inst: Zir.Inst.Index,
97809777
cc_src: LazySrcLoc,
97819778
is_noinline: bool,
9782-
is_generic: bool,
97839779
) CompileError!Air.Inst.Ref {
97849780
const pt = sema.pt;
97859781
const zcu = pt.zcu;
97869782
const ip = &zcu.intern_pool;
97879783
const gpa = sema.gpa;
9788-
const target = zcu.getTarget();
9789-
const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm);
97909784

97919785
const return_type: Type = if (opt_func_index == .none or ret_poison)
97929786
bare_return_type
@@ -9913,13 +9907,6 @@ fn finishFunc(
99139907
}),
99149908
}
99159909

9916-
if (backend == .stage2_llvm and !is_generic and sema.wantErrorReturnTracing(return_type)) {
9917-
// Make sure that StackTrace's fields are resolved so that the backend can
9918-
// lower this fn type.
9919-
const unresolved_stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
9920-
try unresolved_stack_trace_ty.resolveFields(pt);
9921-
}
9922-
99239910
return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty);
99249911
}
99259912

src/codegen/llvm.zig

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,11 +1754,6 @@ pub const Object = struct {
17541754
}
17551755
}
17561756

1757-
pub fn freeDecl(self: *Object, decl_index: InternPool.DeclIndex) void {
1758-
const global = self.decl_map.get(decl_index) orelse return;
1759-
global.delete(&self.builder);
1760-
}
1761-
17621757
fn getDebugFile(o: *Object, pt: Zcu.PerThread, file_index: Zcu.File.Index) Allocator.Error!Builder.Metadata {
17631758
const gpa = o.gpa;
17641759
const gop = try o.debug_file_map.getOrPut(gpa, file_index);
@@ -2596,9 +2591,8 @@ pub const Object = struct {
25962591
}
25972592

25982593
if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
2599-
const stack_trace_ty = zcu.builtin_decl_values.get(.StackTrace);
2600-
const ptr_ty = try pt.ptrType(.{ .child = stack_trace_ty });
2601-
debug_param_types.appendAssumeCapacity(try o.lowerDebugType(pt, ptr_ty));
2594+
// Stack trace pointer.
2595+
debug_param_types.appendAssumeCapacity(try o.lowerDebugType(pt, .fromInterned(.ptr_usize_type)));
26022596
}
26032597

26042598
for (0..fn_info.param_types.len) |i| {
@@ -12901,26 +12895,6 @@ fn compilerRtIntBits(bits: u16) u16 {
1290112895
return bits;
1290212896
}
1290312897

12904-
fn getStackTraceType(pt: Zcu.PerThread) Allocator.Error!Type {
12905-
const zcu = pt.zcu;
12906-
const ip = &zcu.intern_pool;
12907-
12908-
const std_file_index = zcu.module_roots.get(zcu.std_mod).?.unwrap().?;
12909-
const builtin_str = try ip.getOrPutString(zcu.gpa, pt.tid, "builtin", .no_embedded_nulls);
12910-
const std_file_root_type = Type.fromInterned(zcu.fileRootType(std_file_index));
12911-
const std_namespace = ip.namespacePtr(std_file_root_type.getNamespaceIndex(zcu));
12912-
const builtin_nav = std_namespace.pub_decls.getKeyAdapted(builtin_str, Zcu.Namespace.NameAdapter{ .zcu = zcu }).?;
12913-
12914-
const stack_trace_str = try ip.getOrPutString(zcu.gpa, pt.tid, "StackTrace", .no_embedded_nulls);
12915-
// buffer is only used for int_type, `builtin` is a struct.
12916-
const builtin_ty = zcu.navValue(builtin_nav).toType();
12917-
const builtin_namespace = zcu.namespacePtr(builtin_ty.getNamespaceIndex(zcu));
12918-
const stack_trace_nav = builtin_namespace.pub_decls.getKeyAdapted(stack_trace_str, Zcu.Namespace.NameAdapter{ .zcu = zcu }).?;
12919-
12920-
// Sema should have ensured that StackTrace was analyzed.
12921-
return zcu.navValue(stack_trace_nav).toType();
12922-
}
12923-
1292412898
fn buildAllocaInner(
1292512899
wip: *Builder.WipFunction,
1292612900
llvm_ty: Builder.Type,

src/link/Wasm.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,11 +3807,10 @@ pub fn flush(
38073807
tid: Zcu.PerThread.Id,
38083808
prog_node: std.Progress.Node,
38093809
) link.File.FlushError!void {
3810-
_ = tid;
3811-
38123810
// The goal is to never use this because it's only needed if we need to
38133811
// write to InternPool, but flush is too late to be writing to the
38143812
// InternPool.
3813+
_ = tid;
38153814
const comp = wasm.base.comp;
38163815
const diags = &comp.link_diags;
38173816
const gpa = comp.gpa;

0 commit comments

Comments
 (0)