Naked functions

kinke noone at nowhere.com
Fri Jul 27 20:17:12 UTC 2018


On Friday, 27 July 2018 at 19:34:49 UTC, Jack Applegame wrote:
> This code
>
>> import ldc.llvmasm;
>> @naked void foo() {
>>   __asm("mov lr, 0xfffffffd", "");
>> }
>
> Definitely should compile to
>
>> mvn.w   lr, #2
>
> But now it compiles to
>
>> mvn.w   lr, #2
>> bx      lr

'Now' (current/yesterday's PR), this crashes the compiler for the 
aforementioned reason. Interestingly, clang also goes through IR 
(see -emit-llvm and compare with LDC's -output-ll output) but 
appends an unreachable at the end, which gets rid of the error 
about non-terminated function. I've just implemented this, but 
the unreachable makes it to the final assembly, whereas it 
vanishes at some point for clang.


More information about the digitalmars-d-ldc mailing list