Lines Matching +full:batch +full:- +full:reduce
1 //===- Inliner.cpp - Code common to all inliners --------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
71 "intra-scc-cost-multiplier", cl::init(2), cl::Hidden,
74 "new call was previously an intra-SCC call (not relevant when the "
75 "original call was already intra-SCC). This can accumulate over "
79 "multiplied by intra-scc-cost-multiplier). This is to prevent tons of "
83 /// as part of the default (e.g. -O3) pipeline.
84 static cl::opt<bool> KeepAdvisorForPrinting("keep-inline-advisor-for-printing",
89 EnablePostSCCAdvisorPrinting("enable-scc-inline-advisor-printing",
94 "cgscc-inline-replay", cl::init(""), cl::value_desc("filename"),
101 "cgscc-inline-replay-scope",
114 "cgscc-inline-replay-fallback",
131 "cgscc-inline-replay-format",
149 while (InlineHistoryID != -1) {
167 // It should still be possible to run the inliner as a stand-alone SCC pass,
191 assert(IAA->getAdvisor() &&
194 return *IAA->getAdvisor();
213 Module &M = *InitialC.begin()->getFunction().getParent();
224 // process these in-order and append new calls introduced during inlining to
231 // other functions. Because the LLVM inliner is fundamentally a bottom-up
234 // too big to inline, and then move on and flatten another batch.
237 // bottom-up behavior. As a consequence, with heavily connected *SCCs* of
254 // We want to generally process call sites top-down in order for
261 if (Function *Callee = CB->getCalledFunction()) {
262 if (!Callee->isDeclaration())
263 Calls.push_back({CB, -1});
270 << NV("Caller", CB->getCaller())
301 // Track potentially dead non-local functions with comdats to see if they can
302 // be deleted as a batch after inlining.
312 Function &F = *Calls[I].first->getCaller();
321 auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
329 for (; I < (int)Calls.size() && Calls[I].first->getCaller() == &F; ++I) {
333 Function &Callee = *CB->getCalledFunction();
335 if (InlineHistoryID != -1 &&
338 << " -> " << Callee.getName() << "\n");
342 CB->setIsNoInline();
355 << F.getName() << " -> " << Callee.getName() << "\n");
367 if (!Advice->isInliningRecommended()) {
368 Advice->recordUnattemptedInlining();
381 &FAM.getResult<BlockFrequencyAnalysis>(*(CB->getCaller())),
386 &FAM.getResult<AAManager>(*CB->getCaller()));
388 Advice->recordUnsuccessfulInlining(IR);
405 Function *NewCallee = ICB->getCalledFunction();
406 assert(!(NewCallee && NewCallee->isIntrinsic()) &&
410 // the post-inline cleanup and the next DevirtSCCRepeatedPass
414 NewCallee = ICB->getCalledFunction();
417 if (!NewCallee->isDeclaration()) {
426 // self-recursive which the inliner bails out on, and inlining
434 ICB->addFnAttr(NewCBCostMult);
443 // the body of the function eagerly which may reduce the number of callers
444 // of other functions to one, changing inline cost thresholds. Non-local
453 return Call.first->getCaller() == &Callee;
469 Advice->recordInliningWithCalleeDeleted();
471 Advice->recordInlining();
476 --I;
486 // re-use the exact same logic for updating the call graph to reflect the
500 // mutation, we will revisit this function and potentially re-inline. If we
501 // do, and that re-inlining also has the potentially to mutate the SCC
545 // Note that this walks a pointer set which has non-deterministic order but
553 FAM.clear(*DeadF, DeadF->getName());
584 // Run the inliner first. The theory is that we are walking bottom-up and so
587 // For PreLinkThinLTO pass, we disable hot-caller heuristic for sample PGO
616 // in that case to try and catch knock-on inlining or function attrs
618 // in postorder (or bottom-up).
640 static_cast<PassInfoMixin<InlinerPass> *>(this)->printPipeline(
643 OS << "<only-mandatory>";