OSDN Git Service

[MachineLICM] Hoist TOC-based address instructions
authorLei Huang <lei@ca.ibm.com>
Thu, 15 Jun 2017 18:29:59 +0000 (18:29 +0000)
committerLei Huang <lei@ca.ibm.com>
Thu, 15 Jun 2017 18:29:59 +0000 (18:29 +0000)
commitedd54f82b6a98b4f53c5e51cf7fc5c3cd575c6ea
treee44f1315cd6e2df3db52b5cb59f5b606f33e3183
parente4a39516a0bee40aaed1451866656a01810eceef
[MachineLICM] Hoist TOC-based address instructions

Add condition for MachineLICM to safely hoist instructions that utilize
non constant registers that are reserved.

On PPC, global variable access is done through the table of contents (TOC)
which is always in register X2.  The ABI reserves this register in any
functions that have calls or access global variables.

A call through a function pointer involves saving, changing and restoring
this register around the call and thus MachineLICM does not consider it to
be invariant. We can however guarantee the register is preserved across the
call and thus is invariant.

Differential Revision: https://reviews.llvm.org/D33562

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305490 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetRegisterInfo.h
lib/CodeGen/MachineLICM.cpp
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h
test/CodeGen/PowerPC/licm-tocReg.ll [new file with mode: 0644]