diff --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h b/llvm/include/llvm/Analysis/CGSCCPassManager.h --- a/llvm/include/llvm/Analysis/CGSCCPassManager.h +++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h @@ -292,6 +292,8 @@ /// post-order walk. LazyCallGraph::SCC *UpdatedC; + bool SkipCurrentC; + /// Preserved analyses across SCCs. /// /// We specifically want to allow CGSCC passes to mutate ancestor IR diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp --- a/llvm/lib/Analysis/CGSCCPassManager.cpp +++ b/llvm/lib/Analysis/CGSCCPassManager.cpp @@ -81,6 +81,12 @@ AM.getCachedResult(*C)->getManager(); for (auto &Pass : Passes) { + if (UR.SkipCurrentC) { + UR.SkipCurrentC = false; + LLVM_DEBUG(dbgs() << "?\n"); + break; + } + // Check the PassInstrumentation's BeforePass callbacks before running the // pass, skip its execution completely if asked to (callback returns false). if (!PI.runBeforePass(*Pass, *C)) @@ -174,10 +180,16 @@ SmallDenseSet, 4> InlinedInternalEdges; - CGSCCUpdateResult UR = { - RCWorklist, CWorklist, InvalidRefSCCSet, InvalidSCCSet, - nullptr, nullptr, PreservedAnalyses::all(), InlinedInternalEdges, - {}}; + CGSCCUpdateResult UR = {RCWorklist, + CWorklist, + InvalidRefSCCSet, + InvalidSCCSet, + nullptr, + nullptr, + false, + PreservedAnalyses::all(), + InlinedInternalEdges, + {}}; // Request PassInstrumentation from analysis manager, will use it to run // instrumenting callbacks for the passes later. @@ -1200,6 +1212,7 @@ UR.CWorklist.insert(C); LLVM_DEBUG(dbgs() << "Enqueuing the existing SCC in the worklist: " << *C << "\n"); + UR.SkipCurrentC = true; // Enqueue in reverse order as we pop off the back of the worklist. for (SCC &MovedC : llvm::reverse(make_range(RC->begin() + InitialSCCIndex, RC->begin() + NewSCCIndex))) {