mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Allow accessing parameters in a naked function, just disallow return, this fixes #1955.
This commit is contained in:
28
test/test_suite/asm/naked_call_with_instructions.c3t
Normal file
28
test/test_suite/asm/naked_call_with_instructions.c3t
Normal file
@@ -0,0 +1,28 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
import std;
|
||||
fn void main()
|
||||
{
|
||||
char[8] foo = {255, 0, 0, 0, 0, 0, 0, 0};
|
||||
io::printn(to_ulong(&foo));
|
||||
}
|
||||
|
||||
fn ulong to_ulong(char[8]* buf) @naked @noinline
|
||||
{
|
||||
asm
|
||||
{
|
||||
movq $rax, [buf];
|
||||
ret;
|
||||
}
|
||||
unreachable();
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
define i64 @test.to_ulong(ptr %0) #1 {
|
||||
entry:
|
||||
call void asm sideeffect alignstack "movq ($0), %rax\0Aret \0A", "r,~{rax},~{flags},~{dirflag},~{fspr}"(ptr %0)
|
||||
unreachable
|
||||
}
|
||||
|
||||
attributes #1 = { naked noinline nounwind uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
@@ -3,14 +3,15 @@ module test;
|
||||
|
||||
alias IntFn = fn int();
|
||||
IntFn lambda @export = fn () => 1;
|
||||
IntFn lambda_naked @export = fn () @naked => 2;
|
||||
IntFn lambda_naked @export = fn () @naked { asm("ret"); };
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
; Function Attrs: naked nounwind uwtable
|
||||
define internal i32 @"test.$global$lambda2"() #0 {
|
||||
entry:
|
||||
ret i32 2
|
||||
call void asm sideeffect alignstack "ret", "~{dirflag},~{fpsr},~{flags}"()
|
||||
unreachable
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
|
||||
Reference in New Issue
Block a user