summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-11 00:44:19 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-11 00:44:19 +0000
commitfd338e97774b4017003e3a22dff2c3a7818702e1 (patch)
tree2bbcc2b2c0c8fbc19378c650ac8beb009ea429b0
parent17402e3d5ac35d24b42fa58d8efb17fe2c410146 (diff)
downloadbcm5719-llvm-fd338e97774b4017003e3a22dff2c3a7818702e1.tar.gz
bcm5719-llvm-fd338e97774b4017003e3a22dff2c3a7818702e1.zip
Allow Post-RA LICM to hoist reserved register reads.
When using register masks, registers like %rip are clobbered by the register mask. LICM should still be able to hoist instructions reading %rip from a loop containing calls. llvm-svn: 150288
-rw-r--r--llvm/lib/CodeGen/MachineLICM.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index fda60563ed4..47eb685db3c 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -68,6 +68,7 @@ namespace {
MachineRegisterInfo *MRI;
const InstrItineraryData *InstrItins;
bool PreRegAlloc;
+ BitVector ReservedRegs;
// Various analyses that we use...
AliasAnalysis *AA; // Alias analysis info.
@@ -337,6 +338,8 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) {
for (TargetRegisterInfo::regclass_iterator I = TRI->regclass_begin(),
E = TRI->regclass_end(); I != E; ++I)
RegLimit[(*I)->getID()] = TRI->getRegPressureLimit(*I, MF);
+ } else {
+ ReservedRegs = TRI->getReservedRegs(MF);
}
// Get our Loop information...
@@ -426,6 +429,9 @@ void MachineLICM::ProcessMI(MachineInstr *MI,
"Not expecting virtual register!");
if (!MO.isDef()) {
+ // Allow reserved register reads to be hoisted.
+ if (ReservedRegs.test(Reg))
+ continue;
if (Reg && (PhysRegDefs.test(Reg) || PhysRegClobbers.test(Reg)))
// If it's using a non-loop-invariant register, then it's obviously not
// safe to hoist.
@@ -531,6 +537,11 @@ void MachineLICM::HoistRegionPostRA() {
const MachineOperand &MO = MI->getOperand(j);
if (!MO.isReg() || MO.isDef() || !MO.getReg())
continue;
+ // Allow hoisting of reserved register reads that aren't call preserved.
+ // For example %rip.
+ // IsLoopInvariantInst() already checks MRI->isConstantPhysReg().
+ if (ReservedRegs.test(MO.getReg()))
+ continue;
if (PhysRegDefs.test(MO.getReg()) ||
PhysRegClobbers.test(MO.getReg())) {
// If it's using a non-loop-invariant register, then it's obviously
OpenPOWER on IntegriCloud