ldc
ldc copied to clipboard
Naked functions can't access to their parameters
import ldc.attributes;
import ldc.llvmasm;
void test(void* del) @naked {
__asm("jmp *$0", "{rax}", del);
}
This causes LDC to output a stacktrace without writing any readable error.
The prologue is skipped for naked functions, so params can only be accessed via underlying register/stack slot. E.g., for Posix x86_64:
void test(void* del) @naked {
asm { "jmp *%%rdi"; }
}
I was curious seeing this scroll by – it only fails in SelectionDAG when optimisations are enabled; at -O0, LLVM seems happy enough to emit machine code for this. Please include the exact output and compiler version/flags when filing issues!
Seems like we should disallow parameter access in @naked
functions in the frontend layer.