diff options
author | Owen Anderson <resistor@mac.com> | 2010-09-16 18:35:07 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2010-09-16 18:35:07 +0000 |
commit | d10480657527ffb44ea213460fb3676a6b1300aa (patch) | |
tree | 714d7faa7cedcbe8207fa5c4166f731163e4f732 /llvm/lib/Transforms | |
parent | f95f59a0c295771928bafba0fe72f24aa3683d73 (diff) | |
download | bcm5719-llvm-d10480657527ffb44ea213460fb3676a6b1300aa.tar.gz bcm5719-llvm-d10480657527ffb44ea213460fb3676a6b1300aa.zip |
Use a depth-first iteratation in CorrelatedValuePropagation to avoid wasting time trying
to optimize unreachable blocks.
llvm-svn: 114105
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index 0d4e45de346..e8b8e946170 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/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; } |