From: Bryan English Date: Fri, 23 Jan 2026 14:11:49 +0000 (-0500) Subject: no need to restore stack pointer if we're exiting X-Git-Url: https://rethought.computer/gitweb//gitweb//git?a=commitdiff_plain;h=942b296c1adf7778e7476e8b7d1df4235cbb7af6;p=sorel-lang.git no need to restore stack pointer if we're exiting --- diff --git a/hylo-lang/hyloc/src/riscv_asm_codegen.rs b/hylo-lang/hyloc/src/riscv_asm_codegen.rs index d90ca6b..3f0a96c 100644 --- a/hylo-lang/hyloc/src/riscv_asm_codegen.rs +++ b/hylo-lang/hyloc/src/riscv_asm_codegen.rs @@ -130,14 +130,14 @@ impl<'a> CodeGen<'a> { self.line(format!("call {}", name)); }, IR::Ret => { - self.line("lw ra, 8(sp)"); // load return address from stack - self.line("addi sp, sp, 16"); // restore stack pointer if last_label == "main" { // exit 0 syscall self.line("li a7, 93"); self.line("mv a0, x0"); self.line("ecall"); } else { + self.line("lw ra, 8(sp)"); // load return address from stack + self.line("addi sp, sp, 16"); // restore stack pointer self.line("ret"); } },