Do not store StackTrace type

This commit is contained in:
Ali Cheraghi 2025-04-13 21:24:08 +03:30 committed by Andrew Kelley
parent e3b79d65d8
commit 041bcbd109
3 changed files with 7 additions and 6 deletions

View File

@ -9785,6 +9785,8 @@ fn finishFunc(
const zcu = pt.zcu;
const ip = &zcu.intern_pool;
const gpa = sema.gpa;
const target = zcu.getTarget();
const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm);
const return_type: Type = if (opt_func_index == .none or ret_poison)
bare_return_type
@ -9911,13 +9913,11 @@ fn finishFunc(
}),
}
if (!is_generic and sema.wantErrorReturnTracing(return_type)) {
if (backend == .stage2_llvm and !is_generic and sema.wantErrorReturnTracing(return_type)) {
// Make sure that StackTrace's fields are resolved so that the backend can
// lower this fn type.
const unresolved_stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
try unresolved_stack_trace_ty.resolveFields(pt);
if (zcu.stack_trace_type == .none) zcu.stack_trace_type = unresolved_stack_trace_ty.toIntern();
}
return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty);

View File

@ -308,7 +308,6 @@ free_type_references: std.ArrayListUnmanaged(u32) = .empty,
/// Populated by analysis of `AnalUnit.wrap(.{ .memoized_state = s })`, where `s` depends on the element.
builtin_decl_values: BuiltinDecl.Memoized = .initFill(.none),
stack_trace_type: InternPool.Index = .none,
incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =
if (build_options.enable_debug_extensions) .init else {},

View File

@ -2596,7 +2596,8 @@ pub const Object = struct {
}
if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
const ptr_ty = try pt.ptrType(.{ .child = zcu.stack_trace_type });
const stack_trace_ty = zcu.builtin_decl_values.get(.StackTrace);
const ptr_ty = try pt.ptrType(.{ .child = stack_trace_ty });
debug_param_types.appendAssumeCapacity(try o.lowerDebugType(pt, ptr_ty));
}
@ -3508,7 +3509,8 @@ pub const Object = struct {
}
if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
const ptr_ty = try pt.ptrType(.{ .child = zcu.stack_trace_type });
const stack_trace_ty = zcu.builtin_decl_values.get(.StackTrace);
const ptr_ty = try pt.ptrType(.{ .child = stack_trace_ty });
try llvm_params.append(o.gpa, try o.lowerType(pt, ptr_ty));
}