[llvm] [MemProf] Add more assertion checking to the edge removal helper (PR #125017)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 29 19:11:33 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Teresa Johnson (teresajohnson)
<details>
<summary>Changes</summary>
Check a few unexpected cases (edge already removed, edge not in its
caller or callee edge lists).
---
Full diff: https://github.com/llvm/llvm-project/pull/125017.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp (+7)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 03e2e7089202de..d478088e5bbcb2 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -1057,6 +1057,7 @@ template <typename DerivedCCG, typename FuncTy, typename CallTy>
void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
ContextEdge *Edge, EdgeIter *EI, bool CalleeIter) {
assert(!EI || (*EI)->get() == Edge);
+ assert(!Edge->isRemoved());
// Save the Caller and Callee pointers so we can erase Edge from their edge
// lists after clearing Edge below. We do the clearing first in case it is
// destructed after removing from the edge lists (if those were the last
@@ -1069,6 +1070,10 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
// reference.
Edge->clear();
+#ifndef NDEBUG
+ auto CalleeCallerCount = Callee->CallerEdges.size();
+ auto CallerCalleeCount = Caller->CalleeEdges.size();
+#endif
if (!EI) {
Callee->eraseCallerEdge(Edge);
Caller->eraseCalleeEdge(Edge);
@@ -1079,6 +1084,8 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
Caller->eraseCalleeEdge(Edge);
*EI = Callee->CallerEdges.erase(*EI);
}
+ assert(Callee->CallerEdges.size() < CalleeCallerCount);
+ assert(Caller->CalleeEdges.size() < CallerCalleeCount);
}
template <typename DerivedCCG, typename FuncTy, typename CallTy>
``````````
</details>
https://github.com/llvm/llvm-project/pull/125017
More information about the llvm-commits
mailing list