| author | |
| committer | |
| log | 1bce01de97f04984feea7e79ae0809d7b623cdd0 |
| tree | 35da62a30d630a34b97b3f46f4a64fede28b4b08 |
| parent | 941677e08318c2baaabc9d0fc87892d1b63487ae |
4 files changed, 44 insertions(+), 60 deletions(-)
src/InternPool.zig+7-18| ... | @@ -2294,17 +2294,6 @@ pub const Key = union(enum) { | ... | @@ -2294,17 +2294,6 @@ pub const Key = union(enum) { |
| 2294 | return @atomicLoad(FuncAnalysis, func.analysisPtr(ip), .unordered); | 2294 | return @atomicLoad(FuncAnalysis, func.analysisPtr(ip), .unordered); |
| 2295 | } | 2295 | } |
| 2296 | 2296 | ||
| 2297 | pub fn setCallsOrAwaitsErrorableFn(func: Func, ip: *InternPool, value: bool) void { | ||
| 2298 | const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex; | ||
| 2299 | extra_mutex.lock(); | ||
| 2300 | defer extra_mutex.unlock(); | ||
| 2301 | |||
| 2302 | const analysis_ptr = func.analysisPtr(ip); | ||
| 2303 | var analysis = analysis_ptr.*; | ||
| 2304 | analysis.calls_or_awaits_errorable_fn = value; | ||
| 2305 | @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release); | ||
| 2306 | } | ||
| 2307 | |||
| 2308 | pub fn setBranchHint(func: Func, ip: *InternPool, hint: std.builtin.BranchHint) void { | 2297 | pub fn setBranchHint(func: Func, ip: *InternPool, hint: std.builtin.BranchHint) void { |
| 2309 | const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex; | 2298 | const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex; |
| 2310 | extra_mutex.lock(); | 2299 | extra_mutex.lock(); |
| ... | @@ -5975,7 +5964,7 @@ pub const FuncAnalysis = packed struct(u32) { | ... | @@ -5975,7 +5964,7 @@ pub const FuncAnalysis = packed struct(u32) { |
| 5975 | is_analyzed: bool, | 5964 | is_analyzed: bool, |
| 5976 | branch_hint: std.builtin.BranchHint, | 5965 | branch_hint: std.builtin.BranchHint, |
| 5977 | is_noinline: bool, | 5966 | is_noinline: bool, |
| 5978 | calls_or_awaits_errorable_fn: bool, | 5967 | has_error_trace: bool, |
| 5979 | /// True if this function has an inferred error set. | 5968 | /// True if this function has an inferred error set. |
| 5980 | inferred_error_set: bool, | 5969 | inferred_error_set: bool, |
| 5981 | disable_instrumentation: bool, | 5970 | disable_instrumentation: bool, |
| ... | @@ -9007,7 +8996,7 @@ pub fn getFuncDecl( | ... | @@ -9007,7 +8996,7 @@ pub fn getFuncDecl( |
| 9007 | .is_analyzed = false, | 8996 | .is_analyzed = false, |
| 9008 | .branch_hint = .none, | 8997 | .branch_hint = .none, |
| 9009 | .is_noinline = key.is_noinline, | 8998 | .is_noinline = key.is_noinline, |
| 9010 | .calls_or_awaits_errorable_fn = false, | 8999 | .has_error_trace = false, |
| 9011 | .inferred_error_set = false, | 9000 | .inferred_error_set = false, |
| 9012 | .disable_instrumentation = false, | 9001 | .disable_instrumentation = false, |
| 9013 | }, | 9002 | }, |
| ... | @@ -9116,7 +9105,7 @@ pub fn getFuncDeclIes( | ... | @@ -9116,7 +9105,7 @@ pub fn getFuncDeclIes( |
| 9116 | .is_analyzed = false, | 9105 | .is_analyzed = false, |
| 9117 | .branch_hint = .none, | 9106 | .branch_hint = .none, |
| 9118 | .is_noinline = key.is_noinline, | 9107 | .is_noinline = key.is_noinline, |
| 9119 | .calls_or_awaits_errorable_fn = false, | 9108 | .has_error_trace = false, |
| 9120 | .inferred_error_set = true, | 9109 | .inferred_error_set = true, |
| 9121 | .disable_instrumentation = false, | 9110 | .disable_instrumentation = false, |
| 9122 | }, | 9111 | }, |
| ... | @@ -9312,7 +9301,7 @@ pub fn getFuncInstance( | ... | @@ -9312,7 +9301,7 @@ pub fn getFuncInstance( |
| 9312 | .is_analyzed = false, | 9301 | .is_analyzed = false, |
| 9313 | .branch_hint = .none, | 9302 | .branch_hint = .none, |
| 9314 | .is_noinline = arg.is_noinline, | 9303 | .is_noinline = arg.is_noinline, |
| 9315 | .calls_or_awaits_errorable_fn = false, | 9304 | .has_error_trace = false, |
| 9316 | .inferred_error_set = false, | 9305 | .inferred_error_set = false, |
| 9317 | .disable_instrumentation = false, | 9306 | .disable_instrumentation = false, |
| 9318 | }, | 9307 | }, |
| ... | @@ -9410,7 +9399,7 @@ pub fn getFuncInstanceIes( | ... | @@ -9410,7 +9399,7 @@ pub fn getFuncInstanceIes( |
| 9410 | .is_analyzed = false, | 9399 | .is_analyzed = false, |
| 9411 | .branch_hint = .none, | 9400 | .branch_hint = .none, |
| 9412 | .is_noinline = arg.is_noinline, | 9401 | .is_noinline = arg.is_noinline, |
| 9413 | .calls_or_awaits_errorable_fn = false, | 9402 | .has_error_trace = false, |
| 9414 | .inferred_error_set = true, | 9403 | .inferred_error_set = true, |
| 9415 | .disable_instrumentation = false, | 9404 | .disable_instrumentation = false, |
| 9416 | }, | 9405 | }, |
| ... | @@ -12174,7 +12163,7 @@ pub fn funcAnalysisUnordered(ip: *const InternPool, func: Index) FuncAnalysis { | ... | @@ -12174,7 +12163,7 @@ pub fn funcAnalysisUnordered(ip: *const InternPool, func: Index) FuncAnalysis { |
| 12174 | return @atomicLoad(FuncAnalysis, ip.funcAnalysisPtr(func), .unordered); | 12163 | return @atomicLoad(FuncAnalysis, ip.funcAnalysisPtr(func), .unordered); |
| 12175 | } | 12164 | } |
| 12176 | 12165 | ||
| 12177 | pub fn funcSetCallsOrAwaitsErrorableFn(ip: *InternPool, func: Index) void { | 12166 | pub fn funcSetHasErrorTrace(ip: *InternPool, func: Index, has_error_trace: bool) void { |
| 12178 | const unwrapped_func = func.unwrap(ip); | 12167 | const unwrapped_func = func.unwrap(ip); |
| 12179 | const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex; | 12168 | const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex; |
| 12180 | extra_mutex.lock(); | 12169 | extra_mutex.lock(); |
| ... | @@ -12182,7 +12171,7 @@ pub fn funcSetCallsOrAwaitsErrorableFn(ip: *InternPool, func: Index) void { | ... | @@ -12182,7 +12171,7 @@ pub fn funcSetCallsOrAwaitsErrorableFn(ip: *InternPool, func: Index) void { |
| 12182 | 12171 | ||
| 12183 | const analysis_ptr = ip.funcAnalysisPtr(func); | 12172 | const analysis_ptr = ip.funcAnalysisPtr(func); |
| 12184 | var analysis = analysis_ptr.*; | 12173 | var analysis = analysis_ptr.*; |
| 12185 | analysis.calls_or_awaits_errorable_fn = true; | 12174 | analysis.has_error_trace = has_error_trace; |
| 12186 | @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release); | 12175 | @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release); |
| 12187 | } | 12176 | } |
| 12188 | 12177 |
src/Sema.zig+19-24| ... | @@ -7191,14 +7191,6 @@ fn zirCall( | ... | @@ -7191,14 +7191,6 @@ fn zirCall( |
| 7191 | const call_dbg_node: Zir.Inst.Index = @enumFromInt(@intFromEnum(inst) - 1); | 7191 | const call_dbg_node: Zir.Inst.Index = @enumFromInt(@intFromEnum(inst) - 1); |
| 7192 | const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call); | 7192 | const call_inst = try sema.analyzeCall(block, func, func_ty, callee_src, call_src, modifier, ensure_result_used, args_info, call_dbg_node, .call); |
| 7193 | 7193 | ||
| 7194 | switch (sema.owner.unwrap()) { | ||
| 7195 | .@"comptime", .type, .memoized_state, .nav_ty, .nav_val => input_is_error = false, | ||
| 7196 | .func => |owner_func| if (!zcu.intern_pool.funcAnalysisUnordered(owner_func).calls_or_awaits_errorable_fn) { | ||
| 7197 | // No errorable fn actually called; we have no error return trace | ||
| 7198 | input_is_error = false; | ||
| 7199 | }, | ||
| 7200 | } | ||
| 7201 | |||
| 7202 | if (block.ownerModule().error_tracing and | 7194 | if (block.ownerModule().error_tracing and |
| 7203 | !block.isComptime() and !block.is_typeof and (input_is_error or pop_error_return_trace)) | 7195 | !block.isComptime() and !block.is_typeof and (input_is_error or pop_error_return_trace)) |
| 7204 | { | 7196 | { |
| ... | @@ -7865,6 +7857,12 @@ fn analyzeCall( | ... | @@ -7865,6 +7857,12 @@ fn analyzeCall( |
| 7865 | } | 7857 | } |
| 7866 | break :msg msg; | 7858 | break :msg msg; |
| 7867 | }); | 7859 | }); |
| 7860 | if (func_ty_info.cc == .auto) { | ||
| 7861 | switch (sema.owner.unwrap()) { | ||
| 7862 | .@"comptime", .nav_ty, .nav_val, .type, .memoized_state => {}, | ||
| 7863 | .func => |owner_func| ip.funcSetHasErrorTrace(owner_func, true), | ||
| 7864 | } | ||
| 7865 | } | ||
| 7868 | for (args, 0..) |arg, arg_idx| { | 7866 | for (args, 0..) |arg, arg_idx| { |
| 7869 | try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg); | 7867 | try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg); |
| 7870 | } | 7868 | } |
| ... | @@ -7939,13 +7937,6 @@ fn analyzeCall( | ... | @@ -7939,13 +7937,6 @@ fn analyzeCall( |
| 7939 | try zcu.ensureFuncBodyAnalysisQueued(runtime_func_val.toIntern()); | 7937 | try zcu.ensureFuncBodyAnalysisQueued(runtime_func_val.toIntern()); |
| 7940 | } | 7938 | } |
| 7941 | 7939 | ||
| 7942 | switch (sema.owner.unwrap()) { | ||
| 7943 | .@"comptime", .nav_ty, .nav_val, .type, .memoized_state => {}, | ||
| 7944 | .func => |owner_func| if (resolved_ret_ty.isError(zcu)) { | ||
| 7945 | ip.funcSetCallsOrAwaitsErrorableFn(owner_func); | ||
| 7946 | }, | ||
| 7947 | } | ||
| 7948 | |||
| 7949 | const call_tag: Air.Inst.Tag = switch (modifier) { | 7940 | const call_tag: Air.Inst.Tag = switch (modifier) { |
| 7950 | .auto, .no_async => .call, | 7941 | .auto, .no_async => .call, |
| 7951 | .never_tail => .call_never_tail, | 7942 | .never_tail => .call_never_tail, |
| ... | @@ -19699,16 +19690,16 @@ fn retWithErrTracing( | ... | @@ -19699,16 +19690,16 @@ fn retWithErrTracing( |
| 19699 | .bool_false => false, | 19690 | .bool_false => false, |
| 19700 | else => true, | 19691 | else => true, |
| 19701 | }; | 19692 | }; |
| 19693 | |||
| 19694 | // This means we're returning something that might be an error! | ||
| 19695 | // This should only be possible with the `auto` cc, so we definitely have an error trace. | ||
| 19696 | assert(pt.zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace); | ||
| 19697 | |||
| 19702 | const gpa = sema.gpa; | 19698 | const gpa = sema.gpa; |
| 19703 | const stack_trace_ty = try sema.getBuiltinType(src, .StackTrace); | ||
| 19704 | try stack_trace_ty.resolveFields(pt); | ||
| 19705 | const ptr_stack_trace_ty = try pt.singleMutPtrType(stack_trace_ty); | ||
| 19706 | const err_return_trace = try block.addTy(.err_return_trace, ptr_stack_trace_ty); | ||
| 19707 | const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError)); | 19699 | const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError)); |
| 19708 | const args: [1]Air.Inst.Ref = .{err_return_trace}; | ||
| 19709 | 19700 | ||
| 19710 | if (!need_check) { | 19701 | if (!need_check) { |
| 19711 | try sema.callBuiltin(block, src, return_err_fn, .never_inline, &args, .@"error return"); | 19702 | try sema.callBuiltin(block, src, return_err_fn, .never_inline, &.{}, .@"error return"); |
| 19712 | _ = try block.addUnOp(ret_tag, operand); | 19703 | _ = try block.addUnOp(ret_tag, operand); |
| 19713 | return; | 19704 | return; |
| 19714 | } | 19705 | } |
| ... | @@ -19719,7 +19710,7 @@ fn retWithErrTracing( | ... | @@ -19719,7 +19710,7 @@ fn retWithErrTracing( |
| 19719 | 19710 | ||
| 19720 | var else_block = block.makeSubBlock(); | 19711 | var else_block = block.makeSubBlock(); |
| 19721 | defer else_block.instructions.deinit(gpa); | 19712 | defer else_block.instructions.deinit(gpa); |
| 19722 | try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &args, .@"error return"); | 19713 | try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &.{}, .@"error return"); |
| 19723 | _ = try else_block.addUnOp(ret_tag, operand); | 19714 | _ = try else_block.addUnOp(ret_tag, operand); |
| 19724 | 19715 | ||
| 19725 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + | 19716 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len + |
| ... | @@ -19830,7 +19821,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_ | ... | @@ -19830,7 +19821,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_ |
| 19830 | return; | 19821 | return; |
| 19831 | } | 19822 | } |
| 19832 | 19823 | ||
| 19833 | if (!zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).calls_or_awaits_errorable_fn) return; | 19824 | if (!zcu.intern_pool.funcAnalysisUnordered(sema.owner.unwrap().func).has_error_trace) return; |
| 19834 | if (!start_block.ownerModule().error_tracing) return; | 19825 | if (!start_block.ownerModule().error_tracing) return; |
| 19835 | 19826 | ||
| 19836 | assert(saved_index != .none); // The .error_return_trace_index field was dropped somewhere | 19827 | assert(saved_index != .none); // The .error_return_trace_index field was dropped somewhere |
| ... | @@ -21116,7 +21107,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -21116,7 +21107,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 21116 | const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern()); | 21107 | const opt_ptr_stack_trace_ty = try pt.optionalType(ptr_stack_trace_ty.toIntern()); |
| 21117 | 21108 | ||
| 21118 | switch (sema.owner.unwrap()) { | 21109 | switch (sema.owner.unwrap()) { |
| 21119 | .func => |func| if (ip.funcAnalysisUnordered(func).calls_or_awaits_errorable_fn and block.ownerModule().error_tracing) { | 21110 | .func => |func| if (ip.funcAnalysisUnordered(func).has_error_trace and block.ownerModule().error_tracing) { |
| 21120 | return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty); | 21111 | return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty); |
| 21121 | }, | 21112 | }, |
| 21122 | .@"comptime", .nav_ty, .nav_val, .type, .memoized_state => {}, | 21113 | .@"comptime", .nav_ty, .nav_val, .type, .memoized_state => {}, |
| ... | @@ -27089,6 +27080,10 @@ fn preparePanicId(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.PanicId) !InternPo | ... | @@ -27089,6 +27080,10 @@ fn preparePanicId(sema: *Sema, src: LazySrcLoc, panic_id: Zcu.PanicId) !InternPo |
| 27089 | const zcu = sema.pt.zcu; | 27080 | const zcu = sema.pt.zcu; |
| 27090 | try sema.ensureMemoizedStateResolved(src, .panic); | 27081 | try sema.ensureMemoizedStateResolved(src, .panic); |
| 27091 | try zcu.ensureFuncBodyAnalysisQueued(zcu.builtin_decl_values.get(.@"Panic.call")); | 27082 | try zcu.ensureFuncBodyAnalysisQueued(zcu.builtin_decl_values.get(.@"Panic.call")); |
| 27083 | switch (sema.owner.unwrap()) { | ||
| 27084 | .@"comptime", .nav_ty, .nav_val, .type, .memoized_state => {}, | ||
| 27085 | .func => |owner_func| zcu.intern_pool.funcSetHasErrorTrace(owner_func, true), | ||
| 27086 | } | ||
| 27092 | return zcu.builtin_decl_values.get(panic_id.toBuiltin()); | 27087 | return zcu.builtin_decl_values.get(panic_id.toBuiltin()); |
| 27093 | } | 27088 | } |
| 27094 | 27089 |
src/Zcu/PerThread.zig+4-6| ... | @@ -2596,7 +2596,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE | ... | @@ -2596,7 +2596,7 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE |
| 2596 | } | 2596 | } |
| 2597 | 2597 | ||
| 2598 | // reset in case calls to errorable functions are removed. | 2598 | // reset in case calls to errorable functions are removed. |
| 2599 | func.setCallsOrAwaitsErrorableFn(ip, false); | 2599 | ip.funcSetHasErrorTrace(func_index, fn_ty_info.cc == .auto); |
| 2600 | 2600 | ||
| 2601 | // First few indexes of extra are reserved and set at the end. | 2601 | // First few indexes of extra are reserved and set at the end. |
| 2602 | const reserved_count = @typeInfo(Air.ExtraIndex).@"enum".fields.len; | 2602 | const reserved_count = @typeInfo(Air.ExtraIndex).@"enum".fields.len; |
| ... | @@ -2707,11 +2707,9 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE | ... | @@ -2707,11 +2707,9 @@ fn analyzeFnBodyInner(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaE |
| 2707 | 2707 | ||
| 2708 | func.setBranchHint(ip, sema.branch_hint orelse .none); | 2708 | func.setBranchHint(ip, sema.branch_hint orelse .none); |
| 2709 | 2709 | ||
| 2710 | // If we don't get an error return trace from a caller, create our own. | 2710 | if (zcu.comp.config.any_error_tracing and func.analysisUnordered(ip).has_error_trace and fn_ty_info.cc != .auto) { |
| 2711 | if (func.analysisUnordered(ip).calls_or_awaits_errorable_fn and | 2711 | // We're using an error trace, but didn't start out with one from the caller. |
| 2712 | zcu.comp.config.any_error_tracing and | 2712 | // We'll have to create it at the start of the function. |
| 2713 | !sema.fn_ret_ty.isError(zcu)) | ||
| 2714 | { | ||
| 2715 | sema.setupErrorReturnTrace(&inner_block, last_arg_index) catch |err| switch (err) { | 2713 | sema.setupErrorReturnTrace(&inner_block, last_arg_index) catch |err| switch (err) { |
| 2716 | error.ComptimeReturn => unreachable, | 2714 | error.ComptimeReturn => unreachable, |
| 2717 | error.ComptimeBreak => unreachable, | 2715 | error.ComptimeBreak => unreachable, |
src/codegen/llvm.zig+14-12| ... | @@ -1497,8 +1497,7 @@ pub const Object = struct { | ... | @@ -1497,8 +1497,7 @@ pub const Object = struct { |
| 1497 | .unsigned => try attributes.addRetAttr(.zeroext, &o.builder), | 1497 | .unsigned => try attributes.addRetAttr(.zeroext, &o.builder), |
| 1498 | }; | 1498 | }; |
| 1499 | 1499 | ||
| 1500 | const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(zcu) and | 1500 | const err_return_tracing = fn_info.cc == .auto and comp.config.any_error_tracing; |
| 1501 | comp.config.any_error_tracing; | ||
| 1502 | 1501 | ||
| 1503 | const err_ret_trace: Builder.Value = if (err_return_tracing) param: { | 1502 | const err_ret_trace: Builder.Value = if (err_return_tracing) param: { |
| 1504 | const param = wip.arg(llvm_arg_i); | 1503 | const param = wip.arg(llvm_arg_i); |
| ... | @@ -2805,9 +2804,7 @@ pub const Object = struct { | ... | @@ -2805,9 +2804,7 @@ pub const Object = struct { |
| 2805 | debug_param_types.appendAssumeCapacity(try o.lowerDebugType(Type.void)); | 2804 | debug_param_types.appendAssumeCapacity(try o.lowerDebugType(Type.void)); |
| 2806 | } | 2805 | } |
| 2807 | 2806 | ||
| 2808 | if (Type.fromInterned(fn_info.return_type).isError(zcu) and | 2807 | if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) { |
| 2809 | zcu.comp.config.any_error_tracing) | ||
| 2810 | { | ||
| 2811 | const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType()); | 2808 | const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType()); |
| 2812 | debug_param_types.appendAssumeCapacity(try o.lowerDebugType(ptr_ty)); | 2809 | debug_param_types.appendAssumeCapacity(try o.lowerDebugType(ptr_ty)); |
| 2813 | } | 2810 | } |
| ... | @@ -2970,8 +2967,7 @@ pub const Object = struct { | ... | @@ -2970,8 +2967,7 @@ pub const Object = struct { |
| 2970 | llvm_arg_i += 1; | 2967 | llvm_arg_i += 1; |
| 2971 | } | 2968 | } |
| 2972 | 2969 | ||
| 2973 | const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(zcu) and | 2970 | const err_return_tracing = fn_info.cc == .auto and zcu.comp.config.any_error_tracing; |
| 2974 | zcu.comp.config.any_error_tracing; | ||
| 2975 | 2971 | ||
| 2976 | if (err_return_tracing) { | 2972 | if (err_return_tracing) { |
| 2977 | try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder); | 2973 | try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder); |
| ... | @@ -3736,9 +3732,7 @@ pub const Object = struct { | ... | @@ -3736,9 +3732,7 @@ pub const Object = struct { |
| 3736 | try llvm_params.append(o.gpa, .ptr); | 3732 | try llvm_params.append(o.gpa, .ptr); |
| 3737 | } | 3733 | } |
| 3738 | 3734 | ||
| 3739 | if (Type.fromInterned(fn_info.return_type).isError(zcu) and | 3735 | if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) { |
| 3740 | zcu.comp.config.any_error_tracing) | ||
| 3741 | { | ||
| 3742 | const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType()); | 3736 | const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType()); |
| 3743 | try llvm_params.append(o.gpa, try o.lowerType(ptr_ty)); | 3737 | try llvm_params.append(o.gpa, try o.lowerType(ptr_ty)); |
| 3744 | } | 3738 | } |
| ... | @@ -5483,7 +5477,7 @@ pub const FuncGen = struct { | ... | @@ -5483,7 +5477,7 @@ pub const FuncGen = struct { |
| 5483 | break :blk ret_ptr; | 5477 | break :blk ret_ptr; |
| 5484 | }; | 5478 | }; |
| 5485 | 5479 | ||
| 5486 | const err_return_tracing = return_type.isError(zcu) and zcu.comp.config.any_error_tracing; | 5480 | const err_return_tracing = fn_info.cc == .auto and zcu.comp.config.any_error_tracing; |
| 5487 | if (err_return_tracing) { | 5481 | if (err_return_tracing) { |
| 5488 | assert(self.err_ret_trace != .none); | 5482 | assert(self.err_ret_trace != .none); |
| 5489 | try llvm_args.append(self.err_ret_trace); | 5483 | try llvm_args.append(self.err_ret_trace); |
| ... | @@ -5762,6 +5756,8 @@ pub const FuncGen = struct { | ... | @@ -5762,6 +5756,8 @@ pub const FuncGen = struct { |
| 5762 | const panic_nav = ip.getNav(panic_func.owner_nav); | 5756 | const panic_nav = ip.getNav(panic_func.owner_nav); |
| 5763 | const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?; | 5757 | const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?; |
| 5764 | const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav); | 5758 | const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav); |
| 5759 | const has_err_trace = zcu.comp.config.any_error_tracing and fn_info.cc == .auto; | ||
| 5760 | if (has_err_trace) assert(fg.err_ret_trace != .none); | ||
| 5765 | _ = try fg.wip.callIntrinsicAssumeCold(); | 5761 | _ = try fg.wip.callIntrinsicAssumeCold(); |
| 5766 | _ = try fg.wip.call( | 5762 | _ = try fg.wip.call( |
| 5767 | .normal, | 5763 | .normal, |
| ... | @@ -5769,7 +5765,13 @@ pub const FuncGen = struct { | ... | @@ -5769,7 +5765,13 @@ pub const FuncGen = struct { |
| 5769 | .none, | 5765 | .none, |
| 5770 | panic_global.typeOf(&o.builder), | 5766 | panic_global.typeOf(&o.builder), |
| 5771 | panic_global.toValue(&o.builder), | 5767 | panic_global.toValue(&o.builder), |
| 5772 | &.{ | 5768 | if (has_err_trace) &.{ |
| 5769 | fg.err_ret_trace, | ||
| 5770 | msg_ptr.toValue(), | ||
| 5771 | try o.builder.intValue(llvm_usize, msg_len), | ||
| 5772 | try o.builder.nullValue(.ptr), | ||
| 5773 | null_opt_addr_global.toValue(), | ||
| 5774 | } else &.{ | ||
| 5773 | msg_ptr.toValue(), | 5775 | msg_ptr.toValue(), |
| 5774 | try o.builder.intValue(llvm_usize, msg_len), | 5776 | try o.builder.intValue(llvm_usize, msg_len), |
| 5775 | try o.builder.nullValue(.ptr), | 5777 | try o.builder.nullValue(.ptr), |