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