[PATCH] D31681: [ExecutionDepsFix] Don't recurse over the CFG

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 10:55:32 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL299569: [ExecutionDepsFix] Don't recurse over the CFG (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D31681?vs=94129&id=94261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31681

Files:
  llvm/trunk/include/llvm/CodeGen/ExecutionDepsFix.h
  llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp


Index: llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp
+++ llvm/trunk/lib/CodeGen/ExecutionDepsFix.cpp
@@ -616,26 +616,6 @@
          MBBInfos[MBB].IncomingProcessed == MBB->pred_size();
 }
 
-void ExecutionDepsFix::updateSuccessors(MachineBasicBlock *MBB, bool Primary) {
-  bool Done = isBlockDone(MBB);
-  for (auto *Succ : MBB->successors()) {
-    if (!isBlockDone(Succ)) {
-      if (Primary) {
-        MBBInfos[Succ].IncomingProcessed++;
-      }
-      if (Done) {
-        MBBInfos[Succ].IncomingCompleted++;
-      }
-      if (isBlockDone(Succ)) {
-        // Perform secondary processing for this successor. See the big comment
-        // in runOnMachineFunction, for an explanation of the iteration order.
-        processBasicBlock(Succ, false);
-        updateSuccessors(Succ, false);
-      }
-    }
-  }
-}
-
 bool ExecutionDepsFix::runOnMachineFunction(MachineFunction &mf) {
   if (skipFunction(*mf.getFunction()))
     return false;
@@ -708,15 +688,36 @@
 
   MachineBasicBlock *Entry = &*MF->begin();
   ReversePostOrderTraversal<MachineBasicBlock*> RPOT(Entry);
+  SmallVector<MachineBasicBlock *, 4> Workqueue;
   for (ReversePostOrderTraversal<MachineBasicBlock*>::rpo_iterator
          MBBI = RPOT.begin(), MBBE = RPOT.end(); MBBI != MBBE; ++MBBI) {
     MachineBasicBlock *MBB = *MBBI;
     // N.B: IncomingProcessed and IncomingCompleted were already updated while
     // processing this block's predecessors.
     MBBInfos[MBB].PrimaryCompleted = true;
     MBBInfos[MBB].PrimaryIncoming = MBBInfos[MBB].IncomingProcessed;
-    processBasicBlock(MBB, true);
-    updateSuccessors(MBB, true);
+    bool Primary = true;
+    Workqueue.push_back(MBB);
+    while (!Workqueue.empty()) {
+      MachineBasicBlock *ActiveMBB = &*Workqueue.back();
+      Workqueue.pop_back();
+      processBasicBlock(ActiveMBB, Primary);
+      bool Done = isBlockDone(ActiveMBB);
+      for (auto *Succ : ActiveMBB->successors()) {
+        if (!isBlockDone(Succ)) {
+          if (Primary) {
+            MBBInfos[Succ].IncomingProcessed++;
+          }
+          if (Done) {
+            MBBInfos[Succ].IncomingCompleted++;
+          }
+          if (isBlockDone(Succ)) {
+            Workqueue.push_back(Succ);
+          }
+        }
+      }
+      Primary = false;
+    }
   }
 
   // We need to go through again and finalize any blocks that are not done yet.
Index: llvm/trunk/include/llvm/CodeGen/ExecutionDepsFix.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/ExecutionDepsFix.h
+++ llvm/trunk/include/llvm/CodeGen/ExecutionDepsFix.h
@@ -205,7 +205,6 @@
   void leaveBasicBlock(MachineBasicBlock*);
   bool isBlockDone(MachineBasicBlock *);
   void processBasicBlock(MachineBasicBlock *MBB, bool PrimaryPass);
-  void updateSuccessors(MachineBasicBlock *MBB, bool PrimaryPass);
   bool visitInstr(MachineInstr *);
   void processDefs(MachineInstr *, bool breakDependency, bool Kill);
   void visitSoftInstr(MachineInstr*, unsigned mask);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31681.94261.patch
Type: text/x-patch
Size: 3131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170405/72b09fff/attachment.bin>


More information about the llvm-commits mailing list