[PATCH] Replace loop doing postorder walk with postorder iterator
Chandler Carruth
chandlerc at gmail.com
Wed Apr 15 17:10:21 PDT 2015
Looks good with a tiny nit fixed below.
================
Comment at: include/llvm/Analysis/LoopInfoImpl.h:425
@@ -435,18 +424,3 @@
void PopulateLoopsDFS<BlockT, LoopT>::traverse(BlockT *EntryBlock) {
- pushBlock(EntryBlock);
- VisitedBlocks.insert(EntryBlock);
- while (!DFSStack.empty()) {
- // Traverse the leftmost path as far as possible.
- while (dfsSucc() != dfsSuccEnd()) {
- BlockT *BB = *dfsSucc();
- ++dfsSucc();
- if (!VisitedBlocks.insert(BB).second)
- continue;
-
- // Push the next DFS successor onto the stack.
- pushBlock(BB);
- }
- // Visit the top of the stack in postorder and backtrack.
- insertIntoLoop(dfsSource());
- DFSStack.pop_back();
- }
+ for (auto BB : post_order(EntryBlock))
+ insertIntoLoop(BB);
----------------
Especially here, where post_order could return anything, I'd write out explicitly "for (BlockT *BB : ...)".
http://reviews.llvm.org/D9032
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list