blob: 739b0dae3146c3e6c3d4bbcb255a0fb71e821bc4 [file] [log] [blame]
Owen Anderson2f82e272009-06-14 08:26:32 +00001//===- PartialInlining.cpp - Inline parts of functions --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This pass performs partial inlining, typically by inlining an if statement
11// that surrounds the body of the function.
12//
13//===----------------------------------------------------------------------===//
14
Easwaran Raman1832bf62016-06-27 16:50:18 +000015#include "llvm/Transforms/IPO/PartialInlining.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000016#include "llvm/ADT/Statistic.h"
Sean Silvaf8015752016-08-02 02:15:45 +000017#include "llvm/Analysis/BlockFrequencyInfo.h"
18#include "llvm/Analysis/BranchProbabilityInfo.h"
Xinliang David Li66bdfca2017-05-12 23:41:43 +000019#include "llvm/Analysis/CodeMetrics.h"
Xinliang David Li61338462017-05-02 02:44:14 +000020#include "llvm/Analysis/InlineCost.h"
Sean Silvaf8015752016-08-02 02:15:45 +000021#include "llvm/Analysis/LoopInfo.h"
Xinliang David Li15744ad2017-04-23 21:40:58 +000022#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
Xinliang David Li61338462017-05-02 02:44:14 +000023#include "llvm/Analysis/ProfileSummaryInfo.h"
24#include "llvm/Analysis/TargetLibraryInfo.h"
25#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruth1305dc32014-03-04 11:45:46 +000026#include "llvm/IR/CFG.h"
Xinliang David Li15744ad2017-04-23 21:40:58 +000027#include "llvm/IR/DiagnosticInfo.h"
Chandler Carruth5ad5f152014-01-13 09:26:24 +000028#include "llvm/IR/Dominators.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000029#include "llvm/IR/Instructions.h"
30#include "llvm/IR/Module.h"
Owen Anderson2f82e272009-06-14 08:26:32 +000031#include "llvm/Pass.h"
Easwaran Raman1832bf62016-06-27 16:50:18 +000032#include "llvm/Transforms/IPO.h"
Owen Anderson2f82e272009-06-14 08:26:32 +000033#include "llvm/Transforms/Utils/Cloning.h"
Chandler Carruth0fde0012012-05-04 10:18:49 +000034#include "llvm/Transforms/Utils/CodeExtractor.h"
Owen Anderson2f82e272009-06-14 08:26:32 +000035using namespace llvm;
36
Xinliang David Li15744ad2017-04-23 21:40:58 +000037#define DEBUG_TYPE "partial-inlining"
Chandler Carruth964daaa2014-04-22 02:55:47 +000038
Xinliang David Li61338462017-05-02 02:44:14 +000039STATISTIC(NumPartialInlined,
40 "Number of callsites functions partially inlined into.");
Owen Andersonbd6a2132009-06-15 20:50:26 +000041
Xinliang David Lidb8d09b2017-04-23 23:39:04 +000042// Command line option to disable partial-inlining. The default is false:
43static cl::opt<bool>
44 DisablePartialInlining("disable-partial-inlining", cl::init(false),
45 cl::Hidden, cl::desc("Disable partial ininling"));
Xinliang David Li66bdfca2017-05-12 23:41:43 +000046// This is an option used by testing:
47static cl::opt<bool> SkipCostAnalysis("skip-partial-inlining-cost-analysis",
48 cl::init(false), cl::ZeroOrMore,
49 cl::ReallyHidden,
50 cl::desc("Skip Cost Analysis"));
Xinliang David Lidb8d09b2017-04-23 23:39:04 +000051
Xinliang David Lid21601a2017-04-27 16:34:00 +000052static cl::opt<unsigned> MaxNumInlineBlocks(
53 "max-num-inline-blocks", cl::init(5), cl::Hidden,
54 cl::desc("Max Number of Blocks To be Partially Inlined"));
55
Xinliang David Lidb8d09b2017-04-23 23:39:04 +000056// Command line option to set the maximum number of partial inlining allowed
57// for the module. The default value of -1 means no limit.
58static cl::opt<int> MaxNumPartialInlining(
59 "max-partial-inlining", cl::init(-1), cl::Hidden, cl::ZeroOrMore,
60 cl::desc("Max number of partial inlining. The default is unlimited"));
61
Xinliang David Li66bdfca2017-05-12 23:41:43 +000062// Used only when PGO or user annotated branch data is absent. It is
63// the least value that is used to weigh the outline region. If BFI
64// produces larger value, the BFI value will be used.
65static cl::opt<int>
66 OutlineRegionFreqPercent("outline-region-freq-percent", cl::init(75),
67 cl::Hidden, cl::ZeroOrMore,
68 cl::desc("Relative frequency of outline region to "
69 "the entry block"));
70
Owen Anderson2f82e272009-06-14 08:26:32 +000071namespace {
Xinliang David Lid21601a2017-04-27 16:34:00 +000072
73struct FunctionOutliningInfo {
74 FunctionOutliningInfo()
75 : Entries(), ReturnBlock(nullptr), NonReturnBlock(nullptr),
76 ReturnBlockPreds() {}
77 // Returns the number of blocks to be inlined including all blocks
78 // in Entries and one return block.
79 unsigned GetNumInlinedBlocks() const { return Entries.size() + 1; }
80
81 // A set of blocks including the function entry that guard
82 // the region to be outlined.
83 SmallVector<BasicBlock *, 4> Entries;
84 // The return block that is not included in the outlined region.
85 BasicBlock *ReturnBlock;
86 // The dominating block of the region ot be outlined.
87 BasicBlock *NonReturnBlock;
88 // The set of blocks in Entries that that are predecessors to ReturnBlock
89 SmallVector<BasicBlock *, 4> ReturnBlockPreds;
90};
91
Sean Silvafe5abd52016-07-25 05:00:00 +000092struct PartialInlinerImpl {
Xinliang David Li61338462017-05-02 02:44:14 +000093 PartialInlinerImpl(
94 std::function<AssumptionCache &(Function &)> *GetAC,
95 std::function<TargetTransformInfo &(Function &)> *GTTI,
96 Optional<function_ref<BlockFrequencyInfo &(Function &)>> GBFI,
97 ProfileSummaryInfo *ProfSI)
98 : GetAssumptionCache(GetAC), GetTTI(GTTI), GetBFI(GBFI), PSI(ProfSI) {}
Sean Silvafe5abd52016-07-25 05:00:00 +000099 bool run(Module &M);
100 Function *unswitchFunction(Function *F);
101
102private:
Xinliang David Lidb8d09b2017-04-23 23:39:04 +0000103 int NumPartialInlining = 0;
Xinliang David Li61338462017-05-02 02:44:14 +0000104 std::function<AssumptionCache &(Function &)> *GetAssumptionCache;
105 std::function<TargetTransformInfo &(Function &)> *GetTTI;
106 Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI;
107 ProfileSummaryInfo *PSI;
Xinliang David Lidb8d09b2017-04-23 23:39:04 +0000108
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000109 // Return the frequency of the OutlininingBB relative to F's entry point.
110 // The result is no larger than 1 and is represented using BP.
111 // (Note that the outlined region's 'head' block can only have incoming
112 // edges from the guarding entry blocks).
113 BranchProbability getOutliningCallBBRelativeFreq(Function *F,
114 FunctionOutliningInfo *OI,
115 Function *DuplicateFunction,
116 BlockFrequencyInfo *BFI,
117 BasicBlock *OutliningCallBB);
118
119 // Return true if the callee of CS should be partially inlined with
120 // profit.
121 bool shouldPartialInline(CallSite CS, Function *F, FunctionOutliningInfo *OI,
122 BlockFrequencyInfo *CalleeBFI,
123 BasicBlock *OutliningCallBB,
124 int OutliningCallOverhead,
125 OptimizationRemarkEmitter &ORE);
126
127 // Try to inline DuplicateFunction (cloned from F with call to
128 // the OutlinedFunction into its callers. Return true
129 // if there is any successful inlining.
130 bool tryPartialInline(Function *DuplicateFunction,
131 Function *F, /*orignal function */
132 FunctionOutliningInfo *OI, Function *OutlinedFunction,
133 BlockFrequencyInfo *CalleeBFI);
134
135 // Compute the mapping from use site of DuplicationFunction to the enclosing
136 // BB's profile count.
137 void computeCallsiteToProfCountMap(Function *DuplicateFunction,
138 DenseMap<User *, uint64_t> &SiteCountMap);
139
Xinliang David Lidb8d09b2017-04-23 23:39:04 +0000140 bool IsLimitReached() {
141 return (MaxNumPartialInlining != -1 &&
142 NumPartialInlining >= MaxNumPartialInlining);
143 }
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000144
145 CallSite getCallSite(User *U) {
146 CallSite CS;
147 if (CallInst *CI = dyn_cast<CallInst>(U))
148 CS = CallSite(CI);
149 else if (InvokeInst *II = dyn_cast<InvokeInst>(U))
150 CS = CallSite(II);
151 else
152 llvm_unreachable("All uses must be calls");
153 return CS;
154 }
155
156 CallSite getOneCallSiteTo(Function *F) {
157 User *User = *F->user_begin();
158 return getCallSite(User);
159 }
160
161 std::tuple<DebugLoc, BasicBlock *> getOneDebugLoc(Function *F) {
162 CallSite CS = getOneCallSiteTo(F);
163 DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
164 BasicBlock *Block = CS.getParent();
165 return std::make_tuple(DLoc, Block);
166 }
167
168 // Returns the costs associated with function outlining:
169 // - The first value is the non-weighted runtime cost for making the call
170 // to the outlined function 'OutlinedFunction', including the addtional
171 // setup cost in the outlined function itself;
172 // - The second value is the estimated size of the new call sequence in
173 // basic block 'OutliningCallBB';
174 // - The third value is the estimated size of the original code from
175 // function 'F' that is extracted into the outlined function.
176 std::tuple<int, int, int>
177 computeOutliningCosts(Function *F, const FunctionOutliningInfo *OutliningInfo,
178 Function *OutlinedFunction,
179 BasicBlock *OutliningCallBB);
180 // Compute the 'InlineCost' of block BB. InlineCost is a proxy used to
181 // approximate both the size and runtime cost (Note that in the current
182 // inline cost analysis, there is no clear distinction there either).
183 int computeBBInlineCost(BasicBlock *BB);
184
185 std::unique_ptr<FunctionOutliningInfo> computeOutliningInfo(Function *F);
186
Sean Silvafe5abd52016-07-25 05:00:00 +0000187};
Xinliang David Lid21601a2017-04-27 16:34:00 +0000188
Easwaran Raman1832bf62016-06-27 16:50:18 +0000189struct PartialInlinerLegacyPass : public ModulePass {
190 static char ID; // Pass identification, replacement for typeid
191 PartialInlinerLegacyPass() : ModulePass(ID) {
192 initializePartialInlinerLegacyPassPass(*PassRegistry::getPassRegistry());
193 }
Craig Topper3e4c6972014-03-05 09:10:37 +0000194
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000195 void getAnalysisUsage(AnalysisUsage &AU) const override {
196 AU.addRequired<AssumptionCacheTracker>();
Xinliang David Li61338462017-05-02 02:44:14 +0000197 AU.addRequired<ProfileSummaryInfoWrapperPass>();
198 AU.addRequired<TargetTransformInfoWrapperPass>();
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000199 }
Easwaran Raman1832bf62016-06-27 16:50:18 +0000200 bool runOnModule(Module &M) override {
201 if (skipModule(M))
202 return false;
Craig Topper3e4c6972014-03-05 09:10:37 +0000203
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000204 AssumptionCacheTracker *ACT = &getAnalysis<AssumptionCacheTracker>();
Xinliang David Li61338462017-05-02 02:44:14 +0000205 TargetTransformInfoWrapperPass *TTIWP =
206 &getAnalysis<TargetTransformInfoWrapperPass>();
207 ProfileSummaryInfo *PSI =
208 getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
209
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000210 std::function<AssumptionCache &(Function &)> GetAssumptionCache =
211 [&ACT](Function &F) -> AssumptionCache & {
212 return ACT->getAssumptionCache(F);
213 };
Xinliang David Li61338462017-05-02 02:44:14 +0000214
215 std::function<TargetTransformInfo &(Function &)> GetTTI =
216 [&TTIWP](Function &F) -> TargetTransformInfo & {
217 return TTIWP->getTTI(F);
218 };
219
220 return PartialInlinerImpl(&GetAssumptionCache, &GetTTI, None, PSI).run(M);
Sean Silvafe5abd52016-07-25 05:00:00 +0000221 }
Sean Silva519323d2016-07-25 05:57:59 +0000222};
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000223}
Owen Anderson2f82e272009-06-14 08:26:32 +0000224
Xinliang David Lid21601a2017-04-27 16:34:00 +0000225std::unique_ptr<FunctionOutliningInfo>
226PartialInlinerImpl::computeOutliningInfo(Function *F) {
Sean Silva519323d2016-07-25 05:57:59 +0000227 BasicBlock *EntryBlock = &F->front();
228 BranchInst *BR = dyn_cast<BranchInst>(EntryBlock->getTerminator());
Owen Andersonf0081db2009-09-08 19:53:15 +0000229 if (!BR || BR->isUnconditional())
Xinliang David Lid21601a2017-04-27 16:34:00 +0000230 return std::unique_ptr<FunctionOutliningInfo>();
Sean Silvafe5abd52016-07-25 05:00:00 +0000231
Xinliang David Lid21601a2017-04-27 16:34:00 +0000232 // Returns true if Succ is BB's successor
233 auto IsSuccessor = [](BasicBlock *Succ, BasicBlock *BB) {
234 return is_contained(successors(BB), Succ);
235 };
236
237 auto SuccSize = [](BasicBlock *BB) {
238 return std::distance(succ_begin(BB), succ_end(BB));
239 };
240
241 auto IsReturnBlock = [](BasicBlock *BB) {
242 TerminatorInst *TI = BB->getTerminator();
243 return isa<ReturnInst>(TI);
244 };
245
Davide Italianoaa42a102017-05-08 20:44:01 +0000246 auto GetReturnBlock = [&](BasicBlock *Succ1, BasicBlock *Succ2) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000247 if (IsReturnBlock(Succ1))
248 return std::make_tuple(Succ1, Succ2);
249 if (IsReturnBlock(Succ2))
250 return std::make_tuple(Succ2, Succ1);
251
252 return std::make_tuple<BasicBlock *, BasicBlock *>(nullptr, nullptr);
253 };
254
255 // Detect a triangular shape:
Davide Italianoaa42a102017-05-08 20:44:01 +0000256 auto GetCommonSucc = [&](BasicBlock *Succ1, BasicBlock *Succ2) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000257 if (IsSuccessor(Succ1, Succ2))
258 return std::make_tuple(Succ1, Succ2);
259 if (IsSuccessor(Succ2, Succ1))
260 return std::make_tuple(Succ2, Succ1);
261
262 return std::make_tuple<BasicBlock *, BasicBlock *>(nullptr, nullptr);
263 };
264
265 std::unique_ptr<FunctionOutliningInfo> OutliningInfo =
266 llvm::make_unique<FunctionOutliningInfo>();
267
268 BasicBlock *CurrEntry = EntryBlock;
269 bool CandidateFound = false;
270 do {
271 // The number of blocks to be inlined has already reached
272 // the limit. When MaxNumInlineBlocks is set to 0 or 1, this
273 // disables partial inlining for the function.
274 if (OutliningInfo->GetNumInlinedBlocks() >= MaxNumInlineBlocks)
275 break;
276
277 if (SuccSize(CurrEntry) != 2)
278 break;
279
280 BasicBlock *Succ1 = *succ_begin(CurrEntry);
281 BasicBlock *Succ2 = *(succ_begin(CurrEntry) + 1);
282
283 BasicBlock *ReturnBlock, *NonReturnBlock;
284 std::tie(ReturnBlock, NonReturnBlock) = GetReturnBlock(Succ1, Succ2);
285
286 if (ReturnBlock) {
287 OutliningInfo->Entries.push_back(CurrEntry);
288 OutliningInfo->ReturnBlock = ReturnBlock;
289 OutliningInfo->NonReturnBlock = NonReturnBlock;
290 CandidateFound = true;
291 break;
292 }
293
294 BasicBlock *CommSucc;
295 BasicBlock *OtherSucc;
296 std::tie(CommSucc, OtherSucc) = GetCommonSucc(Succ1, Succ2);
297
298 if (!CommSucc)
299 break;
300
301 OutliningInfo->Entries.push_back(CurrEntry);
302 CurrEntry = OtherSucc;
303
304 } while (true);
305
306 if (!CandidateFound)
307 return std::unique_ptr<FunctionOutliningInfo>();
308
309 // Do sanity check of the entries: threre should not
310 // be any successors (not in the entry set) other than
311 // {ReturnBlock, NonReturnBlock}
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000312 assert(OutliningInfo->Entries[0] == &F->front() &&
313 "Function Entry must be the first in Entries vector");
Xinliang David Lid21601a2017-04-27 16:34:00 +0000314 DenseSet<BasicBlock *> Entries;
315 for (BasicBlock *E : OutliningInfo->Entries)
316 Entries.insert(E);
317
318 // Returns true of BB has Predecessor which is not
319 // in Entries set.
320 auto HasNonEntryPred = [Entries](BasicBlock *BB) {
321 for (auto Pred : predecessors(BB)) {
322 if (!Entries.count(Pred))
323 return true;
324 }
325 return false;
326 };
327 auto CheckAndNormalizeCandidate =
328 [Entries, HasNonEntryPred](FunctionOutliningInfo *OutliningInfo) {
329 for (BasicBlock *E : OutliningInfo->Entries) {
330 for (auto Succ : successors(E)) {
331 if (Entries.count(Succ))
332 continue;
333 if (Succ == OutliningInfo->ReturnBlock)
334 OutliningInfo->ReturnBlockPreds.push_back(E);
335 else if (Succ != OutliningInfo->NonReturnBlock)
336 return false;
337 }
338 // There should not be any outside incoming edges either:
339 if (HasNonEntryPred(E))
340 return false;
341 }
342 return true;
343 };
344
345 if (!CheckAndNormalizeCandidate(OutliningInfo.get()))
346 return std::unique_ptr<FunctionOutliningInfo>();
347
348 // Now further growing the candidate's inlining region by
349 // peeling off dominating blocks from the outlining region:
350 while (OutliningInfo->GetNumInlinedBlocks() < MaxNumInlineBlocks) {
351 BasicBlock *Cand = OutliningInfo->NonReturnBlock;
352 if (SuccSize(Cand) != 2)
353 break;
354
355 if (HasNonEntryPred(Cand))
356 break;
357
358 BasicBlock *Succ1 = *succ_begin(Cand);
359 BasicBlock *Succ2 = *(succ_begin(Cand) + 1);
360
361 BasicBlock *ReturnBlock, *NonReturnBlock;
362 std::tie(ReturnBlock, NonReturnBlock) = GetReturnBlock(Succ1, Succ2);
363 if (!ReturnBlock || ReturnBlock != OutliningInfo->ReturnBlock)
364 break;
365
366 if (NonReturnBlock->getSinglePredecessor() != Cand)
367 break;
368
369 // Now grow and update OutlininigInfo:
370 OutliningInfo->Entries.push_back(Cand);
371 OutliningInfo->NonReturnBlock = NonReturnBlock;
372 OutliningInfo->ReturnBlockPreds.push_back(Cand);
373 Entries.insert(Cand);
Reid Klecknerc26a17a2015-02-04 19:14:57 +0000374 }
Sean Silvafe5abd52016-07-25 05:00:00 +0000375
Xinliang David Lid21601a2017-04-27 16:34:00 +0000376 return OutliningInfo;
377}
378
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000379// Check if there is PGO data or user annoated branch data:
380static bool hasProfileData(Function *F, FunctionOutliningInfo *OI) {
381 if (F->getEntryCount())
382 return true;
383 // Now check if any of the entry block has MD_prof data:
384 for (auto *E : OI->Entries) {
385 BranchInst *BR = dyn_cast<BranchInst>(E->getTerminator());
386 if (!BR || BR->isUnconditional())
387 continue;
388 uint64_t T, F;
389 if (BR->extractProfMetadata(T, F))
390 return true;
391 }
392 return false;
393}
394
395BranchProbability PartialInlinerImpl::getOutliningCallBBRelativeFreq(
396 Function *F, FunctionOutliningInfo *OI, Function *DuplicateFunction,
397 BlockFrequencyInfo *BFI, BasicBlock *OutliningCallBB) {
398
399 auto EntryFreq =
400 BFI->getBlockFreq(&DuplicateFunction->getEntryBlock());
401 auto OutliningCallFreq = BFI->getBlockFreq(OutliningCallBB);
402
403 auto OutlineRegionRelFreq =
404 BranchProbability::getBranchProbability(OutliningCallFreq.getFrequency(),
405 EntryFreq.getFrequency());
406
407 if (hasProfileData(F, OI))
408 return OutlineRegionRelFreq;
409
410 // When profile data is not available, we need to be very
411 // conservative in estimating the overall savings. We need to make sure
412 // the outline region relative frequency is not below the threshold
413 // specified by the option.
414 OutlineRegionRelFreq = std::max(OutlineRegionRelFreq, BranchProbability(OutlineRegionFreqPercent, 100));
415
416 return OutlineRegionRelFreq;
417}
418
419bool PartialInlinerImpl::shouldPartialInline(
420 CallSite CS, Function *F /* Original Callee */, FunctionOutliningInfo *OI,
421 BlockFrequencyInfo *CalleeBFI, BasicBlock *OutliningCallBB,
422 int NonWeightedOutliningRcost, OptimizationRemarkEmitter &ORE) {
Xinliang David Li61338462017-05-02 02:44:14 +0000423 using namespace ore;
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000424 if (SkipCostAnalysis)
425 return true;
426
Xinliang David Li61338462017-05-02 02:44:14 +0000427 Instruction *Call = CS.getInstruction();
428 Function *Callee = CS.getCalledFunction();
429 Function *Caller = CS.getCaller();
430 auto &CalleeTTI = (*GetTTI)(*Callee);
431 InlineCost IC = getInlineCost(CS, getInlineParams(), CalleeTTI,
432 *GetAssumptionCache, GetBFI, PSI);
433
434 if (IC.isAlways()) {
435 ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "AlwaysInline", Call)
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000436 << NV("Callee", F)
Xinliang David Li61338462017-05-02 02:44:14 +0000437 << " should always be fully inlined, not partially");
438 return false;
439 }
440
441 if (IC.isNever()) {
442 ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "NeverInline", Call)
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000443 << NV("Callee", F) << " not partially inlined into "
Xinliang David Li61338462017-05-02 02:44:14 +0000444 << NV("Caller", Caller)
445 << " because it should never be inlined (cost=never)");
446 return false;
447 }
448
449 if (!IC) {
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000450 ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "TooCostly", Call)
451 << NV("Callee", F) << " not partially inlined into "
Xinliang David Li61338462017-05-02 02:44:14 +0000452 << NV("Caller", Caller) << " because too costly to inline (cost="
453 << NV("Cost", IC.getCost()) << ", threshold="
454 << NV("Threshold", IC.getCostDelta() + IC.getCost()) << ")");
455 return false;
456 }
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000457 const DataLayout &DL = Caller->getParent()->getDataLayout();
458 // The savings of eliminating the call:
459 int NonWeightedSavings = getCallsiteCost(CS, DL);
460 BlockFrequency NormWeightedSavings(NonWeightedSavings);
461
462 auto RelativeFreq =
463 getOutliningCallBBRelativeFreq(F, OI, Callee, CalleeBFI, OutliningCallBB);
464 auto NormWeightedRcost =
465 BlockFrequency(NonWeightedOutliningRcost) * RelativeFreq;
466
467 // Weighted saving is smaller than weighted cost, return false
468 if (NormWeightedSavings < NormWeightedRcost) {
469 ORE.emit(
470 OptimizationRemarkAnalysis(DEBUG_TYPE, "OutliningCallcostTooHigh", Call)
471 << NV("Callee", F) << " not partially inlined into "
472 << NV("Caller", Caller) << " runtime overhead (overhead="
473 << NV("Overhead", (unsigned)NormWeightedRcost.getFrequency())
474 << ", savings="
475 << NV("Savings", (unsigned)NormWeightedSavings.getFrequency()) << ")"
476 << " of making the outlined call is too high");
477
478 return false;
479 }
Xinliang David Li61338462017-05-02 02:44:14 +0000480
481 ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "CanBePartiallyInlined", Call)
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000482 << NV("Callee", F) << " can be partially inlined into "
Xinliang David Li61338462017-05-02 02:44:14 +0000483 << NV("Caller", Caller) << " with cost=" << NV("Cost", IC.getCost())
484 << " (threshold="
485 << NV("Threshold", IC.getCostDelta() + IC.getCost()) << ")");
486 return true;
487}
488
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000489// TODO: Ideally we should share Inliner's InlineCost Analysis code.
490// For now use a simplified version. The returned 'InlineCost' will be used
491// to esimate the size cost as well as runtime cost of the BB.
492int PartialInlinerImpl::computeBBInlineCost(BasicBlock *BB) {
493 int InlineCost = 0;
494 const DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
495 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
496 if (isa<DbgInfoIntrinsic>(I))
497 continue;
498
499 if (CallInst *CI = dyn_cast<CallInst>(I)) {
500 InlineCost += getCallsiteCost(CallSite(CI), DL);
501 continue;
502 }
503
504 if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
505 InlineCost += getCallsiteCost(CallSite(II), DL);
506 continue;
507 }
508
509 if (SwitchInst *SI = dyn_cast<SwitchInst>(I)) {
510 InlineCost += (SI->getNumCases() + 1) * InlineConstants::InstrCost;
511 continue;
512 }
513 InlineCost += InlineConstants::InstrCost;
514 }
515 return InlineCost;
516}
517
518std::tuple<int, int, int> PartialInlinerImpl::computeOutliningCosts(
519 Function *F, const FunctionOutliningInfo *OI, Function *OutlinedFunction,
520 BasicBlock *OutliningCallBB) {
521 // First compute the cost of the outlined region 'OI' in the original
522 // function 'F':
523 int OutlinedRegionCost = 0;
524 for (BasicBlock &BB : *F) {
525 if (&BB != OI->ReturnBlock &&
526 // Assuming Entry set is small -- do a linear search here:
527 std::find(OI->Entries.begin(), OI->Entries.end(), &BB) ==
528 OI->Entries.end()) {
529 OutlinedRegionCost += computeBBInlineCost(&BB);
530 }
531 }
532
533 // Now compute the cost of the call sequence to the outlined function
534 // 'OutlinedFunction' in BB 'OutliningCallBB':
535 int OutliningFuncCallCost = computeBBInlineCost(OutliningCallBB);
536
537 // Now compute the cost of the extracted/outlined function itself:
538 int OutlinedFunctionCost = 0;
539 for (BasicBlock &BB : *OutlinedFunction) {
540 OutlinedFunctionCost += computeBBInlineCost(&BB);
541 }
542
543 assert(OutlinedFunctionCost >= OutlinedRegionCost &&
544 "Outlined function cost should be no less than the outlined region");
545 int OutliningRuntimeOverhead =
546 OutliningFuncCallCost + (OutlinedFunctionCost - OutlinedRegionCost);
547
548 return std::make_tuple(OutliningFuncCallCost, OutliningRuntimeOverhead,
549 OutlinedRegionCost);
550}
551
552// Create the callsite to profile count map which is
553// used to update the original function's entry count,
554// after the function is partially inlined into the callsite.
555void PartialInlinerImpl::computeCallsiteToProfCountMap(
556 Function *DuplicateFunction,
557 DenseMap<User *, uint64_t> &CallSiteToProfCountMap) {
558 std::vector<User *> Users(DuplicateFunction->user_begin(),
559 DuplicateFunction->user_end());
560 Function *CurrentCaller = nullptr;
561 BlockFrequencyInfo *CurrentCallerBFI = nullptr;
562
563 auto ComputeCurrBFI = [&,this](Function *Caller) {
564 // For the old pass manager:
565 if (!GetBFI) {
566 if (CurrentCallerBFI)
567 delete CurrentCallerBFI;
568 DominatorTree DT(*Caller);
569 LoopInfo LI(DT);
570 BranchProbabilityInfo BPI(*Caller, LI);
571 CurrentCallerBFI = new BlockFrequencyInfo(*Caller, BPI, LI);
572 } else {
573 // New pass manager:
574 CurrentCallerBFI = &(*GetBFI)(*Caller);
575 }
576 };
577
578 for (User *User : Users) {
579 CallSite CS = getCallSite(User);
580 Function *Caller = CS.getCaller();
581 if (CurrentCaller != Caller) {
582 CurrentCaller = Caller;
583 ComputeCurrBFI(Caller);
584 } else {
585 assert(CurrentCallerBFI && "CallerBFI is not set");
586 }
587 BasicBlock *CallBB = CS.getInstruction()->getParent();
588 auto Count = CurrentCallerBFI->getBlockProfileCount(CallBB);
589 if (Count)
590 CallSiteToProfCountMap[User] = *Count;
591 else
592 CallSiteToProfCountMap[User] = 0;
593 }
594}
595
Xinliang David Lid21601a2017-04-27 16:34:00 +0000596Function *PartialInlinerImpl::unswitchFunction(Function *F) {
597
598 if (F->hasAddressTaken())
599 return nullptr;
600
Xinliang David Liab8722f2017-05-02 18:43:21 +0000601 // Let inliner handle it
602 if (F->hasFnAttribute(Attribute::AlwaysInline))
603 return nullptr;
604
605 if (F->hasFnAttribute(Attribute::NoInline))
606 return nullptr;
607
608 if (PSI->isFunctionEntryCold(F))
609 return nullptr;
610
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000611 if (F->user_begin() == F->user_end())
612 return nullptr;
Xinliang David Lid21601a2017-04-27 16:34:00 +0000613
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000614 std::unique_ptr<FunctionOutliningInfo> OI = computeOutliningInfo(F);
615
616 if (!OI)
Craig Topperf40110f2014-04-25 05:29:35 +0000617 return nullptr;
Sean Silvafe5abd52016-07-25 05:00:00 +0000618
Owen Anderson2f82e272009-06-14 08:26:32 +0000619 // Clone the function, so that we can hack away on it.
Rafael Espindola229e38f2010-10-13 01:36:30 +0000620 ValueToValueMapTy VMap;
Sean Silva519323d2016-07-25 05:57:59 +0000621 Function *DuplicateFunction = CloneFunction(F, VMap);
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000622 BasicBlock *NewReturnBlock = cast<BasicBlock>(VMap[OI->ReturnBlock]);
623 BasicBlock *NewNonReturnBlock = cast<BasicBlock>(VMap[OI->NonReturnBlock]);
Xinliang David Lid21601a2017-04-27 16:34:00 +0000624 DenseSet<BasicBlock *> NewEntries;
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000625 for (BasicBlock *BB : OI->Entries) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000626 NewEntries.insert(cast<BasicBlock>(VMap[BB]));
627 }
Sean Silvafe5abd52016-07-25 05:00:00 +0000628
Owen Anderson2f82e272009-06-14 08:26:32 +0000629 // Go ahead and update all uses to the duplicate, so that we can just
630 // use the inliner functionality when we're done hacking.
Sean Silva519323d2016-07-25 05:57:59 +0000631 F->replaceAllUsesWith(DuplicateFunction);
Sean Silvafe5abd52016-07-25 05:00:00 +0000632
Xinliang David Lid21601a2017-04-27 16:34:00 +0000633 auto getFirstPHI = [](BasicBlock *BB) {
634 BasicBlock::iterator I = BB->begin();
635 PHINode *FirstPhi = nullptr;
636 while (I != BB->end()) {
637 PHINode *Phi = dyn_cast<PHINode>(I);
638 if (!Phi)
639 break;
640 if (!FirstPhi) {
641 FirstPhi = Phi;
642 break;
643 }
644 }
645 return FirstPhi;
646 };
Owen Anderson2f82e272009-06-14 08:26:32 +0000647 // Special hackery is needed with PHI nodes that have inputs from more than
648 // one extracted block. For simplicity, just split the PHIs into a two-level
649 // sequence of PHIs, some of which will go in the extracted region, and some
650 // of which will go outside.
Sean Silva519323d2016-07-25 05:57:59 +0000651 BasicBlock *PreReturn = NewReturnBlock;
Xinliang David Lid21601a2017-04-27 16:34:00 +0000652 // only split block when necessary:
653 PHINode *FirstPhi = getFirstPHI(PreReturn);
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000654 unsigned NumPredsFromEntries = OI->ReturnBlockPreds.size();
Xinliang David Lid21601a2017-04-27 16:34:00 +0000655 if (FirstPhi && FirstPhi->getNumIncomingValues() > NumPredsFromEntries + 1) {
Duncan P. N. Exon Smith17323402015-10-13 17:51:03 +0000656
Xinliang David Lid21601a2017-04-27 16:34:00 +0000657 NewReturnBlock = NewReturnBlock->splitBasicBlock(
658 NewReturnBlock->getFirstNonPHI()->getIterator());
659 BasicBlock::iterator I = PreReturn->begin();
660 Instruction *Ins = &NewReturnBlock->front();
661 while (I != PreReturn->end()) {
662 PHINode *OldPhi = dyn_cast<PHINode>(I);
663 if (!OldPhi)
664 break;
Duncan P. N. Exon Smith17323402015-10-13 17:51:03 +0000665
Xinliang David Lid21601a2017-04-27 16:34:00 +0000666 PHINode *RetPhi =
667 PHINode::Create(OldPhi->getType(), NumPredsFromEntries + 1, "", Ins);
668 OldPhi->replaceAllUsesWith(RetPhi);
669 Ins = NewReturnBlock->getFirstNonPHI();
Sean Silvafe5abd52016-07-25 05:00:00 +0000670
Xinliang David Lid21601a2017-04-27 16:34:00 +0000671 RetPhi->addIncoming(&*I, PreReturn);
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000672 for (BasicBlock *E : OI->ReturnBlockPreds) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000673 BasicBlock *NewE = cast<BasicBlock>(VMap[E]);
674 RetPhi->addIncoming(OldPhi->getIncomingValueForBlock(NewE), NewE);
675 OldPhi->removeIncomingValue(NewE);
676 }
677 ++I;
678 }
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000679 for (auto E : OI->ReturnBlockPreds) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000680 BasicBlock *NewE = cast<BasicBlock>(VMap[E]);
681 NewE->getTerminator()->replaceUsesOfWith(PreReturn, NewReturnBlock);
682 }
Owen Anderson2f82e272009-06-14 08:26:32 +0000683 }
Sean Silvafe5abd52016-07-25 05:00:00 +0000684
Xinliang David Lid21601a2017-04-27 16:34:00 +0000685 // Returns true if the block is to be partial inlined into the caller
686 // (i.e. not to be extracted to the out of line function)
Davide Italianoaa42a102017-05-08 20:44:01 +0000687 auto ToBeInlined = [&](BasicBlock *BB) {
Xinliang David Lid21601a2017-04-27 16:34:00 +0000688 return BB == NewReturnBlock || NewEntries.count(BB);
689 };
Owen Anderson2f82e272009-06-14 08:26:32 +0000690 // Gather up the blocks that we're going to extract.
Sean Silva519323d2016-07-25 05:57:59 +0000691 std::vector<BasicBlock *> ToExtract;
692 ToExtract.push_back(NewNonReturnBlock);
693 for (BasicBlock &BB : *DuplicateFunction)
Xinliang David Lid21601a2017-04-27 16:34:00 +0000694 if (!ToBeInlined(&BB) && &BB != NewNonReturnBlock)
Sean Silva519323d2016-07-25 05:57:59 +0000695 ToExtract.push_back(&BB);
Duncan P. N. Exon Smith17323402015-10-13 17:51:03 +0000696
Owen Anderson2f82e272009-06-14 08:26:32 +0000697 // The CodeExtractor needs a dominator tree.
698 DominatorTree DT;
Sean Silva519323d2016-07-25 05:57:59 +0000699 DT.recalculate(*DuplicateFunction);
Chandler Carruth73523022014-01-13 13:07:17 +0000700
Sean Silvaf8015752016-08-02 02:15:45 +0000701 // Manually calculate a BlockFrequencyInfo and BranchProbabilityInfo.
702 LoopInfo LI(DT);
703 BranchProbabilityInfo BPI(*DuplicateFunction, LI);
704 BlockFrequencyInfo BFI(*DuplicateFunction, BPI, LI);
705
Dan Gohman4a618822010-02-10 16:03:48 +0000706 // Extract the body of the if.
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000707 Function *OutlinedFunction =
Sean Silvaf8015752016-08-02 02:15:45 +0000708 CodeExtractor(ToExtract, &DT, /*AggregateArgs*/ false, &BFI, &BPI)
709 .extractCodeRegion();
Sean Silvafe5abd52016-07-25 05:00:00 +0000710
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000711 bool AnyInline =
712 tryPartialInline(DuplicateFunction, F, OI.get(), OutlinedFunction, &BFI);
Sean Silvafe5abd52016-07-25 05:00:00 +0000713
Owen Anderson2f82e272009-06-14 08:26:32 +0000714 // Ditch the duplicate, since we're done with it, and rewrite all remaining
715 // users (function pointers, etc.) back to the original function.
Sean Silva519323d2016-07-25 05:57:59 +0000716 DuplicateFunction->replaceAllUsesWith(F);
717 DuplicateFunction->eraseFromParent();
Xinliang David Li392e9752017-05-14 02:54:02 +0000718
719 if (AnyInline)
720 return OutlinedFunction;
721
722 // Remove the function that is speculatively created:
723 if (OutlinedFunction)
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000724 OutlinedFunction->eraseFromParent();
Xinliang David Li392e9752017-05-14 02:54:02 +0000725
726 return nullptr;
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000727}
Sean Silvafe5abd52016-07-25 05:00:00 +0000728
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000729bool PartialInlinerImpl::tryPartialInline(Function *DuplicateFunction,
730 Function *F,
731 FunctionOutliningInfo *OI,
732 Function *OutlinedFunction,
733 BlockFrequencyInfo *CalleeBFI) {
734 if (OutlinedFunction == nullptr)
735 return false;
Sean Silvafe5abd52016-07-25 05:00:00 +0000736
Xinliang David Li66bdfca2017-05-12 23:41:43 +0000737 int NonWeightedRcost;
738 int SizeCost;
739 int OutlinedRegionSizeCost;
740
741 auto OutliningCallBB =
742 getOneCallSiteTo(OutlinedFunction).getInstruction()->getParent();
743
744 std::tie(SizeCost, NonWeightedRcost, OutlinedRegionSizeCost) =
745 computeOutliningCosts(F, OI, OutlinedFunction, OutliningCallBB);
746
747 // The call sequence to the outlined function is larger than the original
748 // outlined region size, it does not increase the chances of inlining
749 // 'F' with outlining (The inliner usies the size increase to model the
750 // the cost of inlining a callee).
751 if (!SkipCostAnalysis && OutlinedRegionSizeCost < SizeCost) {
752 OptimizationRemarkEmitter ORE(F);
753 DebugLoc DLoc;
754 BasicBlock *Block;
755 std::tie(DLoc, Block) = getOneDebugLoc(DuplicateFunction);
756 ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "OutlineRegionTooSmall",
757 DLoc, Block)
758 << ore::NV("Function", F)
759 << " not partially inlined into callers (Original Size = "
760 << ore::NV("OutlinedRegionOriginalSize", OutlinedRegionSizeCost)
761 << ", Size of call sequence to outlined function = "
762 << ore::NV("NewSize", SizeCost) << ")");
763 return false;
764 }
765
766 assert(F->user_begin() == F->user_end() &&
767 "F's users should all be replaced!");
768 std::vector<User *> Users(DuplicateFunction->user_begin(),
769 DuplicateFunction->user_end());
770
771 DenseMap<User *, uint64_t> CallSiteToProfCountMap;
772 if (F->getEntryCount())
773 computeCallsiteToProfCountMap(DuplicateFunction, CallSiteToProfCountMap);
774
775 auto CalleeEntryCount = F->getEntryCount();
776 uint64_t CalleeEntryCountV = (CalleeEntryCount ? *CalleeEntryCount : 0);
777 bool AnyInline = false;
778 for (User *User : Users) {
779 CallSite CS = getCallSite(User);
780
781 if (IsLimitReached())
782 continue;
783
784 OptimizationRemarkEmitter ORE(CS.getCaller());
785
786 if (!shouldPartialInline(CS, F, OI, CalleeBFI, OutliningCallBB,
787 NonWeightedRcost, ORE))
788 continue;
789
790 ORE.emit(
791 OptimizationRemark(DEBUG_TYPE, "PartiallyInlined", CS.getInstruction())
792 << ore::NV("Callee", F) << " partially inlined into "
793 << ore::NV("Caller", CS.getCaller()));
794
795 InlineFunctionInfo IFI(nullptr, GetAssumptionCache, PSI);
796 InlineFunction(CS, IFI);
797
798 // Now update the entry count:
799 if (CalleeEntryCountV && CallSiteToProfCountMap.count(User)) {
800 uint64_t CallSiteCount = CallSiteToProfCountMap[User];
801 CalleeEntryCountV -= std::min(CalleeEntryCountV, CallSiteCount);
802 }
803
804 AnyInline = true;
805 NumPartialInlining++;
806 // Update the stats
807 NumPartialInlined++;
808 }
809
810 if (AnyInline && CalleeEntryCount)
811 F->setEntryCount(CalleeEntryCountV);
812
813 return AnyInline;
Owen Anderson2f82e272009-06-14 08:26:32 +0000814}
815
Sean Silvafe5abd52016-07-25 05:00:00 +0000816bool PartialInlinerImpl::run(Module &M) {
Xinliang David Lidb8d09b2017-04-23 23:39:04 +0000817 if (DisablePartialInlining)
818 return false;
819
Sean Silva519323d2016-07-25 05:57:59 +0000820 std::vector<Function *> Worklist;
821 Worklist.reserve(M.size());
Benjamin Kramer135f7352016-06-26 12:28:59 +0000822 for (Function &F : M)
823 if (!F.use_empty() && !F.isDeclaration())
Sean Silva519323d2016-07-25 05:57:59 +0000824 Worklist.push_back(&F);
Benjamin Kramer135f7352016-06-26 12:28:59 +0000825
Sean Silva519323d2016-07-25 05:57:59 +0000826 bool Changed = false;
827 while (!Worklist.empty()) {
828 Function *CurrFunc = Worklist.back();
829 Worklist.pop_back();
Sean Silvafe5abd52016-07-25 05:00:00 +0000830
Sean Silva519323d2016-07-25 05:57:59 +0000831 if (CurrFunc->use_empty())
832 continue;
Sean Silvafe5abd52016-07-25 05:00:00 +0000833
Sean Silva519323d2016-07-25 05:57:59 +0000834 bool Recursive = false;
835 for (User *U : CurrFunc->users())
836 if (Instruction *I = dyn_cast<Instruction>(U))
837 if (I->getParent()->getParent() == CurrFunc) {
838 Recursive = true;
Owen Anderson2f82e272009-06-14 08:26:32 +0000839 break;
840 }
Sean Silva519323d2016-07-25 05:57:59 +0000841 if (Recursive)
842 continue;
Sean Silvafe5abd52016-07-25 05:00:00 +0000843
Sean Silvaf8015752016-08-02 02:15:45 +0000844 if (Function *NewFunc = unswitchFunction(CurrFunc)) {
845 Worklist.push_back(NewFunc);
Sean Silva519323d2016-07-25 05:57:59 +0000846 Changed = true;
Owen Anderson2f82e272009-06-14 08:26:32 +0000847 }
Owen Anderson2f82e272009-06-14 08:26:32 +0000848 }
Easwaran Raman1832bf62016-06-27 16:50:18 +0000849
Sean Silva519323d2016-07-25 05:57:59 +0000850 return Changed;
Sean Silvafe5abd52016-07-25 05:00:00 +0000851}
852
853char PartialInlinerLegacyPass::ID = 0;
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000854INITIALIZE_PASS_BEGIN(PartialInlinerLegacyPass, "partial-inliner",
855 "Partial Inliner", false, false)
856INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
Xinliang David Li61338462017-05-02 02:44:14 +0000857INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)
858INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000859INITIALIZE_PASS_END(PartialInlinerLegacyPass, "partial-inliner",
860 "Partial Inliner", false, false)
Sean Silvafe5abd52016-07-25 05:00:00 +0000861
862ModulePass *llvm::createPartialInliningPass() {
863 return new PartialInlinerLegacyPass();
864}
865
866PreservedAnalyses PartialInlinerPass::run(Module &M,
867 ModuleAnalysisManager &AM) {
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000868 auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
Xinliang David Li61338462017-05-02 02:44:14 +0000869
Daniel Jasperaec2fa32016-12-19 08:22:17 +0000870 std::function<AssumptionCache &(Function &)> GetAssumptionCache =
871 [&FAM](Function &F) -> AssumptionCache & {
872 return FAM.getResult<AssumptionAnalysis>(F);
873 };
Xinliang David Li61338462017-05-02 02:44:14 +0000874
875 std::function<BlockFrequencyInfo &(Function &)> GetBFI =
876 [&FAM](Function &F) -> BlockFrequencyInfo & {
877 return FAM.getResult<BlockFrequencyAnalysis>(F);
878 };
879
880 std::function<TargetTransformInfo &(Function &)> GetTTI =
881 [&FAM](Function &F) -> TargetTransformInfo & {
882 return FAM.getResult<TargetIRAnalysis>(F);
883 };
884
885 ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
886
887 if (PartialInlinerImpl(&GetAssumptionCache, &GetTTI, {GetBFI}, PSI).run(M))
Easwaran Raman1832bf62016-06-27 16:50:18 +0000888 return PreservedAnalyses::none();
889 return PreservedAnalyses::all();
Duncan Sands29c8efc2009-07-03 15:30:58 +0000890}