@@ -2079,12 +2079,13 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,
2079
2079
return Shape;
2080
2080
}
2081
2081
2082
- static void updateCallGraphAfterCoroutineSplit (
2082
+ static LazyCallGraph::SCC & updateCallGraphAfterCoroutineSplit (
2083
2083
LazyCallGraph::Node &N, const coro::Shape &Shape,
2084
2084
const SmallVectorImpl<Function *> &Clones, LazyCallGraph::SCC &C,
2085
2085
LazyCallGraph &CG, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR,
2086
2086
FunctionAnalysisManager &FAM) {
2087
2087
2088
+ auto *CurrentSCC = &C;
2088
2089
if (!Clones.empty ()) {
2089
2090
switch (Shape.ABI ) {
2090
2091
case coro::ABI::Switch:
@@ -2104,13 +2105,16 @@ static void updateCallGraphAfterCoroutineSplit(
2104
2105
}
2105
2106
2106
2107
// Let the CGSCC infra handle the changes to the original function.
2107
- updateCGAndAnalysisManagerForCGSCCPass (CG, C, N, AM, UR, FAM);
2108
+ CurrentSCC = &updateCGAndAnalysisManagerForCGSCCPass (CG, *CurrentSCC, N, AM,
2109
+ UR, FAM);
2108
2110
}
2109
2111
2110
2112
// Do some cleanup and let the CGSCC infra see if we've cleaned up any edges
2111
2113
// to the split functions.
2112
2114
postSplitCleanup (N.getFunction ());
2113
- updateCGAndAnalysisManagerForFunctionPass (CG, C, N, AM, UR, FAM);
2115
+ CurrentSCC = &updateCGAndAnalysisManagerForFunctionPass (CG, *CurrentSCC, N,
2116
+ AM, UR, FAM);
2117
+ return *CurrentSCC;
2114
2118
}
2115
2119
2116
2120
// / Replace a call to llvm.coro.prepare.retcon.
@@ -2199,6 +2203,7 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
2199
2203
if (Coroutines.empty () && PrepareFns.empty ())
2200
2204
return PreservedAnalyses::all ();
2201
2205
2206
+ auto *CurrentSCC = &C;
2202
2207
// Split all the coroutines.
2203
2208
for (LazyCallGraph::Node *N : Coroutines) {
2204
2209
Function &F = N->getFunction ();
@@ -2210,7 +2215,8 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
2210
2215
coro::Shape Shape =
2211
2216
splitCoroutine (F, Clones, FAM.getResult <TargetIRAnalysis>(F),
2212
2217
OptimizeFrame, MaterializableCallback);
2213
- updateCallGraphAfterCoroutineSplit (*N, Shape, Clones, C, CG, AM, UR, FAM);
2218
+ CurrentSCC = &updateCallGraphAfterCoroutineSplit (
2219
+ *N, Shape, Clones, *CurrentSCC, CG, AM, UR, FAM);
2214
2220
2215
2221
auto &ORE = FAM.getResult <OptimizationRemarkEmitterAnalysis>(F);
2216
2222
ORE.emit ([&]() {
@@ -2222,14 +2228,14 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
2222
2228
2223
2229
if (!Shape.CoroSuspends .empty ()) {
2224
2230
// Run the CGSCC pipeline on the original and newly split functions.
2225
- UR.CWorklist .insert (&C );
2231
+ UR.CWorklist .insert (CurrentSCC );
2226
2232
for (Function *Clone : Clones)
2227
2233
UR.CWorklist .insert (CG.lookupSCC (CG.get (*Clone)));
2228
2234
}
2229
2235
}
2230
2236
2231
2237
for (auto *PrepareFn : PrepareFns) {
2232
- replaceAllPrepares (PrepareFn, CG, C );
2238
+ replaceAllPrepares (PrepareFn, CG, *CurrentSCC );
2233
2239
}
2234
2240
2235
2241
return PreservedAnalyses::none ();
0 commit comments