Skip to content

Commit 3075d2d

Browse files
author
tnowicki
committed
[Coroutines][LazyCallGraph] resumes are not really SCC
In this debug code the check assumes the lookup find an object. If it does not it tries to dereference the nullptr. This patch adds a check, however, notice it does not require the object to exist. This method (addSplitRefRecursiveFunctions) was added for coroutines with continuations. The split coroutine transform generates the continuations by cloning the entire function then changing the entry block and a few other things. This results in a lot of dead code that is kept around only to satisfy a few assumptions then is removed. With the deadcode the original function and its continuations appear to be SCC. However, when the deadcode is removed they are not SCC. Consider a simple coroutine { begin ... suspend ... suspend ... end }. After deadcode is eliminated the ramp references resume0, resume0 references resume1, etc... To be efficient it is necessary to split coroutines without generating deadcode and this removese the unnecessary references (on a phi's edges). This does not satisfy one of the conditions of addSplitRefRecursiveFunctions: "All new functions must reference (not call) each other.". From my testing so far it seems that this condition is not necessary and it is only this debug code that checks for it. Can we safely remove the "All new functions must reference (not call) each other." requirement of addSplitRefRecursiveFunctions? If not, what alternative do we have so we avoid cloning deadcode? (In our use case the deadcode can be a particular problem due to its size).
1 parent 6aa7403 commit 3075d2d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Analysis/LazyCallGraph.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,9 @@ void LazyCallGraph::addSplitRefRecursiveFunctions(
17751775
if (F1 == F2)
17761776
continue;
17771777
Node &N2 = get(*F2);
1778-
assert(!N1->lookup(N2)->isCall() &&
1779-
"Edges between new functions must be ref edges");
1778+
assert(!N1->lookup(N2) ||
1779+
(!N1->lookup(N2)->isCall() &&
1780+
"Edges between new functions must be ref edges"));
17801781
}
17811782
}
17821783
#endif

0 commit comments

Comments
 (0)