[cfe-dev] naked attribute

reed kotler rkotler at mips.com
Thu May 2 15:16:24 PDT 2013


When I use the latest code sourcery/Menor release of the ARM compiler I 
get no return statement. This claims to be 4.6.3

~/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc 
tnaked.c  -S

void tnaked() __attribute__((naked));

void tnaked() {
}


tnaked:
     .fnstart
     @ Naked Function: prologue and epilogue provided by programmer.
     @ args = 0, pretend = 0, frame = 0
     @ frame_needed = 1, uses_anonymous_args = 0
     .fnend
     .size    tnaked, .-tnaked
     .align    2
     .global    tnonaked
     .type    tnonaked, %function


On 05/02/2013 02:06 PM, Rafael EspĂ­ndola wrote:
> This is a gcc extension so I am more comfortable doing what gcc does
> when possible. gcc documents this extension as only being supported on
> ARM, AVR, MCORE, RX and SPU, so users clearly depend on undocumented
> behavior.
>
> Now,  given
>
> __attribute__((naked)) void f(void) {
> }
>
> gcc (both 4.7 and 4.9) produce
>
> f:
> .cfi_startproc
> ret
> .cfi_endproc
>
> Clang currently produces the IL
>
> define void @f() #0 {
> entry:
>    ret void
> }
>
> (where #0 includes naked) and we then codegen it to
>
> f:
> .cfi_startproc
> ret
> .cfi_endproc
>
> matching gcc. If we change the 'ret void' to 'unreachable', we codegen the IL to
>
> f:
> .cfi_startproc
> .cfi_endproc
>
> So I think we should keep the 'ret void'
>
> Cheers,
> Rafael





More information about the cfe-dev mailing list