[PATCH] D26290: Only consider local functions local for the purpose of NOP eliminate after calls on PPC64

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 10:46:42 PST 2016


hfinkel added a comment.

In https://reviews.llvm.org/D26290#590529, @joerg wrote:

> http://math-atlas.sourceforge.net/devel/assembly/PPC-elf64abi-1.7.pdf
>
> 3.5.11 Function Calls
>
> Programs use the 64-bit PowerPC bl instruction to make direct function calls. The bl instruction must be
>  followed by a nop instruction.
>
>  ---
>
> The definition we currently use for whether a call is interposable doesn't agree with the logic in GNU ld or GCC. While it doesn't matter for inlined functoins, a call must contain the nop as the target can be replaced.


Alright; I think we're confusing several issues here. This does not have anything to do with PIC vs. non-PIC code. Yes, the bl will require a following nop so that we can patch in the TOC-restore when required. This will be necessary for shared libraries and other multi-TOC configurations.

However, I think that we really need to understand why you're running into a problem here. The range of bl is the same as b, and so you don't gain any extra range by stub creation here. The only thing I've been able to think of is that you're using -ffunction-sections and the linker is re-arranging things so that the direct branch needs a stub, and the linker requires the nop patch for the stub. If I'm right, then I'm fine with doing this when using -ffunction-sections.


https://reviews.llvm.org/D26290





More information about the llvm-commits mailing list