-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[CGSCC] Verify that call graph is valid after iteration #94692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Only in expensive checks, to match other LazyCallGraph verification. Is helpful for verifying LazyCallGraph updates. Many issues only surface when we reuse the LazyCallGraph.
@llvm/pr-subscribers-llvm-analysis Author: Arthur Eubanks (aeubanks) ChangesOnly in expensive checks, to match other LazyCallGraph verification. Is helpful for verifying LazyCallGraph updates. Many issues only surface when we reuse the LazyCallGraph. Full diff: https://github.com/llvm/llvm-project/pull/94692.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/LazyCallGraph.h
index 68c98b416ce96..ac8ca207d312b 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -943,6 +943,11 @@ class LazyCallGraph {
LazyCallGraph(LazyCallGraph &&G);
LazyCallGraph &operator=(LazyCallGraph &&RHS);
+#if !defined(NDEBUG) || defined(EXPENSIVE_CHECKS)
+ /// Verify that every RefSCC is valid.
+ void verify();
+#endif
+
bool invalidate(Module &, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &);
diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 2246887afe68a..8ae5c3dee6103 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -340,6 +340,11 @@ ModuleToPostOrderCGSCCPassAdaptor::run(Module &M, ModuleAnalysisManager &AM) {
} while (!RCWorklist.empty());
}
+#if defined(EXPENSIVE_CHECKS)
+ // Verify that the call graph is still valid.
+ CG.verify();
+#endif
+
// By definition we preserve the call garph, all SCC analyses, and the
// analysis proxies by handling them above and in any nested pass managers.
PA.preserveSet<AllAnalysesOn<LazyCallGraph::SCC>>();
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index 1e5cf84d589b0..48a7ca0061600 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -211,6 +211,14 @@ LazyCallGraph::LazyCallGraph(LazyCallGraph &&G)
updateGraphPtrs();
}
+#if !defined(NDEBUG) || defined(EXPENSIVE_CHECKS)
+void LazyCallGraph::verify() {
+ for (RefSCC &RC : postorder_ref_sccs()) {
+ RC.verify();
+ }
+}
+#endif
+
bool LazyCallGraph::invalidate(Module &, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &) {
// Check whether the analysis, all analyses on functions, or the function's
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Only in expensive checks, to match other LazyCallGraph verification. Is helpful for verifying LazyCallGraph updates. Many issues only surface when we reuse the LazyCallGraph. (cherry picked from commit 6f2c610)
Only in expensive checks, to match other LazyCallGraph verification. Is helpful for verifying LazyCallGraph updates. Many issues only surface when we reuse the LazyCallGraph. (cherry picked from commit 6f2c610)
Only in expensive checks, to match other LazyCallGraph verification.
Is helpful for verifying LazyCallGraph updates. Many issues only surface when we reuse the LazyCallGraph.