Lines Matching +full:low +full:- +full:cost
1 //===- InlineAdvisor.cpp - analysis pass implementation -------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
40 STATISTIC(NumCallerCallersAnalyzed, "Number of caller-callers analyzed");
42 /// Flag to add inline messages as callsite attributes 'inline-remark'.
44 InlineRemarkAttribute("inline-remark-attribute", cl::init(false),
46 cl::desc("Enable adding inline-remark attribute to"
50 static cl::opt<bool> EnableInlineDeferral("inline-deferral", cl::init(false),
54 // An integer used to limit the cost of inline deferral. The default negative
55 // number tells shouldBeDeferred to only take the secondary cost into account.
57 InlineDeferralScale("inline-deferral-scale",
58 cl::desc("Scale to limit the cost of inline deferral"),
62 AnnotateInlinePhase("annotate-inline-phase", cl::Hidden, cl::init(false),
93 return OptimizationRemarkMissed(Advisor->getAnnotatedInlinePassName(), in recordUnsuccessfulInliningImpl()
113 return OptimizationRemarkMissed(Advisor->getAnnotatedInlinePassName(), in recordUnsuccessfulInliningImpl()
125 Advisor->getAnnotatedInlinePassName()); in recordInliningWithCalleeDeletedImpl()
132 Advisor->getAnnotatedInlinePassName()); in recordInliningImpl()
141 *CB.getParent()->getParent()->getParent()); in getDefaultInlineAdvice()
144 auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { in getDefaultInlineAdvice()
147 auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & { in getDefaultInlineAdvice()
150 auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { in getDefaultInlineAdvice()
158 Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled( in getDefaultInlineAdvice()
184 if (Advisor->ImportedFunctionsStats) in recordInlineStatsIfNeeded()
185 Advisor->ImportedFunctionsStats->recordInline(*Caller, *Callee); in recordInlineStatsIfNeeded()
231 LLVM_DEBUG(dbgs() << "Using development-mode inliner policy.\n"); in tryCreate()
236 LLVM_DEBUG(dbgs() << "Using release-mode inliner policy.\n"); in tryCreate()
246 /// estimated inline cost associated with callsite \p CB.
247 /// \p TotalSecondaryCost will be set to the estimated cost of inlining the
253 if (!Caller->hasLocalLinkage() && !Caller->hasLinkOnceODRLinkage()) in shouldBeDeferred()
255 // If the cost of inlining CB is non-positive, it is not going to prevent the in shouldBeDeferred()
261 // it B) is a static or linkonce-ODR function and is an inlining candidate in shouldBeDeferred()
267 // This only applies to static and linkonce-ODR functions because those are in shouldBeDeferred()
270 // decisions. Importantly the linkonce-ODR linkage covers inline functions in shouldBeDeferred()
274 // the internal implementation of the inline cost metrics rather than in shouldBeDeferred()
277 // The candidate cost to be imposed upon the current function. in shouldBeDeferred()
278 int CandidateCost = IC.getCost() - 1; in shouldBeDeferred()
281 bool ApplyLastCallBonus = Caller->hasLocalLinkage() && !Caller->hasOneUse(); in shouldBeDeferred()
285 for (User *U : Caller->users()) { in shouldBeDeferred()
291 if (!CS2 || CS2->getCalledFunction() != Caller) { in shouldBeDeferred()
305 // See if inlining of the original callsite would erase the cost delta of in shouldBeDeferred()
318 // If all outer calls to Caller would get inlined, the cost for the last in shouldBeDeferred()
319 // one is set very low by getInlineCost, in anticipation that Caller will in shouldBeDeferred()
323 TotalSecondaryCost -= InlineConstants::LastCallToStaticBonus; in shouldBeDeferred()
325 // If InlineDeferralScale is negative, then ignore the cost of primary in shouldBeDeferred()
326 // inlining -- IC.getCost() multiplied by the number of callers to Caller. in shouldBeDeferred()
344 R << "(cost=always)"; in operator <<()
346 R << "(cost=never)"; in operator <<()
348 R << "(cost=" << ore::NV("Cost", IC.getCost()) in operator <<()
368 Attribute Attr = Attribute::get(CB.getContext(), "inline-remark", Message); in setInlineRemark()
372 /// Return the cost only if the inliner should attempt to inline at the given
373 /// CallSite. If we return the cost, we will emit an optimisation remark later
374 /// using that cost, so we won't do so from this function. Return std::nullopt
419 << " Cost = " << IC.getCost() in shouldInline()
420 << ", outer Cost = " << TotalSecondaryCost << '\n'); in shouldInline()
424 << "Not inlining. Cost of inlining '" << NV("Callee", Callee) in shouldInline()
425 << "' increases the cost of inlining '" << NV("Caller", Caller) in shouldInline()
442 for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) { in formatCallSiteLocation()
449 DIL->getLine() - DIL->getScope()->getSubprogram()->getLine(); in formatCallSiteLocation()
450 uint32_t Discriminator = DIL->getBaseDiscriminator(); in formatCallSiteLocation()
451 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName(); in formatCallSiteLocation()
453 Name = DIL->getScope()->getSubprogram()->getName(); in formatCallSiteLocation()
456 CallSiteLoc << ":" << llvm::utostr(DIL->getColumn()); in formatCallSiteLocation()
472 for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) { in addLocationToRemarks()
475 unsigned int Offset = DIL->getLine(); in addLocationToRemarks()
476 Offset -= DIL->getScope()->getSubprogram()->getLine(); in addLocationToRemarks()
477 unsigned int Discriminator = DIL->getBaseDiscriminator(); in addLocationToRemarks()
478 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName(); in addLocationToRemarks()
480 Name = DIL->getScope()->getSubprogram()->getName(); in addLocationToRemarks()
482 << ore::NV("Column", DIL->getColumn()); in addLocationToRemarks()
532 ImportedFunctionsStats->setModuleInfo(M); in InlineAdvisor()
539 ImportedFunctionsStats->dump(InlinerFunctionImportStats == in ~InlineAdvisor()
567 return "always-inline"; in getInlineAdvisorContext()
569 return "cgscc-inline"; in getInlineAdvisorContext()
571 return "early-inline"; in getInlineAdvisorContext()
573 return "ml-inline"; in getInlineAdvisorContext()
575 return "module-inline"; in getInlineAdvisorContext()
577 return "replay-cgscc-inline"; in getInlineAdvisorContext()
579 return "replay-sample-profile-inline"; in getInlineAdvisorContext()
581 return "sample-profile-inline"; in getInlineAdvisorContext()
588 return std::string(getLTOPhase(IC.LTOPhase)) + "-" + in AnnotateInlinePassName()
597 auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { in getMandatoryKind()
607 if (TrivialDecision->isSuccess()) in getMandatoryKind()
635 IA->getAdvisor()->print(OS); in run()
649 Module &M = *InitialC.begin()->getFunction().getParent(); in run()
654 IA->getAdvisor()->print(OS); in run()