Skip to content

Commit

Permalink
llvm: Don't emit extra debug instructions for dbg_var_val in naked …
Browse files Browse the repository at this point in the history
…functions.
  • Loading branch information
alexrp committed Aug 15, 2024
1 parent acad2fa commit 7a8e86e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6743,7 +6743,10 @@ pub const FuncGen = struct {
},
"",
);
} else if (owner_mod.optimize_mode == .Debug) {
} else if (owner_mod.optimize_mode == .Debug and !self.is_naked) {
// We avoid taking this path for naked functions because there's no guarantee that such
// functions even have a valid stack pointer, making the `alloca` + `store` unsafe.

const alignment = operand_ty.abiAlignment(pt).toLlvm();
const alloca = try self.buildAlloca(operand.typeOfWip(&self.wip), alignment);
_ = try self.wip.store(.normal, operand, alloca, alignment);
Expand Down

0 comments on commit 7a8e86e

Please sign in to comment.