[PATCH] D79298: [NFC] Traverse function using dominator tree.
Zoe Carver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 16:26:15 PDT 2020
zoecarver created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Iterate over the basic blocks in a function using a dominator tree instead of the function iterator.
This will be helpful when adding support for multiple blocks.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79298
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -9,9 +9,6 @@
// This file implements a trivial dead store elimination that only considers
// basic-block local redundant stores.
//
-// FIXME: This should eventually be extended to be a post-dominator tree
-// traversal. Doing so would be pretty trivial.
-//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar/DeadStoreElimination.h"
@@ -1388,12 +1385,14 @@
MemoryDependenceResults *MD, DominatorTree *DT,
const TargetLibraryInfo *TLI) {
bool MadeChange = false;
- for (BasicBlock &BB : F)
+ for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT);
+ node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) {
+ BasicBlock *BB = node->getBlock();
// Only check non-dead blocks. Dead blocks may have strange pointer
// cycles that will confuse alias analysis.
- if (DT->isReachableFromEntry(&BB))
- MadeChange |= eliminateDeadStores(BB, AA, MD, DT, TLI);
-
+ if (DT->isReachableFromEntry(BB))
+ MadeChange |= eliminateDeadStores(*BB, AA, MD, DT, TLI);
+ }
return MadeChange;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79298.261673.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/3671a69d/attachment.bin>
More information about the llvm-commits
mailing list