1 //===- InlineAdvisor.cpp - analysis pass implementation -------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements InlineAdvisorAnalysis and DefaultInlineAdvisor, and 10 // related types. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "llvm/Analysis/InlineAdvisor.h" 15 #include "llvm/ADT/Statistic.h" 16 #include "llvm/Analysis/InlineCost.h" 17 #include "llvm/Analysis/OptimizationRemarkEmitter.h" 18 #include "llvm/Analysis/ProfileSummaryInfo.h" 19 #include "llvm/Analysis/ReplayInlineAdvisor.h" 20 #include "llvm/Analysis/TargetLibraryInfo.h" 21 #include "llvm/Analysis/TargetTransformInfo.h" 22 #include "llvm/IR/DebugInfoMetadata.h" 23 #include "llvm/IR/Instructions.h" 24 #include "llvm/IR/PassManager.h" 25 #include "llvm/Support/CommandLine.h" 26 #include "llvm/Support/raw_ostream.h" 27 28 using namespace llvm; 29 #define DEBUG_TYPE "inline" 30 31 // This weirdly named statistic tracks the number of times that, when attempting 32 // to inline a function A into B, we analyze the callers of B in order to see 33 // if those would be more profitable and blocked inline steps. 34 STATISTIC(NumCallerCallersAnalyzed, "Number of caller-callers analyzed"); 35 36 /// Flag to add inline messages as callsite attributes 'inline-remark'. 37 static cl::opt<bool> 38 InlineRemarkAttribute("inline-remark-attribute", cl::init(false), 39 cl::Hidden, 40 cl::desc("Enable adding inline-remark attribute to" 41 " callsites processed by inliner but decided" 42 " to be not inlined")); 43 44 static cl::opt<bool> EnableInlineDeferral("inline-deferral", cl::init(false), 45 cl::Hidden, 46 cl::desc("Enable deferred inlining")); 47 48 // An integer used to limit the cost of inline deferral. The default negative 49 // number tells shouldBeDeferred to only take the secondary cost into account. 50 static cl::opt<int> 51 InlineDeferralScale("inline-deferral-scale", 52 cl::desc("Scale to limit the cost of inline deferral"), 53 cl::init(2), cl::Hidden); 54 55 extern cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats; 56 57 namespace { 58 using namespace llvm::ore; 59 class MandatoryInlineAdvice : public InlineAdvice { 60 public: 61 MandatoryInlineAdvice(InlineAdvisor *Advisor, CallBase &CB, 62 OptimizationRemarkEmitter &ORE, 63 bool IsInliningMandatory) 64 : InlineAdvice(Advisor, CB, ORE, IsInliningMandatory) {} 65 66 private: 67 void recordInliningWithCalleeDeletedImpl() override { recordInliningImpl(); } 68 69 void recordInliningImpl() override { 70 if (IsInliningRecommended) 71 emitInlinedInto(ORE, DLoc, Block, *Callee, *Caller, IsInliningRecommended, 72 [&](OptimizationRemark &Remark) { 73 Remark << ": always inline attribute"; 74 }); 75 } 76 77 void recordUnsuccessfulInliningImpl(const InlineResult &Result) override { 78 if (IsInliningRecommended) 79 ORE.emit([&]() { 80 return OptimizationRemarkMissed(DEBUG_TYPE, "NotInlined", DLoc, Block) 81 << "'" << NV("Callee", Callee) << "' is not AlwaysInline into '" 82 << NV("Caller", Caller) 83 << "': " << NV("Reason", Result.getFailureReason()); 84 }); 85 } 86 87 void recordUnattemptedInliningImpl() override { 88 assert(!IsInliningRecommended && "Expected to attempt inlining"); 89 } 90 }; 91 } // namespace 92 93 void DefaultInlineAdvice::recordUnsuccessfulInliningImpl( 94 const InlineResult &Result) { 95 using namespace ore; 96 llvm::setInlineRemark(*OriginalCB, std::string(Result.getFailureReason()) + 97 "; " + inlineCostStr(*OIC)); 98 ORE.emit([&]() { 99 return OptimizationRemarkMissed(DEBUG_TYPE, "NotInlined", DLoc, Block) 100 << "'" << NV("Callee", Callee) << "' is not inlined into '" 101 << NV("Caller", Caller) 102 << "': " << NV("Reason", Result.getFailureReason()); 103 }); 104 } 105 106 void DefaultInlineAdvice::recordInliningWithCalleeDeletedImpl() { 107 if (EmitRemarks) 108 emitInlinedIntoBasedOnCost(ORE, DLoc, Block, *Callee, *Caller, *OIC); 109 } 110 111 void DefaultInlineAdvice::recordInliningImpl() { 112 if (EmitRemarks) 113 emitInlinedIntoBasedOnCost(ORE, DLoc, Block, *Callee, *Caller, *OIC); 114 } 115 116 llvm::Optional<llvm::InlineCost> static getDefaultInlineAdvice( 117 CallBase &CB, FunctionAnalysisManager &FAM, const InlineParams &Params) { 118 Function &Caller = *CB.getCaller(); 119 ProfileSummaryInfo *PSI = 120 FAM.getResult<ModuleAnalysisManagerFunctionProxy>(Caller) 121 .getCachedResult<ProfileSummaryAnalysis>( 122 *CB.getParent()->getParent()->getParent()); 123 124 auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller); 125 auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { 126 return FAM.getResult<AssumptionAnalysis>(F); 127 }; 128 auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & { 129 return FAM.getResult<BlockFrequencyAnalysis>(F); 130 }; 131 auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { 132 return FAM.getResult<TargetLibraryAnalysis>(F); 133 }; 134 135 auto GetInlineCost = [&](CallBase &CB) { 136 Function &Callee = *CB.getCalledFunction(); 137 auto &CalleeTTI = FAM.getResult<TargetIRAnalysis>(Callee); 138 bool RemarksEnabled = 139 Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled( 140 DEBUG_TYPE); 141 return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI, 142 GetBFI, PSI, RemarksEnabled ? &ORE : nullptr); 143 }; 144 return llvm::shouldInline( 145 CB, GetInlineCost, ORE, 146 Params.EnableDeferral.getValueOr(EnableInlineDeferral)); 147 } 148 149 std::unique_ptr<InlineAdvice> 150 DefaultInlineAdvisor::getAdviceImpl(CallBase &CB) { 151 auto OIC = getDefaultInlineAdvice(CB, FAM, Params); 152 return std::make_unique<DefaultInlineAdvice>( 153 this, CB, OIC, 154 FAM.getResult<OptimizationRemarkEmitterAnalysis>(*CB.getCaller())); 155 } 156 157 InlineAdvice::InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, 158 OptimizationRemarkEmitter &ORE, 159 bool IsInliningRecommended) 160 : Advisor(Advisor), Caller(CB.getCaller()), Callee(CB.getCalledFunction()), 161 DLoc(CB.getDebugLoc()), Block(CB.getParent()), ORE(ORE), 162 IsInliningRecommended(IsInliningRecommended) {} 163 164 void InlineAdvice::recordInlineStatsIfNeeded() { 165 if (Advisor->ImportedFunctionsStats) 166 Advisor->ImportedFunctionsStats->recordInline(*Caller, *Callee); 167 } 168 169 void InlineAdvice::recordInlining() { 170 markRecorded(); 171 recordInlineStatsIfNeeded(); 172 recordInliningImpl(); 173 } 174 175 void InlineAdvice::recordInliningWithCalleeDeleted() { 176 markRecorded(); 177 recordInlineStatsIfNeeded(); 178 recordInliningWithCalleeDeletedImpl(); 179 } 180 181 AnalysisKey InlineAdvisorAnalysis::Key; 182 183 bool InlineAdvisorAnalysis::Result::tryCreate( 184 InlineParams Params, InliningAdvisorMode Mode, 185 const ReplayInlinerSettings &ReplaySettings) { 186 auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); 187 switch (Mode) { 188 case InliningAdvisorMode::Default: 189 LLVM_DEBUG(dbgs() << "Using default inliner heuristic.\n"); 190 Advisor.reset(new DefaultInlineAdvisor(M, FAM, Params)); 191 // Restrict replay to default advisor, ML advisors are stateful so 192 // replay will need augmentations to interleave with them correctly. 193 if (!ReplaySettings.ReplayFile.empty()) { 194 Advisor = llvm::getReplayInlineAdvisor(M, FAM, M.getContext(), 195 std::move(Advisor), ReplaySettings, 196 /* EmitRemarks =*/true); 197 } 198 break; 199 case InliningAdvisorMode::Development: 200 #ifdef LLVM_HAVE_TF_API 201 LLVM_DEBUG(dbgs() << "Using development-mode inliner policy.\n"); 202 Advisor = 203 llvm::getDevelopmentModeAdvisor(M, MAM, [&FAM, Params](CallBase &CB) { 204 auto OIC = getDefaultInlineAdvice(CB, FAM, Params); 205 return OIC.hasValue(); 206 }); 207 #endif 208 break; 209 case InliningAdvisorMode::Release: 210 #ifdef LLVM_HAVE_TF_AOT 211 LLVM_DEBUG(dbgs() << "Using release-mode inliner policy.\n"); 212 Advisor = llvm::getReleaseModeAdvisor(M, MAM); 213 #endif 214 break; 215 } 216 217 return !!Advisor; 218 } 219 220 /// Return true if inlining of CB can block the caller from being 221 /// inlined which is proved to be more beneficial. \p IC is the 222 /// estimated inline cost associated with callsite \p CB. 223 /// \p TotalSecondaryCost will be set to the estimated cost of inlining the 224 /// caller if \p CB is suppressed for inlining. 225 static bool 226 shouldBeDeferred(Function *Caller, InlineCost IC, int &TotalSecondaryCost, 227 function_ref<InlineCost(CallBase &CB)> GetInlineCost) { 228 // For now we only handle local or inline functions. 229 if (!Caller->hasLocalLinkage() && !Caller->hasLinkOnceODRLinkage()) 230 return false; 231 // If the cost of inlining CB is non-positive, it is not going to prevent the 232 // caller from being inlined into its callers and hence we don't need to 233 // defer. 234 if (IC.getCost() <= 0) 235 return false; 236 // Try to detect the case where the current inlining candidate caller (call 237 // it B) is a static or linkonce-ODR function and is an inlining candidate 238 // elsewhere, and the current candidate callee (call it C) is large enough 239 // that inlining it into B would make B too big to inline later. In these 240 // circumstances it may be best not to inline C into B, but to inline B into 241 // its callers. 242 // 243 // This only applies to static and linkonce-ODR functions because those are 244 // expected to be available for inlining in the translation units where they 245 // are used. Thus we will always have the opportunity to make local inlining 246 // decisions. Importantly the linkonce-ODR linkage covers inline functions 247 // and templates in C++. 248 // 249 // FIXME: All of this logic should be sunk into getInlineCost. It relies on 250 // the internal implementation of the inline cost metrics rather than 251 // treating them as truly abstract units etc. 252 TotalSecondaryCost = 0; 253 // The candidate cost to be imposed upon the current function. 254 int CandidateCost = IC.getCost() - 1; 255 // If the caller has local linkage and can be inlined to all its callers, we 256 // can apply a huge negative bonus to TotalSecondaryCost. 257 bool ApplyLastCallBonus = Caller->hasLocalLinkage() && !Caller->hasOneUse(); 258 // This bool tracks what happens if we DO inline C into B. 259 bool InliningPreventsSomeOuterInline = false; 260 unsigned NumCallerUsers = 0; 261 for (User *U : Caller->users()) { 262 CallBase *CS2 = dyn_cast<CallBase>(U); 263 264 // If this isn't a call to Caller (it could be some other sort 265 // of reference) skip it. Such references will prevent the caller 266 // from being removed. 267 if (!CS2 || CS2->getCalledFunction() != Caller) { 268 ApplyLastCallBonus = false; 269 continue; 270 } 271 272 InlineCost IC2 = GetInlineCost(*CS2); 273 ++NumCallerCallersAnalyzed; 274 if (!IC2) { 275 ApplyLastCallBonus = false; 276 continue; 277 } 278 if (IC2.isAlways()) 279 continue; 280 281 // See if inlining of the original callsite would erase the cost delta of 282 // this callsite. We subtract off the penalty for the call instruction, 283 // which we would be deleting. 284 if (IC2.getCostDelta() <= CandidateCost) { 285 InliningPreventsSomeOuterInline = true; 286 TotalSecondaryCost += IC2.getCost(); 287 NumCallerUsers++; 288 } 289 } 290 291 if (!InliningPreventsSomeOuterInline) 292 return false; 293 294 // If all outer calls to Caller would get inlined, the cost for the last 295 // one is set very low by getInlineCost, in anticipation that Caller will 296 // be removed entirely. We did not account for this above unless there 297 // is only one caller of Caller. 298 if (ApplyLastCallBonus) 299 TotalSecondaryCost -= InlineConstants::LastCallToStaticBonus; 300 301 // If InlineDeferralScale is negative, then ignore the cost of primary 302 // inlining -- IC.getCost() multiplied by the number of callers to Caller. 303 if (InlineDeferralScale < 0) 304 return TotalSecondaryCost < IC.getCost(); 305 306 int TotalCost = TotalSecondaryCost + IC.getCost() * NumCallerUsers; 307 int Allowance = IC.getCost() * InlineDeferralScale; 308 return TotalCost < Allowance; 309 } 310 311 namespace llvm { 312 static raw_ostream &operator<<(raw_ostream &R, const ore::NV &Arg) { 313 return R << Arg.Val; 314 } 315 316 template <class RemarkT> 317 RemarkT &operator<<(RemarkT &&R, const InlineCost &IC) { 318 using namespace ore; 319 if (IC.isAlways()) { 320 R << "(cost=always)"; 321 } else if (IC.isNever()) { 322 R << "(cost=never)"; 323 } else { 324 R << "(cost=" << ore::NV("Cost", IC.getCost()) 325 << ", threshold=" << ore::NV("Threshold", IC.getThreshold()) << ")"; 326 } 327 if (const char *Reason = IC.getReason()) 328 R << ": " << ore::NV("Reason", Reason); 329 return R; 330 } 331 } // namespace llvm 332 333 std::string llvm::inlineCostStr(const InlineCost &IC) { 334 std::string Buffer; 335 raw_string_ostream Remark(Buffer); 336 Remark << IC; 337 return Remark.str(); 338 } 339 340 void llvm::setInlineRemark(CallBase &CB, StringRef Message) { 341 if (!InlineRemarkAttribute) 342 return; 343 344 Attribute Attr = Attribute::get(CB.getContext(), "inline-remark", Message); 345 CB.addFnAttr(Attr); 346 } 347 348 /// Return the cost only if the inliner should attempt to inline at the given 349 /// CallSite. If we return the cost, we will emit an optimisation remark later 350 /// using that cost, so we won't do so from this function. Return None if 351 /// inlining should not be attempted. 352 Optional<InlineCost> 353 llvm::shouldInline(CallBase &CB, 354 function_ref<InlineCost(CallBase &CB)> GetInlineCost, 355 OptimizationRemarkEmitter &ORE, bool EnableDeferral) { 356 using namespace ore; 357 358 InlineCost IC = GetInlineCost(CB); 359 Instruction *Call = &CB; 360 Function *Callee = CB.getCalledFunction(); 361 Function *Caller = CB.getCaller(); 362 363 if (IC.isAlways()) { 364 LLVM_DEBUG(dbgs() << " Inlining " << inlineCostStr(IC) 365 << ", Call: " << CB << "\n"); 366 return IC; 367 } 368 369 if (!IC) { 370 LLVM_DEBUG(dbgs() << " NOT Inlining " << inlineCostStr(IC) 371 << ", Call: " << CB << "\n"); 372 if (IC.isNever()) { 373 ORE.emit([&]() { 374 return OptimizationRemarkMissed(DEBUG_TYPE, "NeverInline", Call) 375 << "'" << NV("Callee", Callee) << "' not inlined into '" 376 << NV("Caller", Caller) 377 << "' because it should never be inlined " << IC; 378 }); 379 } else { 380 ORE.emit([&]() { 381 return OptimizationRemarkMissed(DEBUG_TYPE, "TooCostly", Call) 382 << "'" << NV("Callee", Callee) << "' not inlined into '" 383 << NV("Caller", Caller) << "' because too costly to inline " 384 << IC; 385 }); 386 } 387 setInlineRemark(CB, inlineCostStr(IC)); 388 return None; 389 } 390 391 int TotalSecondaryCost = 0; 392 if (EnableDeferral && 393 shouldBeDeferred(Caller, IC, TotalSecondaryCost, GetInlineCost)) { 394 LLVM_DEBUG(dbgs() << " NOT Inlining: " << CB 395 << " Cost = " << IC.getCost() 396 << ", outer Cost = " << TotalSecondaryCost << '\n'); 397 ORE.emit([&]() { 398 return OptimizationRemarkMissed(DEBUG_TYPE, "IncreaseCostInOtherContexts", 399 Call) 400 << "Not inlining. Cost of inlining '" << NV("Callee", Callee) 401 << "' increases the cost of inlining '" << NV("Caller", Caller) 402 << "' in other contexts"; 403 }); 404 setInlineRemark(CB, "deferred"); 405 return None; 406 } 407 408 LLVM_DEBUG(dbgs() << " Inlining " << inlineCostStr(IC) << ", Call: " << CB 409 << '\n'); 410 return IC; 411 } 412 413 std::string llvm::formatCallSiteLocation(DebugLoc DLoc, 414 const CallSiteFormat &Format) { 415 std::string Buffer; 416 raw_string_ostream CallSiteLoc(Buffer); 417 bool First = true; 418 for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) { 419 if (!First) 420 CallSiteLoc << " @ "; 421 // Note that negative line offset is actually possible, but we use 422 // unsigned int to match line offset representation in remarks so 423 // it's directly consumable by relay advisor. 424 uint32_t Offset = 425 DIL->getLine() - DIL->getScope()->getSubprogram()->getLine(); 426 uint32_t Discriminator = DIL->getBaseDiscriminator(); 427 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName(); 428 if (Name.empty()) 429 Name = DIL->getScope()->getSubprogram()->getName(); 430 CallSiteLoc << Name.str() << ":" << llvm::utostr(Offset); 431 if (Format.outputColumn()) 432 CallSiteLoc << ":" << llvm::utostr(DIL->getColumn()); 433 if (Format.outputDiscriminator() && Discriminator) 434 CallSiteLoc << "." << llvm::utostr(Discriminator); 435 First = false; 436 } 437 438 return CallSiteLoc.str(); 439 } 440 441 void llvm::addLocationToRemarks(OptimizationRemark &Remark, DebugLoc DLoc) { 442 if (!DLoc.get()) { 443 return; 444 } 445 446 bool First = true; 447 Remark << " at callsite "; 448 for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) { 449 if (!First) 450 Remark << " @ "; 451 unsigned int Offset = DIL->getLine(); 452 Offset -= DIL->getScope()->getSubprogram()->getLine(); 453 unsigned int Discriminator = DIL->getBaseDiscriminator(); 454 StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName(); 455 if (Name.empty()) 456 Name = DIL->getScope()->getSubprogram()->getName(); 457 Remark << Name << ":" << ore::NV("Line", Offset) << ":" 458 << ore::NV("Column", DIL->getColumn()); 459 if (Discriminator) 460 Remark << "." << ore::NV("Disc", Discriminator); 461 First = false; 462 } 463 464 Remark << ";"; 465 } 466 467 void llvm::emitInlinedInto( 468 OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, 469 const Function &Callee, const Function &Caller, bool AlwaysInline, 470 function_ref<void(OptimizationRemark &)> ExtraContext, 471 const char *PassName) { 472 ORE.emit([&]() { 473 StringRef RemarkName = AlwaysInline ? "AlwaysInline" : "Inlined"; 474 OptimizationRemark Remark(PassName ? PassName : DEBUG_TYPE, RemarkName, 475 DLoc, Block); 476 Remark << "'" << ore::NV("Callee", &Callee) << "' inlined into '" 477 << ore::NV("Caller", &Caller) << "'"; 478 if (ExtraContext) 479 ExtraContext(Remark); 480 addLocationToRemarks(Remark, DLoc); 481 return Remark; 482 }); 483 } 484 485 void llvm::emitInlinedIntoBasedOnCost( 486 OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, 487 const Function &Callee, const Function &Caller, const InlineCost &IC, 488 bool ForProfileContext, const char *PassName) { 489 llvm::emitInlinedInto( 490 ORE, DLoc, Block, Callee, Caller, IC.isAlways(), 491 [&](OptimizationRemark &Remark) { 492 if (ForProfileContext) 493 Remark << " to match profiling context"; 494 Remark << " with " << IC; 495 }, 496 PassName); 497 } 498 499 InlineAdvisor::InlineAdvisor(Module &M, FunctionAnalysisManager &FAM) 500 : M(M), FAM(FAM) { 501 if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No) { 502 ImportedFunctionsStats = 503 std::make_unique<ImportedFunctionsInliningStatistics>(); 504 ImportedFunctionsStats->setModuleInfo(M); 505 } 506 } 507 508 InlineAdvisor::~InlineAdvisor() { 509 if (ImportedFunctionsStats) { 510 assert(InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No); 511 ImportedFunctionsStats->dump(InlinerFunctionImportStats == 512 InlinerFunctionImportStatsOpts::Verbose); 513 } 514 } 515 516 std::unique_ptr<InlineAdvice> InlineAdvisor::getMandatoryAdvice(CallBase &CB, 517 bool Advice) { 518 return std::make_unique<MandatoryInlineAdvice>(this, CB, getCallerORE(CB), 519 Advice); 520 } 521 522 InlineAdvisor::MandatoryInliningKind 523 InlineAdvisor::getMandatoryKind(CallBase &CB, FunctionAnalysisManager &FAM, 524 OptimizationRemarkEmitter &ORE) { 525 auto &Callee = *CB.getCalledFunction(); 526 527 auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { 528 return FAM.getResult<TargetLibraryAnalysis>(F); 529 }; 530 531 auto &TIR = FAM.getResult<TargetIRAnalysis>(Callee); 532 533 auto TrivialDecision = 534 llvm::getAttributeBasedInliningDecision(CB, &Callee, TIR, GetTLI); 535 536 if (TrivialDecision.hasValue()) { 537 if (TrivialDecision->isSuccess()) 538 return MandatoryInliningKind::Always; 539 else 540 return MandatoryInliningKind::Never; 541 } 542 return MandatoryInliningKind::NotMandatory; 543 } 544 545 std::unique_ptr<InlineAdvice> InlineAdvisor::getAdvice(CallBase &CB, 546 bool MandatoryOnly) { 547 if (!MandatoryOnly) 548 return getAdviceImpl(CB); 549 bool Advice = CB.getCaller() != CB.getCalledFunction() && 550 MandatoryInliningKind::Always == 551 getMandatoryKind(CB, FAM, getCallerORE(CB)); 552 return getMandatoryAdvice(CB, Advice); 553 } 554 555 OptimizationRemarkEmitter &InlineAdvisor::getCallerORE(CallBase &CB) { 556 return FAM.getResult<OptimizationRemarkEmitterAnalysis>(*CB.getCaller()); 557 } 558 559 PreservedAnalyses 560 InlineAdvisorAnalysisPrinterPass::run(Module &M, ModuleAnalysisManager &MAM) { 561 const auto *IA = MAM.getCachedResult<InlineAdvisorAnalysis>(M); 562 if (!IA) 563 OS << "No Inline Advisor\n"; 564 else 565 IA->getAdvisor()->print(OS); 566 return PreservedAnalyses::all(); 567 } 568