[llvm] [Analysis] Visit orphan Functions in GCGPassManager catch-up loop (PR #194219)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 15:06:26 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)) {
----------------
SjoerdNijboer wrote:
I think so since orphaned node roots might become referenced by other nodes. At which point you don’t have to generate the functions anymore. However I didn’t like the approach so I’ve redone this with the custom iterator and only one single flow for regular and orphaned nodes.
https://github.com/llvm/llvm-project/pull/194219
More information about the llvm-commits
mailing list