From 942b296c1adf7778e7476e8b7d1df4235cbb7af6 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 23 Jan 2026 09:11:49 -0500 Subject: [PATCH] no need to restore stack pointer if we're exiting --- hylo-lang/hyloc/src/riscv_asm_codegen.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"); } }, -- 2.43.0