[cfe-dev] naked attribute

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu May 2 14:06:27 PDT 2013


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