Have isel visit blocks in reverse postorder rather than an undefined order. This
authorCameron Zwarich <zwarich@apple.com>
Thu, 24 Feb 2011 10:00:04 +0000 (10:00 +0000)
committerCameron Zwarich <zwarich@apple.com>
Thu, 24 Feb 2011 10:00:04 +0000 (10:00 +0000)
allows for the information propagated across basic blocks to be merged at phis.

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

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index ae63f2e657f4188ba43a678212d2f52c83d4f57e..bbc62d8a91cc4d6d08505ef3c6b2820ea03c46bf 100644 (file)
@@ -49,6 +49,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Statistic.h"
 #include <algorithm>
 using namespace llvm;
@@ -832,8 +833,10 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
     FastIS = TLI.createFastISel(*FuncInfo);
 
   // Iterate over all basic blocks in the function.
-  for (Function::const_iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
-    const BasicBlock *LLVMBB = &*I;
+  ReversePostOrderTraversal<const Function*> RPOT(&Fn);
+  for (ReversePostOrderTraversal<const Function*>::rpo_iterator
+       I = RPOT.begin(), E = RPOT.end(); I != E; ++I) {
+    const BasicBlock *LLVMBB = *I;
 #ifndef NDEBUG
     CheckLineNumbers(LLVMBB);
 #endif