]> granicus.if.org Git - llvm/commitdiff
[SelectionDAG] Fix an use-after-free issue introduced in r305775.
authorHaojian Wu <hokein@google.com>
Tue, 20 Jun 2017 09:29:43 +0000 (09:29 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 20 Jun 2017 09:29:43 +0000 (09:29 +0000)
vector.back() will be invalidated when memory reallocation happens.

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

lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp

index c90747943f5f32a945bbeb7bcf54d71647c3eb58..70b1fa77a0991c645d0e0992b48a4095bdbc48c7 100644 (file)
@@ -1888,10 +1888,10 @@ CalcNodeSethiUllmanNumber(const SUnit *SU, std::vector<unsigned> &SUNumbers) {
         for (auto It : WorkList)
           assert(It.SU != PredSU && "Trying to push an element twice?");
 #endif
-        WorkList.push_back(PredSU);
-        AllPredsKnown = false;
         // Next time start processing this one starting from the next pred.
         Temp.PredsProcessed = P + 1;
+        WorkList.push_back(PredSU);
+        AllPredsKnown = false;
         break;
       }
     }