aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/VirtRegRewriter.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-10-12 18:49:00 +0000
committerDale Johannesen <dalej@apple.com>2009-10-12 18:49:00 +0000
commit3a6b9eb868f579b945aa8ec8fadf65e4dd913555 (patch)
treeca7b4a8f6992c73b826fc4cb08f60fd1f576bfea /lib/CodeGen/VirtRegRewriter.cpp
parentc1deda50ca04d25e21a9b0bbd0ccccc882993e74 (diff)
downloadexternal_llvm-3a6b9eb868f579b945aa8ec8fadf65e4dd913555.tar.gz
external_llvm-3a6b9eb868f579b945aa8ec8fadf65e4dd913555.tar.bz2
external_llvm-3a6b9eb868f579b945aa8ec8fadf65e4dd913555.zip
Revert the kludge in 76703. I got a clean
bootstrap of FSF-style PPC, so there is some reason to believe the original bug (which was never analyzed) has been fixed, probably by 82266. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83871 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegRewriter.cpp')
-rw-r--r--lib/CodeGen/VirtRegRewriter.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/CodeGen/VirtRegRewriter.cpp b/lib/CodeGen/VirtRegRewriter.cpp
index 670e1cb575..401bcb618e 100644
--- a/lib/CodeGen/VirtRegRewriter.cpp
+++ b/lib/CodeGen/VirtRegRewriter.cpp
@@ -1478,6 +1478,29 @@ private:
++NumStores;
}
+ /// isSafeToDelete - Return true if this instruction doesn't produce any side
+ /// effect and all of its defs are dead.
+ static bool isSafeToDelete(MachineInstr &MI) {
+ const TargetInstrDesc &TID = MI.getDesc();
+ if (TID.mayLoad() || TID.mayStore() || TID.isCall() || TID.isTerminator() ||
+ TID.isCall() || TID.isBarrier() || TID.isReturn() ||
+ TID.hasUnmodeledSideEffects())
+ return false;
+ for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = MI.getOperand(i);
+ if (!MO.isReg() || !MO.getReg())
+ continue;
+ if (MO.isDef() && !MO.isDead())
+ return false;
+ if (MO.isUse() && MO.isKill())
+ // FIXME: We can't remove kill markers or else the scavenger will assert.
+ // An alternative is to add a ADD pseudo instruction to replace kill
+ // markers.
+ return false;
+ }
+ return true;
+ }
+
/// TransferDeadness - A identity copy definition is dead and it's being
/// removed. Find the last def or use and mark it as dead / kill.
void TransferDeadness(MachineBasicBlock *MBB, unsigned CurDist,
@@ -1519,7 +1542,7 @@ private:
if (LastUD->isDef()) {
// If the instruction has no side effect, delete it and propagate
// backward further. Otherwise, mark is dead and we are done.
- if (!TII->isDeadInstruction(LastUDMI)) {
+ if (!isSafeToDelete(*LastUDMI)) {
LastUD->setIsDead();
break;
}
@@ -2340,7 +2363,7 @@ private:
}
ProcessNextInst:
// Delete dead instructions without side effects.
- if (!Erased && !BackTracked && TII->isDeadInstruction(&MI)) {
+ if (!Erased && !BackTracked && isSafeToDelete(MI)) {
InvalidateKills(MI, TRI, RegKills, KillOps);
VRM.RemoveMachineInstrFromMaps(&MI);
MBB.erase(&MI);