[cfe-dev] Function alignment

Todd Jackson quantum.skyline at gmail.com
Thu Dec 1 13:15:33 PST 2011


[apologies if this is sent to the wrong list]

I have come across a few cases on 32-bit x86 where the Clang emitted
functions that contain a RET instruction followed by 15 NOP
instructions.  I suspect that Clang is doing this to align the
beginning of each function to a 16-byte boundary, but I'm not
completely sure.  The functions are empty, so the code is correct.

I've searched through the code for Clang and LLVM and can't find the
code that controls this or the exact reason why.  I tried to pass
-falign-functions to the Clang driver, but didn't see it get passed to
the compiler proper.

As a result, I have some questions:
1) Is Clang or LLVM responsible for this?
1) Why is this alignment done?  Is it a GCC or ABI compatibility requirement?
2) Can it be controlled through -falign-functions?
3) Where can I find the code inside Clang or LLVM that controls this behaviour?

Thanks,

Todd Jackson



More information about the cfe-dev mailing list