summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-11 01:50:01 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-11 01:50:01 +0000
commitceec2bdaa52186b0bf92a6efe1545d093d70eb60 (patch)
treef6b5198fc202c67406f7a74387249acf43921cb3 /llvm/lib/Transforms/Utils/SimplifyInstructions.cpp
parent5d049b9732b29b6d46abe881efccb8a04be7cdff (diff)
downloadbcm5719-llvm-ceec2bdaa52186b0bf92a6efe1545d093d70eb60.tar.gz
bcm5719-llvm-ceec2bdaa52186b0bf92a6efe1545d093d70eb60.zip
Implement depth_first and inverse_depth_first range factory functions.
Also updated as many loops as I could find using df_begin/idf_begin - strangely I found no uses of idf_begin. Is that just used out of tree? Also a few places couldn't use df_begin because either they used the member functions of the depth first iterators or had specific ordering constraints (I added a comment in the latter case). Based on a patch by Jim Grosbach. (Jim - you just had iterator_range<T> where you needed iterator_range<idf_iterator<T>>) llvm-svn: 206016
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyInstructions.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyInstructions.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp b/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp
index bbd65f17528..6762527cf76 100644
--- a/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyInstructions.cpp
@@ -55,9 +55,10 @@ namespace {
bool Changed = false;
do {
- for (df_iterator<BasicBlock*> DI = df_begin(&F.getEntryBlock()),
- DE = df_end(&F.getEntryBlock()); DI != DE; ++DI)
- for (BasicBlock::iterator BI = DI->begin(), BE = DI->end(); BI != BE;) {
+ for (BasicBlock *BB : depth_first(&F.getEntryBlock()))
+ // Here be subtlety: the iterator must be incremented before the loop
+ // body (not sure why), so a range-for loop won't work here.
+ for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
Instruction *I = BI++;
// The first time through the loop ToSimplify is empty and we try to
// simplify all instructions. On later iterations ToSimplify is not
OpenPOWER on IntegriCloud