authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-04-13 21:24:08+03:30
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-13 12:16:31-07:00
log041bcbd10943bf78e315466b429ae0acfb5cd97a
tree5d788b87754c109423145f6a9a3c0bca6e666f75
parente3b79d65d808700d6308996a52186dcb3ff48b06

Do not store StackTrace type


3 files changed, 7 insertions(+), 6 deletions(-)

src/Sema.zig+3-3
...@@ -9785,6 +9785,8 @@ fn finishFunc(...@@ -9785,6 +9785,8 @@ fn finishFunc(
9785 const zcu = pt.zcu;9785 const zcu = pt.zcu;
9786 const ip = &zcu.intern_pool;9786 const ip = &zcu.intern_pool;
9787 const gpa = sema.gpa;9787 const gpa = sema.gpa;
9788 const target = zcu.getTarget();
9789 const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm);
97889790
9789 const return_type: Type = if (opt_func_index == .none or ret_poison)9791 const return_type: Type = if (opt_func_index == .none or ret_poison)
9790 bare_return_type9792 bare_return_type
...@@ -9911,13 +9913,11 @@ fn finishFunc(...@@ -9911,13 +9913,11 @@ fn finishFunc(
9911 }),9913 }),
9912 }9914 }
99139915
9914 if (!is_generic and sema.wantErrorReturnTracing(return_type)) {9916 if (backend == .stage2_llvm and !is_generic and sema.wantErrorReturnTracing(return_type)) {
9915 // Make sure that StackTrace's fields are resolved so that the backend can9917 // Make sure that StackTrace's fields are resolved so that the backend can
9916 // lower this fn type.9918 // lower this fn type.
9917 const unresolved_stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);9919 const unresolved_stack_trace_ty = try sema.getBuiltinType(block.nodeOffset(.zero), .StackTrace);
9918 try unresolved_stack_trace_ty.resolveFields(pt);9920 try unresolved_stack_trace_ty.resolveFields(pt);
9919
9920 if (zcu.stack_trace_type == .none) zcu.stack_trace_type = unresolved_stack_trace_ty.toIntern();
9921 }9921 }
99229922
9923 return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty);9923 return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty);
src/Zcu.zig-1
...@@ -308,7 +308,6 @@ free_type_references: std.ArrayListUnmanaged(u32) = .empty,...@@ -308,7 +308,6 @@ free_type_references: std.ArrayListUnmanaged(u32) = .empty,
308308
309/// Populated by analysis of `AnalUnit.wrap(.{ .memoized_state = s })`, where `s` depends on the element.309/// Populated by analysis of `AnalUnit.wrap(.{ .memoized_state = s })`, where `s` depends on the element.
310builtin_decl_values: BuiltinDecl.Memoized = .initFill(.none),310builtin_decl_values: BuiltinDecl.Memoized = .initFill(.none),
311stack_trace_type: InternPool.Index = .none,
312311
313incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =312incremental_debug_state: if (build_options.enable_debug_extensions) IncrementalDebugState else void =
314 if (build_options.enable_debug_extensions) .init else {},313 if (build_options.enable_debug_extensions) .init else {},
src/codegen/llvm.zig+4-2
...@@ -2596,7 +2596,8 @@ pub const Object = struct {...@@ -2596,7 +2596,8 @@ pub const Object = struct {
2596 }2596 }
25972597
2598 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {2598 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
2599 const ptr_ty = try pt.ptrType(.{ .child = zcu.stack_trace_type });2599 const stack_trace_ty = zcu.builtin_decl_values.get(.StackTrace);
2600 const ptr_ty = try pt.ptrType(.{ .child = stack_trace_ty });
2600 debug_param_types.appendAssumeCapacity(try o.lowerDebugType(pt, ptr_ty));2601 debug_param_types.appendAssumeCapacity(try o.lowerDebugType(pt, ptr_ty));
2601 }2602 }
26022603
...@@ -3508,7 +3509,8 @@ pub const Object = struct {...@@ -3508,7 +3509,8 @@ pub const Object = struct {
3508 }3509 }
35093510
3510 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {3511 if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
3511 const ptr_ty = try pt.ptrType(.{ .child = zcu.stack_trace_type });3512 const stack_trace_ty = zcu.builtin_decl_values.get(.StackTrace);
3513 const ptr_ty = try pt.ptrType(.{ .child = stack_trace_ty });
3512 try llvm_params.append(o.gpa, try o.lowerType(pt, ptr_ty));3514 try llvm_params.append(o.gpa, try o.lowerType(pt, ptr_ty));
3513 }3515 }
35143516