Avoid referring to edge D after the Succs or Preds arrays have
authorDan Gohman <gohman@apple.com>
Tue, 13 Jan 2009 19:08:45 +0000 (19:08 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 13 Jan 2009 19:08:45 +0000 (19:08 +0000)
been modified, to avoid trouble in the (unlikely) scenario that
D is a reference to an element in one of those arrays.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62173 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ScheduleDAG.cpp

index 730080d0fa4e36e49f9c476853d148686795aee3..62b816c1472d6db2cbea373ef0f30dd38b5db51b 100644 (file)
@@ -75,8 +75,8 @@ void SUnit::addPred(const SDep &D) {
     ++NumPredsLeft;
   if (!isScheduled)
     ++N->NumSuccsLeft;
-  N->Succs.push_back(P);
   Preds.push_back(D);
+  N->Succs.push_back(P);
   if (P.getLatency() != 0) {
     this->setDepthDirty();
     N->setHeightDirty();
@@ -105,8 +105,8 @@ void SUnit::removePred(const SDep &D) {
         }
       assert(FoundSucc && "Mismatching preds / succs lists!");
       Preds.erase(I);
-      // Update the bookkeeping;
-      if (D.getKind() == SDep::Data) {
+      // Update the bookkeeping.
+      if (P.getKind() == SDep::Data) {
         --NumPreds;
         --N->NumSuccs;
       }