aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2007-12-18 21:38:04 +0000
committerBill Wendling <isanbard@gmail.com>2007-12-18 21:38:04 +0000
commit280f4565eb599ce424c204b9ea07130d772af7e3 (patch)
tree91807c5f7247f0cae6efc850d40f265087baf727 /lib
parent7a0678cae6c549a1e11ac0767e04c273c298c0b7 (diff)
downloadexternal_llvm-280f4565eb599ce424c204b9ea07130d772af7e3.zip
external_llvm-280f4565eb599ce424c204b9ea07130d772af7e3.tar.gz
external_llvm-280f4565eb599ce424c204b9ea07130d772af7e3.tar.bz2
Add debugging info. Use the newly created "hasUnmodelledSideEffects" method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45178 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/MachineLICM.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp
index 8ae166b..200ca0b 100644
--- a/lib/CodeGen/MachineLICM.cpp
+++ b/lib/CodeGen/MachineLICM.cpp
@@ -103,25 +103,6 @@ namespace {
return LI->getLoopFor(BB) != CurLoop;
}
- /// CanHoistInst - Checks that this instructions is one that can be hoisted
- /// out of the loop. I.e., it has no side effects, isn't a control flow
- /// instr, etc.
- ///
- bool CanHoistInst(MachineInstr &I) const {
-#ifndef NDEBUG
- DEBUG({
- DOUT << "--- Checking if we can hoist " << I << "\n";
- if (I.getInstrDescriptor()->ImplicitUses)
- DOUT << " * Instruction has implicit uses.\n";
- else if (!TII->isTriviallyReMaterializable(&I))
- DOUT << " * Instruction has side effects.\n";
- });
-#endif
- // Don't hoist if this instruction implicitly reads physical registers.
- if (I.getInstrDescriptor()->ImplicitUses) return false;
- return TII->isTriviallyReMaterializable(&I);
- }
-
/// IsLoopInvariantInst - Returns true if the instruction is loop
/// invariant. I.e., all virtual register operands are defined outside of
/// the loop, physical registers aren't accessed (explicitly or implicitly),
@@ -272,13 +253,46 @@ void MachineLICM::HoistRegion(MachineDomTreeNode *N) {
/// instruction is hoistable.
///
bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
- if (!CanHoistInst(I)) return false;
+ DEBUG({
+ DOUT << "--- Checking if we can hoist " << I;
+ if (I.getInstrDescriptor()->ImplicitUses) {
+ DOUT << " * Instruction has implicit uses:\n";
+
+ const TargetMachine &TM = CurMF->getTarget();
+ const MRegisterInfo *MRI = TM.getRegisterInfo();
+ const unsigned *ImpUses = I.getInstrDescriptor()->ImplicitUses;
+
+ for (; *ImpUses; ++ImpUses)
+ DOUT << " -> " << MRI->getName(*ImpUses) << "\n";
+ }
+
+ if (I.getInstrDescriptor()->ImplicitDefs) {
+ DOUT << " * Instruction has implicit defines:\n";
+
+ const TargetMachine &TM = CurMF->getTarget();
+ const MRegisterInfo *MRI = TM.getRegisterInfo();
+ const unsigned *ImpDefs = I.getInstrDescriptor()->ImplicitDefs;
+
+ for (; *ImpDefs; ++ImpDefs)
+ DOUT << " -> " << MRI->getName(*ImpDefs) << "\n";
+ }
+
+ if (TII->hasUnmodelledSideEffects(&I))
+ DOUT << " * Instruction has side effects.\n";
+ });
+
+#if 0
+ // FIXME: Don't hoist if this instruction implicitly reads physical registers.
+ if (I.getInstrDescriptor()->ImplicitUses ||
+ I.getInstrDescriptor()->ImplicitDefs)
+ return false;
+#endif
// The instruction is loop invariant if all of its operands are loop-invariant
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
const MachineOperand &MO = I.getOperand(i);
- if (!MO.isRegister() || !MO.isUse())
+ if (!(MO.isRegister() && MO.getReg() && MO.isUse()))
continue;
unsigned Reg = MO.getReg();
@@ -295,6 +309,9 @@ bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
return false;
}
+ // Don't hoist something that has side effects.
+ if (TII->hasUnmodelledSideEffects(&I)) return false;
+
// If we got this far, the instruction is loop invariant!
return true;
}