Avoid inserting a live register more than once.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 27 Sep 2007 18:46:06 +0000 (18:46 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 27 Sep 2007 18:46:06 +0000 (18:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42410 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp

index 6127ab6381cb0501520c929e2ff0a152cea8d23f..0b218abd4ab3d08fb93133799b032db86d7afe7a 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include <climits>
@@ -523,17 +524,22 @@ bool ScheduleDAGRRList::DelayForLiveRegsBottomUp(SUnit *SU,
   if (LiveRegs.empty())
     return false;
 
+  SmallSet<unsigned, 4> RegAdded;
   // If this node would clobber any "live" register, then it's not ready.
   for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
        I != E; ++I) {
     if (I->Cost < 0)  {
       unsigned Reg = I->Reg;
-      if (LiveRegs.count(Reg) && LiveRegDefs[Reg] != I->Dep)
-        LRegs.push_back(Reg);
+      if (LiveRegs.count(Reg) && LiveRegDefs[Reg] != I->Dep) {
+        if (RegAdded.insert(Reg))
+          LRegs.push_back(Reg);
+      }
       for (const unsigned *Alias = MRI->getAliasSet(Reg);
            *Alias; ++Alias)
-        if (LiveRegs.count(*Alias) && LiveRegDefs[*Alias] != I->Dep)
-          LRegs.push_back(*Alias);
+        if (LiveRegs.count(*Alias) && LiveRegDefs[*Alias] != I->Dep) {
+          if (RegAdded.insert(*Alias))
+            LRegs.push_back(*Alias);
+        }
     }
   }
 
@@ -545,12 +551,16 @@ bool ScheduleDAGRRList::DelayForLiveRegsBottomUp(SUnit *SU,
     if (!TID.ImplicitDefs)
       continue;
     for (const unsigned *Reg = TID.ImplicitDefs; *Reg; ++Reg) {
-      if (LiveRegs.count(*Reg) && LiveRegDefs[*Reg] != SU)
-        LRegs.push_back(*Reg);
+      if (LiveRegs.count(*Reg) && LiveRegDefs[*Reg] != SU) {
+        if (RegAdded.insert(*Reg))
+          LRegs.push_back(*Reg);
+      }
       for (const unsigned *Alias = MRI->getAliasSet(*Reg);
            *Alias; ++Alias)
-        if (LiveRegs.count(*Alias) && LiveRegDefs[*Alias] != SU)
-          LRegs.push_back(*Alias);
+        if (LiveRegs.count(*Alias) && LiveRegDefs[*Alias] != SU) {
+          if (RegAdded.insert(*Alias))
+            LRegs.push_back(*Alias);
+        }
     }
   }
   return !LRegs.empty();