[PowerPC] Ensure that the TOC reload directly follows bctrl on PPC64
authorHal Finkel <hfinkel@anl.gov>
Tue, 23 Dec 2014 22:29:40 +0000 (22:29 +0000)
committerHal Finkel <hfinkel@anl.gov>
Tue, 23 Dec 2014 22:29:40 +0000 (22:29 +0000)
commitfc096c98f389b3d8813e72e1ea3c38d1a2e567d4
tree1829cc1ba53e7cbbbedb293b9e29fbf91da3851a
parent947cd7041391db25bf9185ec65f60226405ed54f
[PowerPC] Ensure that the TOC reload directly follows bctrl on PPC64

On non-Darwin PPC64, the TOC reload needs to come directly after the bctrl
instruction (for indirect calls) because the 'bctrl/ld 2, 40(1)' instruction
sequence is interpreted by the unwinding code in libgcc. To make sure these
occur as a pair, as with other pairings interpreted by the linker, fuse the two
instructions into one instruction (for code generation only).

In the future, we might wish to do this by emitting CFI directives instead,
but this solution is simpler, and mirrors what GCC does. Additional discussion
on this point is contained in the PR.

Fixes PR22015.

llvm-svn: 224788
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
llvm/lib/Target/PowerPC/PPCInstrFormats.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/test/CodeGen/PowerPC/ppc64-calls.ll