summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/VirtRegRewriter.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-07-22 00:25:27 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-07-22 00:25:27 +0000
commit4dc848f3e81d369352e675f9195b3819e3b49cda (patch)
treee0865cde36cf13552d21e85d5125e74d6d338982 /llvm/lib/CodeGen/VirtRegRewriter.cpp
parent47db941fd3e5a698c4417e38686ff6da6b2d81ee (diff)
downloadbcm5719-llvm-4dc848f3e81d369352e675f9195b3819e3b49cda.tar.gz
bcm5719-llvm-4dc848f3e81d369352e675f9195b3819e3b49cda.zip
Let each target determines whether a machine instruction is dead. If true, that allows late codeine passes to delete it.
This is considered a workaround. The problem is some targets are not modeling side effects correctly. PPC is apparently one of those. This patch allows ppc llvm-gcc to bootstrap on Darwin. Once we find out which instruction definitions are wrong, we can remove the PPCInstrInfo workaround. llvm-svn: 76703
Diffstat (limited to 'llvm/lib/CodeGen/VirtRegRewriter.cpp')
-rw-r--r--llvm/lib/CodeGen/VirtRegRewriter.cpp27
1 files changed, 2 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/VirtRegRewriter.cpp b/llvm/lib/CodeGen/VirtRegRewriter.cpp
index 83224cc4742..745bfca9f26 100644
--- a/llvm/lib/CodeGen/VirtRegRewriter.cpp
+++ b/llvm/lib/CodeGen/VirtRegRewriter.cpp
@@ -1349,29 +1349,6 @@ 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,
@@ -1413,7 +1390,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 (!isSafeToDelete(*LastUDMI)) {
+ if (!TII->isDeadInstruction(LastUDMI)) {
LastUD->setIsDead();
break;
}
@@ -2198,7 +2175,7 @@ private:
}
ProcessNextInst:
// Delete dead instructions without side effects.
- if (!Erased && !BackTracked && isSafeToDelete(MI)) {
+ if (!Erased && !BackTracked && TII->isDeadInstruction(&MI)) {
InvalidateKills(MI, TRI, RegKills, KillOps);
VRM.RemoveMachineInstrFromMaps(&MI);
MBB.erase(&MI);
OpenPOWER on IntegriCloud