Skip to content

Commit edb7f6c

Browse files
[MemProf] Add more assertion checking to the edge removal helper (#125017)
Check a few unexpected cases (edge already removed, edge not in its caller or callee edge lists).
1 parent 1fdf334 commit edb7f6c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ template <typename DerivedCCG, typename FuncTy, typename CallTy>
10571057
void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
10581058
ContextEdge *Edge, EdgeIter *EI, bool CalleeIter) {
10591059
assert(!EI || (*EI)->get() == Edge);
1060+
assert(!Edge->isRemoved());
10601061
// Save the Caller and Callee pointers so we can erase Edge from their edge
10611062
// lists after clearing Edge below. We do the clearing first in case it is
10621063
// destructed after removing from the edge lists (if those were the last
@@ -1069,6 +1070,10 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
10691070
// reference.
10701071
Edge->clear();
10711072

1073+
#ifndef NDEBUG
1074+
auto CalleeCallerCount = Callee->CallerEdges.size();
1075+
auto CallerCalleeCount = Caller->CalleeEdges.size();
1076+
#endif
10721077
if (!EI) {
10731078
Callee->eraseCallerEdge(Edge);
10741079
Caller->eraseCalleeEdge(Edge);
@@ -1079,6 +1084,8 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::removeEdgeFromGraph(
10791084
Caller->eraseCalleeEdge(Edge);
10801085
*EI = Callee->CallerEdges.erase(*EI);
10811086
}
1087+
assert(Callee->CallerEdges.size() < CalleeCallerCount);
1088+
assert(Caller->CalleeEdges.size() < CallerCalleeCount);
10821089
}
10831090

10841091
template <typename DerivedCCG, typename FuncTy, typename CallTy>

0 commit comments

Comments
 (0)