[cfe-dev] naked attribute
rkotler at mips.com
Thu May 2 19:11:01 PDT 2013
On 05/02/2013 02:08 PM, Tim Northover wrote:
> Hi Reed,
>> I propose to make the following change to clang.
>> In the presence of the "naked" attribute, in cases where clang would
>> normally implicitly emit a "return" instruction, it should emit an
>> "unreachable" instruction.
> I'd have loved to if we were designing the attribute from scratch; I
> think the semantics would definitely be better. Unfortunately GCC got
> there first, and at least on AArch64 it also puts the implicit return
> in. I'll check AArch32 at work tomorrow.
> If so, there's a real risk of breaking compatibility if anyone
> actually uses naked functions already. Not a fatal barrier, but one we
> should consider carefully.
Are you sure that AArch64 supports the naked attribute?
It's not on the official list of targets that support it in the gcc manual.
I think we are confusing things.
If you make a simple test case with a function that has nothing in it,
you will likely see just a return instruction.
I've posted a question on the gcc developers list regarding the intent
of naked functions but it makes no logical sense to me to emit a return
instruction in a naked function.
You can emit the instruction yourself along with the inline asm code for
the rest of your function.
gcc/llvm does not even know what flavor of return to emit.
More information about the cfe-dev