Skip to content

Commit 21b2331

Browse files
committed
[Coroutines] [LazyCallGraph] Make all new functions reference eachother.
1 parent 4359d15 commit 21b2331

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

llvm/include/llvm/Analysis/LazyCallGraph.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,12 +1081,12 @@ class LazyCallGraph {
10811081

10821082
/// Add new ref-recursive functions split/outlined from an existing function.
10831083
///
1084-
/// The new functions may only reference other functions that the original
1085-
/// function did. The new functions may reference (not call) the original
1086-
/// function.
1084+
/// The new functions may only reference the original function or other
1085+
/// functions that the original function did. New functions must not call
1086+
/// other new functions.
10871087
///
1088-
/// The original function must reference (not call) all new functions.
1089-
/// All new functions must reference (not call) each other.
1088+
/// Mark the original function as referencing all new functions.
1089+
/// Mark all new functions as referencing each other.
10901090
void addSplitRefRecursiveFunctions(Function &OriginalFunction,
10911091
ArrayRef<Function *> NewFunctions);
10921092

llvm/lib/Analysis/LazyCallGraph.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,7 @@ void LazyCallGraph::addSplitRefRecursiveFunctions(
17201720
for (Function *NewFunction : NewFunctions) {
17211721
Node &NewN = initNode(*NewFunction);
17221722

1723+
// Make the original function reference each new function
17231724
OriginalN->insertEdgeInternal(NewN, Edge::Kind::Ref);
17241725

17251726
// Check if there is any edge from any new function back to any function in
@@ -1732,6 +1733,23 @@ void LazyCallGraph::addSplitRefRecursiveFunctions(
17321733
}
17331734
}
17341735

1736+
for (Function *NewFunction : NewFunctions) {
1737+
Node &NewN = get(*NewFunction);
1738+
for (Function *OtherNewFunction : NewFunctions) {
1739+
if (NewFunction == OtherNewFunction)
1740+
continue;
1741+
1742+
Node &OtherNewN = get(*OtherNewFunction);
1743+
1744+
// Don't add an edge if one already exists.
1745+
if (NewN->lookup(OtherNewN))
1746+
continue;
1747+
1748+
// Make the new function reference each other new function
1749+
NewN->insertEdgeInternal(OtherNewN, Edge::Kind::Ref);
1750+
}
1751+
}
1752+
17351753
RefSCC *NewRC;
17361754
if (ExistsRefToOriginalRefSCC) {
17371755
// If there is any edge from any new function to any function in the
@@ -1775,7 +1793,7 @@ void LazyCallGraph::addSplitRefRecursiveFunctions(
17751793
if (F1 == F2)
17761794
continue;
17771795
Node &N2 = get(*F2);
1778-
assert(!N1->lookup(N2) ||
1796+
assert(N1->lookup(N2) &&
17791797
(!N1->lookup(N2)->isCall() &&
17801798
"Edges between new functions must be ref edges"));
17811799
}

0 commit comments

Comments
 (0)