From c99284103d4af9bb613cfee1d6c100beb75d2a4a Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 4 Aug 2025 15:51:49 +0200 Subject: [PATCH] Fix issue with naked functions #2365 --- src/compiler/llvm_codegen_function.c | 8 +++++--- test/test_suite/asm/naked.c3t | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index d20904a75..d54f19e22 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -495,10 +495,12 @@ void llvm_emit_body(GenContext *c, LLVMValueRef function, FunctionPrototype *pro // Generate LLVMValueRef's for all parameters, so we can use them as local vars in code - FOREACH_IDX(i, Decl *, param, signature->params) + if (!is_naked) { - if (!param->name && is_naked) continue; - llvm_emit_func_parameter(c, param, prototype->abi_args[i], &arg, i); + FOREACH_IDX(i, Decl *, param, signature->params) + { + llvm_emit_func_parameter(c, param, prototype->abi_args[i], &arg, i); + } } LLVMSetCurrentDebugLocation2(c->builder, NULL); diff --git a/test/test_suite/asm/naked.c3t b/test/test_suite/asm/naked.c3t index 913eeab89..1a42ca8a7 100644 --- a/test/test_suite/asm/naked.c3t +++ b/test/test_suite/asm/naked.c3t @@ -9,6 +9,9 @@ fn void start() @export("_start") @naked @nostrip { } } +fn void foo(char a) @naked @nostrip { } + + /* #expect: testing.ll define void @_start() #0 { @@ -17,3 +20,9 @@ entry: unreachable } +; Function Attrs: naked nounwind uwtable +define void @testing.foo(i8 zeroext %0) #0 { +entry: + unreachable +} +