@@ -2080,12 +2080,13 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,
20802080 return Shape;
20812081}
20822082
2083- static void updateCallGraphAfterCoroutineSplit (
2083+ static LazyCallGraph::SCC & updateCallGraphAfterCoroutineSplit (
20842084 LazyCallGraph::Node &N, const coro::Shape &Shape,
20852085 const SmallVectorImpl<Function *> &Clones, LazyCallGraph::SCC &C,
20862086 LazyCallGraph &CG, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR,
20872087 FunctionAnalysisManager &FAM) {
20882088
2089+ auto *CurrentSCC = &C;
20892090 if (!Clones.empty ()) {
20902091 switch (Shape.ABI ) {
20912092 case coro::ABI::Switch:
@@ -2105,13 +2106,16 @@ static void updateCallGraphAfterCoroutineSplit(
21052106 }
21062107
21072108 // 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);
21092111 }
21102112
21112113 // Do some cleanup and let the CGSCC infra see if we've cleaned up any edges
21122114 // to the split functions.
21132115 postSplitCleanup (N.getFunction ());
2114- updateCGAndAnalysisManagerForFunctionPass (CG, C, N, AM, UR, FAM);
2116+ CurrentSCC = &updateCGAndAnalysisManagerForFunctionPass (CG, *CurrentSCC, N,
2117+ AM, UR, FAM);
2118+ return *CurrentSCC;
21152119}
21162120
21172121// / Replace a call to llvm.coro.prepare.retcon.
@@ -2200,6 +2204,7 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
22002204 if (Coroutines.empty () && PrepareFns.empty ())
22012205 return PreservedAnalyses::all ();
22022206
2207+ auto *CurrentSCC = &C;
22032208 // Split all the coroutines.
22042209 for (LazyCallGraph::Node *N : Coroutines) {
22052210 Function &F = N->getFunction ();
@@ -2211,7 +2216,8 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
22112216 coro::Shape Shape =
22122217 splitCoroutine (F, Clones, FAM.getResult <TargetIRAnalysis>(F),
22132218 OptimizeFrame, MaterializableCallback);
2214- updateCallGraphAfterCoroutineSplit (*N, Shape, Clones, C, CG, AM, UR, FAM);
2219+ CurrentSCC = &updateCallGraphAfterCoroutineSplit (
2220+ *N, Shape, Clones, *CurrentSCC, CG, AM, UR, FAM);
22152221
22162222 auto &ORE = FAM.getResult <OptimizationRemarkEmitterAnalysis>(F);
22172223 ORE.emit ([&]() {
@@ -2223,14 +2229,14 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
22232229
22242230 if (!Shape.CoroSuspends .empty ()) {
22252231 // Run the CGSCC pipeline on the original and newly split functions.
2226- UR.CWorklist .insert (&C );
2232+ UR.CWorklist .insert (CurrentSCC );
22272233 for (Function *Clone : Clones)
22282234 UR.CWorklist .insert (CG.lookupSCC (CG.get (*Clone)));
22292235 }
22302236 }
22312237
22322238 for (auto *PrepareFn : PrepareFns) {
2233- replaceAllPrepares (PrepareFn, CG, C );
2239+ replaceAllPrepares (PrepareFn, CG, *CurrentSCC );
22342240 }
22352241
22362242 return PreservedAnalyses::none ();
0 commit comments