[llvm] [Analysis] Visit orphan Functions in GCGPassManager catch-up loop (PR #194219)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 14:52:09 PDT 2026
================
@@ -541,10 +555,51 @@ bool CGPassManager::runOnModule(Module &M) {
MaxSCCIterations.updateMax(Iteration);
}
+
+ Changed |= RunAllPassesOnOrphanNodes(CG, CurSCC, VisitedNodes);
Changed |= doFinalization(CG);
return Changed;
}
+bool CGPassManager::RunAllPassesOnOrphanNodes(
+ CallGraph &CG, CallGraphSCC &CurSCC,
+ std::vector<const CallGraphNode *> &VisitedNodes) {
+ bool Changed = false;
+
+ // Collect orphan roots up front so Module iteration cannot be disturbed
+ // by IR-level mutation a pass may perform on an orphan.
+ std::vector<CallGraphNode *> OrphanRoots;
+ for (Function &F : CG.getModule()) {
+ if (!F.isDeclaration()) {
+ CallGraphNode *Node = CG[&F];
+ if (!is_contained(VisitedNodes, Node))
+ OrphanRoots.push_back(Node);
+ }
+ }
+
+ for (CallGraphNode *Root : OrphanRoots) {
+ if (!is_contained(VisitedNodes, Root)) {
+ for (auto SCCI = scc_begin(Root); !SCCI.isAtEnd(); ++SCCI) {
+ const std::vector<CallGraphNode *> &Members = *SCCI;
+ if (!any_of(Members, [&](CallGraphNode *M) {
----------------
SjoerdNijboer wrote:
I used continue to reduice nesting.
I'm not particularly fond of continue but it seems to be common LLVM code.
https://github.com/llvm/llvm-project/pull/194219
More information about the llvm-commits
mailing list