[llvm-dev] Any way to disable the alignment of functions?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 28 04:02:13 PST 2015


On 28 Dec 2015, at 00:24, mats petersson via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> On 27 December 2015 at 21:23, Rahman Lavaee Mashhadi via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>  but on a few programs, it produces a segfault-generating executable. So my guess is that for some functions, alignment is necessary for soundness, not just performance.
> 
> 
> That seems rather odd. On x86, I'm not aware of any instruction sequence that REQUIRES alignment of the instruction itself.

I would definitely expect it to break most C++ programs, because the C++ ABI uses the low bit to distinguish between function pointers and pointers to members.  Other code may also assume that functions start on an n>1 byte boundary and reuse the low bits for other things.  If a valid function pointer has its low bit set, then you may end up masking it off in some other code and then jumping to one byte into the first instruction.  This being x86, that may still be a valid instruction sequence, but it’s almost certainly not a sensible one.

David



More information about the llvm-dev mailing list