aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-01-22 01:51:39 +0000
committerJacob Young <jacobly0@users.noreply.github.com>2025-01-22 02:22:56 -0500
commit1bce01de97f04984feea7e79ae0809d7b623cdd0 (patch)
tree35da62a30d630a34b97b3f46f4a64fede28b4b08 /src/codegen
parent941677e08318c2baaabc9d0fc87892d1b63487ae (diff)
downloadzig-1bce01de97f04984feea7e79ae0809d7b623cdd0.tar.gz
zig-1bce01de97f04984feea7e79ae0809d7b623cdd0.zip
compiler: pass error return traces everywhere
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 89595f0f5c..cf5f75b880 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -1497,8 +1497,7 @@ pub const Object = struct {
.unsigned => try attributes.addRetAttr(.zeroext, &o.builder),
};
- const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(zcu) and
- comp.config.any_error_tracing;
+ const err_return_tracing = fn_info.cc == .auto and comp.config.any_error_tracing;
const err_ret_trace: Builder.Value = if (err_return_tracing) param: {
const param = wip.arg(llvm_arg_i);
@@ -2805,9 +2804,7 @@ pub const Object = struct {
debug_param_types.appendAssumeCapacity(try o.lowerDebugType(Type.void));
}
- if (Type.fromInterned(fn_info.return_type).isError(zcu) and
- zcu.comp.config.any_error_tracing)
- {
+ if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType());
debug_param_types.appendAssumeCapacity(try o.lowerDebugType(ptr_ty));
}
@@ -2970,8 +2967,7 @@ pub const Object = struct {
llvm_arg_i += 1;
}
- const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(zcu) and
- zcu.comp.config.any_error_tracing;
+ const err_return_tracing = fn_info.cc == .auto and zcu.comp.config.any_error_tracing;
if (err_return_tracing) {
try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
@@ -3736,9 +3732,7 @@ pub const Object = struct {
try llvm_params.append(o.gpa, .ptr);
}
- if (Type.fromInterned(fn_info.return_type).isError(zcu) and
- zcu.comp.config.any_error_tracing)
- {
+ if (fn_info.cc == .auto and zcu.comp.config.any_error_tracing) {
const ptr_ty = try pt.singleMutPtrType(try o.getStackTraceType());
try llvm_params.append(o.gpa, try o.lowerType(ptr_ty));
}
@@ -5483,7 +5477,7 @@ pub const FuncGen = struct {
break :blk ret_ptr;
};
- const err_return_tracing = return_type.isError(zcu) and zcu.comp.config.any_error_tracing;
+ const err_return_tracing = fn_info.cc == .auto and zcu.comp.config.any_error_tracing;
if (err_return_tracing) {
assert(self.err_ret_trace != .none);
try llvm_args.append(self.err_ret_trace);
@@ -5762,6 +5756,8 @@ pub const FuncGen = struct {
const panic_nav = ip.getNav(panic_func.owner_nav);
const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?;
const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav);
+ const has_err_trace = zcu.comp.config.any_error_tracing and fn_info.cc == .auto;
+ if (has_err_trace) assert(fg.err_ret_trace != .none);
_ = try fg.wip.callIntrinsicAssumeCold();
_ = try fg.wip.call(
.normal,
@@ -5769,7 +5765,13 @@ pub const FuncGen = struct {
.none,
panic_global.typeOf(&o.builder),
panic_global.toValue(&o.builder),
- &.{
+ if (has_err_trace) &.{
+ fg.err_ret_trace,
+ msg_ptr.toValue(),
+ try o.builder.intValue(llvm_usize, msg_len),
+ try o.builder.nullValue(.ptr),
+ null_opt_addr_global.toValue(),
+ } else &.{
msg_ptr.toValue(),
try o.builder.intValue(llvm_usize, msg_len),
try o.builder.nullValue(.ptr),