[llvm-dev] Any way to disable the alignment of functions?
Rahman Lavaee Mashhadi via llvm-dev
llvm-dev at lists.llvm.org
Sun Dec 27 13:23:41 PST 2015
I am trying to test if disabling function (entry) alignment has any effect on performance. On my x86 machine, all functions seem to get aligned to 16-bytes.
I know that GCC provides a flag (-fno-align-functions) to disable function alignment. However, I could not find the similar flag for clang.
According to the following quote from LLVM doc, clang delegates the job to the target in case no attributes are specified for a function.
"An explicit alignment may be specified for a function. If not present, or if the alignment is set to zero, the alignment of the function is set by the target to whatever it feels convenient.”
So, as a first try, I dived into the “EmitAlignment” code in AsmPrinter.cpp and simply removed the function alignment part. Interestingly the compilation seems flawless at many cases (large programs) 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.
More information about the llvm-dev