[Bug target/50242] __attribute__((naked)) is not implemented on IA32 (x86)

congruwer at yahoo dot co.uk gcc-bugzilla@gcc.gnu.org
Wed Aug 31 16:11:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50242

--- Comment #2 from congruwer at yahoo dot co.uk 2011-08-31 15:46:19 UTC ---
Sometimes I want to implement an entire method or function in assembler. The
main reasons are:
1) I want to thunk to another function &c. in a way that is hard to do from
C++.
2) The compiler generated horrible code, because of an optimization bug for
example.
3) I need to execute a some specific opcodes.
For loose functions you can sometimes get away with using a definition in a
separate assembler module (although getting the name mangling right is a pain)
but for methods this is often impossible since C++ doesn't see the assembler
definition of the method (or constructor &c.) and that can cause problems.

The most recent problem that made me want this was a badly optimised destructor
that pulled in a lot of dependencies via the destructor prologue. I really want
the destructor in question to be inlined (since it's essentially empty) but
that doesn't work when the destructor is defined in a separate file. Trying to
use asm() won't work since the problem is in the prologue and the compiler
ignores the naked attribute. For now I've deleted it, but that is a cause of
potential bugs since a non-existent destructor doesn't have the protected:
visibility specifier.



More information about the Gcc-bugs mailing list