Revert the kludge in 76703. I got a clean
authorDale Johannesen <dalej@apple.com>
Mon, 12 Oct 2009 18:49:00 +0000 (18:49 +0000)
committerDale Johannesen <dalej@apple.com>
Mon, 12 Oct 2009 18:49:00 +0000 (18:49 +0000)
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

include/llvm/Target/TargetInstrInfo.h
lib/CodeGen/TargetInstrInfoImpl.cpp
lib/CodeGen/VirtRegRewriter.cpp
lib/Target/PowerPC/PPCInstrInfo.h

index 5cd6ff5082e9da9e677418c35abff15ee5ccceb6..919bef1e7f2bb7292a25fcfb3cdd0bf8f0c40a52 100644 (file)
@@ -449,10 +449,6 @@ public:
     return true;
   }
 
-  /// isDeadInstruction - Return true if the instruction is considered dead.
-  /// This allows some late codegen passes to delete them.
-  virtual bool isDeadInstruction(const MachineInstr *MI) const = 0;
-
   /// GetInstSize - Returns the size of the specified Instruction.
   /// 
   virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const {
@@ -490,8 +486,6 @@ public:
                              MachineBasicBlock::iterator MI,
                              unsigned DestReg, unsigned SubReg,
                              const MachineInstr *Orig) const;
-  virtual bool isDeadInstruction(const MachineInstr *MI) const;
-
   virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
 };
 
index 2211308856c1bb44643834b41f2d73224f511802..c646869e8a735ec30f16123cc187bdbf3f374184 100644 (file)
@@ -143,27 +143,6 @@ void TargetInstrInfoImpl::reMaterialize(MachineBasicBlock &MBB,
   MBB.insert(I, MI);
 }
 
-bool TargetInstrInfoImpl::isDeadInstruction(const MachineInstr *MI) const {
-  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) {
-    const 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;
-}
-
 unsigned
 TargetInstrInfoImpl::GetFunctionSizeInBytes(const MachineFunction &MF) const {
   unsigned FnSize = 0;
index 670e1cb575e6d4d1a56160577f5a9aa3a60a057d..401bcb618e429e5c96552ea85346cfb4563da6c0 100644 (file)
@@ -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);
index a69a61632f45519070f2b43377cd2d0f9eb7de4f..bb0dc15a7922217e0c90f2e2231f337cda29dbd2 100644 (file)
@@ -146,13 +146,6 @@ public:
   virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
   virtual
   bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
-
-  virtual bool isDeadInstruction(const MachineInstr *MI) const {
-    // FIXME: Without this, ppc llvm-gcc doesn't bootstrap. That means some
-    // instruction definitions are not modeling side effects correctly.
-    // This is a workaround until we know the exact cause.
-    return false;
-  }
   
   /// GetInstSize - Return the number of bytes of code the specified
   /// instruction may be.  This returns the maximum number of bytes.