[MCA][Pipeline] Don't visit stages in reverse order when calling method cycleEnd...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 27 Mar 2019 15:41:53 +0000 (15:41 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 27 Mar 2019 15:41:53 +0000 (15:41 +0000)
There is no reason why stages should be visited in reverse order.
This patch allows the definition of stages that push instructions forward from
their cycleEnd() routine.

llvm-svn: 357074

llvm/lib/MCA/Pipeline.cpp

index 5361f08..6860a8c 100644 (file)
@@ -63,9 +63,9 @@ Error Pipeline::runCycle() {
     Err = FirstStage.execute(IR);
 
   // Update stages in preparation for a new cycle.
-  for (auto I = Stages.rbegin(), E = Stages.rend(); I != E && !Err; ++I) {
-    const std::unique_ptr<Stage> &S = *I;
-    Err = S->cycleEnd();
+  for (const std::unique_ptr<Stage> &S : Stages) {
+    if (Err = S->cycleEnd())
+      break;
   }
 
   return Err;