[PATCH] Disable x86 tail call optimization under PIC mode
chh at google.com
Tue May 26 13:53:04 PDT 2015
I read the new discussions in https://llvm.org/bugs/show_bug.cgi?id=15086.
- If it is not considered an optimization bug, we need to change semantics of dlopen() with RTLD_LAZY.
- A fix to have both tail call optimization and RTLD_LAZY seems infeasible, to setup %ebx before and restore %ebx after the call.
- Both X.org and Android hit this problem. I have spent weeks to trace down this problem in Android and hence my motivation to change llvm and save future debug time.
- This problem has been worked around with a global -fno-optimize-sibling-calls flag. So it is not urgent to have a fix. But that flag also disables other valid cases such as non-PIC mode.
In my new diff3, I keep current isMustTail feature and disable isTailCall only under PIC mode.
That should not lose performance compared with gcc.
If we want to keep this optimization selectable under PIC mode,
then we need a new flag and the question is whether the optimization is on or off
under PIC mode by default. Considering the difficulty of debugging this problem
and current competition from gcc, I would rather the default to be off.
More information about the llvm-commits