Skip to content

Commit c37f00e

Browse files
committed
llvm: Don't emit extra debug instructions for dbg_var_val in naked functions.
1 parent f1eed6a commit c37f00e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/codegen/llvm.zig

+4-1
Original file line numberDiff line numberDiff line change
@@ -6743,7 +6743,10 @@ pub const FuncGen = struct {
67436743
},
67446744
"",
67456745
);
6746-
} else if (owner_mod.optimize_mode == .Debug) {
6746+
} else if (owner_mod.optimize_mode == .Debug and !self.is_naked) {
6747+
// We avoid taking this path for naked functions because there's no guarantee that such
6748+
// functions even have a valid stack pointer, making the `alloca` + `store` unsafe.
6749+
67476750
const alignment = operand_ty.abiAlignment(pt).toLlvm();
67486751
const alloca = try self.buildAlloca(operand.typeOfWip(&self.wip), alignment);
67496752
_ = try self.wip.store(.normal, operand, alloca, alignment);

0 commit comments

Comments
 (0)