summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-09-16 18:35:07 +0000
committerOwen Anderson <resistor@mac.com>2010-09-16 18:35:07 +0000
commitceb9a959573b102d0fc7776cf4660881e6f0f628 (patch)
treef94e0317e11388bf7bbc7529f402cf378f989da2 /lib/Transforms
parent677c6ecd0804c247eb727a830b50cd6537a6c12c (diff)
downloadllvm-ceb9a959573b102d0fc7776cf4660881e6f0f628.tar.gz
llvm-ceb9a959573b102d0fc7776cf4660881e6f0f628.tar.bz2
llvm-ceb9a959573b102d0fc7776cf4660881e6f0f628.tar.xz
Use a depth-first iteratation in CorrelatedValuePropagation to avoid wasting time trying
to optimize unreachable blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/CorrelatedValuePropagation.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index 0d4e45de34..e8b8e94617 100644
--- a/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -19,6 +19,7 @@
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/Support/CFG.h"
#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
@@ -166,7 +167,10 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
bool FnChanged = false;
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
+ // Perform a depth-first walk of the CFG so that we don't waste time
+ // optimizing unreachable blocks.
+ for (df_iterator<BasicBlock*> FI = df_begin(&F.getEntryBlock()),
+ FE = df_end(&F.getEntryBlock()); FI != FE; ++FI) {
bool BBChanged = false;
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
Instruction *II = BI++;
@@ -191,7 +195,7 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
// Propagating correlated values might leave cruft around.
// Try to clean it up before we continue.
if (BBChanged)
- SimplifyInstructionsInBlock(FI);
+ SimplifyInstructionsInBlock(*FI);
FnChanged |= BBChanged;
}