[llvm] 8604651 - [DomTree] Assert that blocks in queries aren't from another function
Daniil Suchkov via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 1 14:31:39 PDT 2021
Author: Daniil Suchkov
Date: 2021-10-01T21:30:54Z
New Revision: 86046516e4f4527213c595c154c9971d81a49601
URL: https://github.com/llvm/llvm-project/commit/86046516e4f4527213c595c154c9971d81a49601
DIFF: https://github.com/llvm/llvm-project/commit/86046516e4f4527213c595c154c9971d81a49601.diff
LOG: [DomTree] Assert that blocks in queries aren't from another function
This assertion should help us catch cases when DT is used in a way that
doesn't make much sense and usually indicates usage errors. In D110752
you can see a test on which this assertion catches a miscompile.
The assertion is added to getNode since all queries seem to be
routed through that function for all non-trivial cases.
Reviewed By: aeubanks, MaskRay
Differential Revision: https://reviews.llvm.org/D110751
Added:
Modified:
llvm/include/llvm/Support/GenericDomTree.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h
index 21fd50763b1f2..92af9891b0e90 100644
--- a/llvm/include/llvm/Support/GenericDomTree.h
+++ b/llvm/include/llvm/Support/GenericDomTree.h
@@ -349,6 +349,9 @@ class DominatorTreeBase {
/// may (but is not required to) be null for a forward (backwards)
/// statically unreachable block.
DomTreeNodeBase<NodeT> *getNode(const NodeT *BB) const {
+ assert((!BB || !BB->getParent() || BB->getParent() == Parent) &&
+ "A node from another function!");
+
auto I = DomTreeNodes.find(BB);
if (I != DomTreeNodes.end())
return I->second.get();
More information about the llvm-commits
mailing list