[PATCH] D41298: [Dominators] Remove verifyDomTree add some verifing for Post Dom Trees
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 26 10:07:49 PST 2018
dmgreen updated this revision to Diff 131605.
dmgreen retitled this revision from "[PDT] Add verifyDomTree and verifyAnalysis for Post Dom Trees" to "[Dominators] Remove verifyDomTree add some verifing for Post Dom Trees".
dmgreen edited the summary of this revision.
dmgreen added a comment.
Herald added a subscriber: mehdi_amini.
Updates. What do you think?
This exposes a bug in the DominatorTree.InsertReachable2 test that we need to sort. We may need something like this, I'm not 100%:
diff --git a/include/llvm/Support/GenericDomTreeConstruction.h b/include/llvm/Support/GenericDomTreeConstruction.h
index 172efb5..53387db 100644
--- a/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/include/llvm/Support/GenericDomTreeConstruction.h
@@ -697,25 +697,22 @@ struct SemiNCAInfo {
}))
return;
+
// Recalculate the set of roots.
- DT.Roots = FindRoots(DT, BUI);
- for (const NodePtr R : DT.Roots) {
- const TreeNodePtr TN = DT.getNode(R);
- // A CFG node was selected as a tree root, but the corresponding tree node
- // is not connected to the virtual root. This is because the incremental
+ auto Roots = FindRoots(DT, BUI);
+ if (DT.Roots.size() != Roots.size() ||
+ !std::is_permutation(DT.Roots.begin(), DT.Roots.end(),
+ Roots.begin())) {
+ // The roots chosen in the CFG have changed. This is because the incremental
// algorithm does not really know or use the set of roots and can make a
// different (implicit) decision about which nodes within an infinite loop
// becomes a root.
- if (TN && !DT.isVirtualRoot(TN->getIDom())) {
- DEBUG(dbgs() << "Root " << BlockNamePrinter(R)
- << " is not virtual root's child\n"
- << "The entire tree needs to be rebuilt\n");
- // It should be possible to rotate the subtree instead of recalculating
- // the whole tree, but this situation happens extremely rarely in
- // practice.
- CalculateFromScratch(DT, BUI);
- return;
- }
+ DEBUG(dbgs() << "Roots are different in updated trees\n"
+ << "The entire tree needs to be rebuilt\n");
+ // It may be possible to rotate the subtree instead of recalculating
+ // the whole tree, but this situation happens extremely rarely in
+ // practice.
+ CalculateFromScratch(DT, BUI);
}
}
https://reviews.llvm.org/D41298
Files:
include/llvm/Analysis/PostDominators.h
include/llvm/CodeGen/MachineDominators.h
include/llvm/IR/Dominators.h
include/llvm/Support/GenericDomTree.h
include/llvm/Support/GenericDomTreeConstruction.h
lib/Analysis/PostDominators.cpp
lib/CodeGen/MachineDominators.cpp
lib/IR/Dominators.cpp
lib/Transforms/Scalar/LoopDistribute.cpp
lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
lib/Transforms/Utils/LibCallsShrinkWrap.cpp
lib/Transforms/Utils/LoopUnroll.cpp
lib/Transforms/Utils/LoopUnrollPeel.cpp
lib/Transforms/Vectorize/LoopVectorize.cpp
unittests/IR/DominatorTreeTest.cpp
unittests/Transforms/Scalar/LoopPassManagerTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41298.131605.patch
Type: text/x-patch
Size: 16297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180126/1f608d71/attachment.bin>
More information about the llvm-commits
mailing list