[PATCH] D18796: Correct IDF calculator for ReverseIDF
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 18 23:19:10 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266718: Correct IDF calculator for ReverseIDF (authored by dannyb).
Changed prior to commit:
http://reviews.llvm.org/D18796?vs=54160&id=54161#toc
Repository:
rL LLVM
http://reviews.llvm.org/D18796
Files:
llvm/trunk/include/llvm/Analysis/IteratedDominanceFrontier.h
llvm/trunk/lib/Analysis/IteratedDominanceFrontier.cpp
llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Index: llvm/trunk/include/llvm/Analysis/IteratedDominanceFrontier.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/IteratedDominanceFrontier.h
+++ llvm/trunk/include/llvm/Analysis/IteratedDominanceFrontier.h
@@ -40,6 +40,9 @@
/// This algorithm is a linear time computation of Iterated Dominance Frontiers,
/// pruned using the live-in set.
/// By default, liveness is not used to prune the IDF computation.
+/// The template parameters should be either BasicBlock* or Inverse<BasicBlock
+/// *>, depending on if you want the forward or reverse IDF.
+template <class NodeTy>
class IDFCalculator {
public:
@@ -88,5 +91,7 @@
const SmallPtrSetImpl<BasicBlock *> *DefBlocks;
SmallVector<BasicBlock *, 32> PHIBlocks;
};
+typedef IDFCalculator<BasicBlock *> ForwardIDFCalculator;
+typedef IDFCalculator<Inverse<BasicBlock *>> ReverseIDFCalculator;
}
#endif
Index: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -523,7 +523,7 @@
AllocaInfo Info;
LargeBlockInfo LBI;
- IDFCalculator IDF(DT);
+ ForwardIDFCalculator IDF(DT);
for (unsigned AllocaNum = 0; AllocaNum != Allocas.size(); ++AllocaNum) {
AllocaInst *AI = Allocas[AllocaNum];
Index: llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
+++ llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
@@ -304,7 +304,7 @@
}
// Determine where our MemoryPhi's should go
- IDFCalculator IDFs(*DT);
+ ForwardIDFCalculator IDFs(*DT);
IDFs.setDefiningBlocks(DefiningBlocks);
IDFs.setLiveInBlocks(LiveInBlocks);
SmallVector<BasicBlock *, 32> IDFBlocks;
Index: llvm/trunk/lib/Analysis/IteratedDominanceFrontier.cpp
===================================================================
--- llvm/trunk/lib/Analysis/IteratedDominanceFrontier.cpp
+++ llvm/trunk/lib/Analysis/IteratedDominanceFrontier.cpp
@@ -16,9 +16,10 @@
#include "llvm/IR/Dominators.h"
#include <queue>
-using namespace llvm;
-
-void IDFCalculator::calculate(SmallVectorImpl<BasicBlock *> &PHIBlocks) {
+namespace llvm {
+template <class NodeTy>
+void IDFCalculator<NodeTy>::calculate(
+ SmallVectorImpl<BasicBlock *> &PHIBlocks) {
// If we haven't computed dominator tree levels, do so now.
if (DomLevels.empty()) {
for (auto DFI = df_begin(DT.getRootNode()), DFE = df_end(DT.getRootNode());
@@ -61,8 +62,12 @@
while (!Worklist.empty()) {
DomTreeNode *Node = Worklist.pop_back_val();
BasicBlock *BB = Node->getBlock();
-
- for (auto Succ : successors(BB)) {
+ // Succ is the successor in the direction we are calculating IDF, so it is
+ // successor for IDF, and predecessor for Reverse IDF.
+ for (auto SuccIter = GraphTraits<NodeTy>::child_begin(BB),
+ End = GraphTraits<NodeTy>::child_end(BB);
+ SuccIter != End; ++SuccIter) {
+ BasicBlock *Succ = *SuccIter;
DomTreeNode *SuccNode = DT.getNode(Succ);
// Quickly skip all CFG edges that are also dominator tree edges instead
@@ -93,3 +98,7 @@
}
}
}
+
+template class IDFCalculator<BasicBlock *>;
+template class IDFCalculator<Inverse<BasicBlock *>>;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18796.54161.patch
Type: text/x-patch
Size: 3451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160419/593bdfcb/attachment.bin>
More information about the llvm-commits
mailing list