[PowerPC] Make r2 allocatable on PPC64/ELF for some leaf functions
authorHal Finkel <hfinkel@anl.gov>
Sun, 1 Feb 2015 15:03:28 +0000 (15:03 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 1 Feb 2015 15:03:28 +0000 (15:03 +0000)
commit8f5c829c1eb1188f5c084737f37cce9743ad7246
tree10e55137f08abcdbcf0dfb962fe250b8d018d0e8
parent8931c49efade57afb73e0d6f51e739a8ea4b896e
[PowerPC] Make r2 allocatable on PPC64/ELF for some leaf functions

The TOC base pointer is passed in r2, and we normally reserve this register so
that we can depend on it being there. However, for leaf functions, and
specifically those leaf functions that don't do any TOC access of their own
(which is generally due to accessing the constant pool, using TLS, etc.),
we can treat r2 as an ordinary callee-saved register (it must be callee-saved
because, for local direct calls, the linker will not insert any save/restore
code).

The allocation order has been changed slightly for PPC64/ELF systems to put r2
at the end of the list (while leaving it near the beginning for Darwin systems
to prevent unnecessary output changes). While r2 is allocatable, using it still
requires spill/restore traffic, and thus comes at the end of the list.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227745 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCCallingConv.td
lib/Target/PowerPC/PPCFastISel.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCMachineFunctionInfo.h
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.td
test/CodeGen/PowerPC/named-reg-alloc-r2-64.ll
test/CodeGen/PowerPC/named-reg-alloc-r2.ll
test/CodeGen/PowerPC/ppc64-r2-alloc.ll [new file with mode: 0644]