bool SRETPromotion::runOnSCC(CallGraphSCC &SCC) { bool Changed = false; for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) if (CallGraphNode *NewNode = PromoteReturn(*I)) { SCC.ReplaceNode(*I, NewNode); Changed = true; } return Changed; }
bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) { if (skipSCC(SCC)) return false; // Get the callgraph information that we need to update to reflect our // changes. CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph(); LegacyAARGetter AARGetter(*this); bool Changed = false, LocalChange; // Iterate until we stop promoting from this SCC. do { LocalChange = false; // Attempt to promote arguments from all functions in this SCC. for (CallGraphNode *OldNode : SCC) { Function *OldF = OldNode->getFunction(); if (!OldF) continue; auto ReplaceCallSite = [&](CallSite OldCS, CallSite NewCS) { Function *Caller = OldCS.getInstruction()->getParent()->getParent(); CallGraphNode *NewCalleeNode = CG.getOrInsertFunction(NewCS.getCalledFunction()); CallGraphNode *CallerNode = CG[Caller]; CallerNode->replaceCallEdge(OldCS, NewCS, NewCalleeNode); }; if (Function *NewF = promoteArguments(OldF, AARGetter, MaxElements, {ReplaceCallSite})) { LocalChange = true; // Update the call graph for the newly promoted function. CallGraphNode *NewNode = CG.getOrInsertFunction(NewF); NewNode->stealCalledFunctionsFrom(OldNode); if (OldNode->getNumReferences() == 0) delete CG.removeFunctionFromModule(OldNode); else OldF->setLinkage(Function::ExternalLinkage); // And updat ethe SCC we're iterating as well. SCC.ReplaceNode(OldNode, NewNode); } } // Remember that we changed something. Changed |= LocalChange; } while (LocalChange); return Changed; }
bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) { bool Changed = false, LocalChange; do { // Iterate until we stop promoting from this SCC. LocalChange = false; // Attempt to promote arguments from all functions in this SCC. for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) { if (CallGraphNode *CGN = PromoteArguments(*I)) { LocalChange = true; SCC.ReplaceNode(*I, CGN); } } Changed |= LocalChange; // Remember that we changed something. } while (LocalChange); return Changed; }
bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) { bool Changed = false, LocalChange; DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); DL = DLP ? &DLP->getDataLayout() : nullptr; do { // Iterate until we stop promoting from this SCC. LocalChange = false; // Attempt to promote arguments from all functions in this SCC. for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) { if (CallGraphNode *CGN = PromoteArguments(*I)) { LocalChange = true; SCC.ReplaceNode(*I, CGN); } } Changed |= LocalChange; // Remember that we changed something. } while (LocalChange); return Changed; }
static bool runImpl(CallGraphSCC &SCC, CallGraph &CG, function_ref<AAResults &(Function &F)> AARGetter, unsigned MaxElements) { bool Changed = false, LocalChange; do { // Iterate until we stop promoting from this SCC. LocalChange = false; // Attempt to promote arguments from all functions in this SCC. for (CallGraphNode *OldNode : SCC) { if (CallGraphNode *NewNode = PromoteArguments(OldNode, CG, AARGetter, MaxElements)) { LocalChange = true; SCC.ReplaceNode(OldNode, NewNode); } } Changed |= LocalChange; // Remember that we changed something. } while (LocalChange); return Changed; }