3535#include " llvm/Transforms/Utils/ModuleUtils.h"
3636#include " llvm/Transforms/Utils/PromoteMemToReg.h"
3737
38-
3938using namespace llvm ;
4039
4140#define DEBUG_TYPE " inline"
@@ -53,35 +52,36 @@ bool canInlineCallBase(CallBase *CB) {
5352 !CB->getAttributes ().hasFnAttr (Attribute::NoInline);
5453}
5554
56- bool attemptInlineFunction (
57- Function &F, CallBase *CB, bool InsertLifetime,
58- function_ref<AAResults &(Function &)> &GetAAR,
59- function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
60- ProfileSummaryInfo &PSI) {
61- Function *Caller = CB->getCaller ();
62- OptimizationRemarkEmitter ORE (Caller);
63- DebugLoc DLoc = CB->getDebugLoc ();
64- BasicBlock *Block = CB->getParent ();
65-
66- InlineFunctionInfo IFI (GetAssumptionCache, &PSI, nullptr , nullptr );
67- InlineResult Res = InlineFunction (*CB, IFI, /* MergeAttributes=*/ true ,
68- &GetAAR (F), InsertLifetime);
69- if (!Res.isSuccess ()) {
70- ORE.emit ([&]() {
71- return OptimizationRemarkMissed (DEBUG_TYPE, " NotInlined" , DLoc, Block)
72- << " '" << ore::NV (" Callee" , &F) << " ' is not inlined into '"
73- << ore::NV (" Caller" , Caller)
74- << " ': " << ore::NV (" Reason" , Res.getFailureReason ());
75- });
76- return false ;
77- }
55+ bool attemptInlineFunction (
56+ Function &F, CallBase *CB, bool InsertLifetime,
57+ function_ref<AAResults &(Function &)> &GetAAR,
58+ function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
59+ ProfileSummaryInfo &PSI) {
60+ Function *Caller = CB->getCaller ();
61+ OptimizationRemarkEmitter ORE (Caller);
62+ DebugLoc DLoc = CB->getDebugLoc ();
63+ BasicBlock *Block = CB->getParent ();
64+
65+ InlineFunctionInfo IFI (GetAssumptionCache, &PSI, nullptr , nullptr );
66+ InlineResult Res = InlineFunction (*CB, IFI, /* MergeAttributes=*/ true ,
67+ &GetAAR (F), InsertLifetime);
68+ if (!Res.isSuccess ()) {
69+ ORE.emit ([&]() {
70+ return OptimizationRemarkMissed (DEBUG_TYPE, " NotInlined" , DLoc, Block)
71+ << " '" << ore::NV (" Callee" , &F) << " ' is not inlined into '"
72+ << ore::NV (" Caller" , Caller)
73+ << " ': " << ore::NV (" Reason" , Res.getFailureReason ());
74+ });
75+ return false ;
76+ }
7877
79- emitInlinedIntoBasedOnCost (ORE, DLoc, Block, F, *Caller,
80- InlineCost::getAlways (" always inline attribute" ),
81- /* ForProfileContext=*/ false , DEBUG_TYPE);
78+ emitInlinedIntoBasedOnCost (ORE, DLoc, Block, F, *Caller,
79+ InlineCost::getAlways (" always inline attribute" ),
80+ /* ForProfileContext=*/ false , DEBUG_TYPE);
81+
82+ return true ;
83+ }
8284
83- return true ;
84- }
8585// / This function inlines all functions that are marked with the always_inline
8686// / attribute. It also removes the inlined functions if they are dead after the
8787// / inlining process.
@@ -385,7 +385,6 @@ bool AlwaysInlineInterleavedMem2RegImpl(
385385 return Changed;
386386}
387387
388-
389388struct AlwaysInlinerLegacyPass : public ModulePass {
390389 bool InsertLifetime;
391390
0 commit comments