[llvm-commits] [llvm] r89905 - /llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp

Evan Cheng evan.cheng at apple.com
Wed Nov 25 16:32:36 PST 2009


Author: evancheng
Date: Wed Nov 25 18:32:36 2009
New Revision: 89905

URL: http://llvm.org/viewvc/llvm-project?rev=89905&view=rev
Log:
When all defs of a vr are implicit_def, delete all of the defs.

Modified:
    llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp

Modified: llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp?rev=89905&r1=89904&r2=89905&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp (original)
+++ llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp Wed Nov 25 18:32:36 2009
@@ -183,19 +183,23 @@
       // is not an implicit_def, do not insert implicit_def's before the
       // uses.
       bool Skip = false;
+      SmallVector<MachineInstr*, 4> DeadImpDefs;
       for (MachineRegisterInfo::def_iterator DI = mri_->def_begin(Reg),
              DE = mri_->def_end(); DI != DE; ++DI) {
-        if (DI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) {
+        MachineInstr *DeadImpDef = &*DI;
+        if (DeadImpDef->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) {
           Skip = true;
           break;
         }
+        DeadImpDefs.push_back(DeadImpDef);
       }
       if (Skip)
         continue;
 
       // The only implicit_def which we want to keep are those that are live
       // out of its block.
-      MI->eraseFromParent();
+      for (unsigned j = 0, ee = DeadImpDefs.size(); j != ee; ++j)
+        DeadImpDefs[j]->eraseFromParent();
       Changed = true;
 
       // Process each use instruction once.





More information about the llvm-commits mailing list