LLVM  16.0.0git
Macros | Typedefs | Functions | Variables
InlineFunction.cpp File Reference
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/EHPersonalities.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryProfileInfo.h"
#include "llvm/Analysis/ObjCARCAnalysisUtils.h"
#include "llvm/Analysis/ObjCARCUtil.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <limits>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "inline-function"
 
#define DEBUG_TYPE   "assignment-tracking"
 
#define DEBUG_TYPE   "inline-function"
 

Typedefs

using ProfileCount = Function::ProfileCount
 
using UnwindDestMemoTy = DenseMap< Instruction *, Value * >
 

Functions

static ValuegetParentPad (Value *EHPad)
 Helper for getUnwindDestToken/getUnwindDestTokenHelper. More...
 
static ValuegetUnwindDestTokenHelper (Instruction *EHPad, UnwindDestMemoTy &MemoMap)
 Helper for getUnwindDestToken that does the descendant-ward part of the search. More...
 
static ValuegetUnwindDestToken (Instruction *EHPad, UnwindDestMemoTy &MemoMap)
 Given an EH pad, find where it unwinds. More...
 
static BasicBlockHandleCallsInBlockInlinedThroughInvoke (BasicBlock *BB, BasicBlock *UnwindEdge, UnwindDestMemoTy *FuncletUnwindMap=nullptr)
 When we inline a basic block into an invoke, we have to turn all of the calls that can throw into invokes. More...
 
static void HandleInlinedLandingPad (InvokeInst *II, BasicBlock *FirstNewBlock, ClonedCodeInfo &InlinedCodeInfo)
 If we inlined an invoke site, we need to convert calls in the body of the inlined function into invokes. More...
 
static void HandleInlinedEHPad (InvokeInst *II, BasicBlock *FirstNewBlock, ClonedCodeInfo &InlinedCodeInfo)
 If we inlined an invoke site, we need to convert calls in the body of the inlined function into invokes. More...
 
static bool haveCommonPrefix (MDNode *MIBStackContext, MDNode *CallsiteStackContext)
 
static void removeMemProfMetadata (CallBase *Call)
 
static void removeCallsiteMetadata (CallBase *Call)
 
static void updateMemprofMetadata (CallBase *CI, const std::vector< Metadata * > &MIBList)
 
static void propagateMemProfHelper (const CallBase *OrigCall, CallBase *ClonedCall, MDNode *InlinedCallsiteMD, std::map< const CallBase *, std::vector< Metadata * >> &OrigCallToNewMemProfMDMap)
 
static void propagateMemProfMetadata (Function *Callee, CallBase &CB, bool ContainsMemProfMetadata, const ValueMap< const Value *, WeakTrackingVH > &VMap)
 
static void PropagateCallSiteMetadata (CallBase &CB, Function::iterator FStart, Function::iterator FEnd)
 When inlining a call site that has !llvm.mem.parallel_loop_access, !llvm.access.group, !alias.scope or !noalias metadata, that metadata should be propagated to all memory-accessing cloned instructions. More...
 
static void PropagateOperandBundles (Function::iterator InlinedBB, Instruction *CallSiteEHPad)
 Bundle operands of the inlined function must be added to inlined call sites. More...
 
static void AddAliasScopeMetadata (CallBase &CB, ValueToValueMapTy &VMap, const DataLayout &DL, AAResults *CalleeAAR, ClonedCodeInfo &InlinedFunctionInfo)
 If the inlined function has noalias arguments, then add new alias scopes for each noalias argument, tag the mapped noalias parameters with noalias metadata specifying the new scope, and tag all non-derived loads, stores and memory intrinsics with the new alias scopes. More...
 
static bool MayContainThrowingOrExitingCall (Instruction *Begin, Instruction *End)
 
static AttrBuilder IdentifyValidAttributes (CallBase &CB)
 
static void AddReturnAttributes (CallBase &CB, ValueToValueMapTy &VMap)
 
static void AddAlignmentAssumptions (CallBase &CB, InlineFunctionInfo &IFI)
 If the inlined function has non-byval align arguments, then add @llvm.assume-based alignment assumptions to preserve this information. More...
 
static void UpdateCallGraphAfterInlining (CallBase &CB, Function::iterator FirstNewBlock, ValueToValueMapTy &VMap, InlineFunctionInfo &IFI)
 Once we have cloned code over from a callee into the caller, update the specified callgraph to reflect the changes we made. More...
 
static void HandleByValArgumentInit (Type *ByValType, Value *Dst, Value *Src, Module *M, BasicBlock *InsertBlock, InlineFunctionInfo &IFI)
 
static ValueHandleByValArgument (Type *ByValType, Value *Arg, Instruction *TheCall, const Function *CalledFunc, InlineFunctionInfo &IFI, unsigned ByValAlignment)
 When inlining a call site that has a byval argument, we have to make the implicit memcpy explicit by adding it. More...
 
static bool isUsedByLifetimeMarker (Value *V)
 
static bool hasLifetimeMarkers (AllocaInst *AI)
 
static bool allocaWouldBeStaticInEntry (const AllocaInst *AI)
 Return the result of AI->isStaticAlloca() if AI were moved to the entry block. More...
 
static DebugLoc inlineDebugLoc (DebugLoc OrigDL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &IANodes)
 Returns a DebugLoc for a new DILocation which is a clone of OrigDL inlined at InlinedAt. More...
 
static void fixupLineNumbers (Function *Fn, Function::iterator FI, Instruction *TheCall, bool CalleeHasDebugInfo)
 Update inlined instructions' line numbers to to encode location where these instructions are inlined. More...
 
static at::StorageToVarsMap collectEscapedLocals (const DataLayout &DL, const CallBase &CB)
 Find Alloca and linked DbgAssignIntrinsic for locals escaped by CB. More...
 
static void trackInlinedStores (Function::iterator Start, Function::iterator End, const CallBase &CB)
 
static void fixupAssignments (Function::iterator Start, Function::iterator End)
 Update inlined instructions' DIAssignID metadata. More...
 
static void updateCallerBFI (BasicBlock *CallSiteBlock, const ValueToValueMapTy &VMap, BlockFrequencyInfo *CallerBFI, BlockFrequencyInfo *CalleeBFI, const BasicBlock &CalleeEntryBlock)
 Update the block frequencies of the caller after a callee has been inlined. More...
 
static void updateCallProfile (Function *Callee, const ValueToValueMapTy &VMap, const ProfileCount &CalleeEntryCount, const CallBase &TheCall, ProfileSummaryInfo *PSI, BlockFrequencyInfo *CallerBFI)
 Update the branch metadata for cloned call instructions. More...
 
static void inlineRetainOrClaimRVCalls (CallBase &CB, objcarc::ARCInstKind RVCallKind, const SmallVectorImpl< ReturnInst * > &Returns)
 An operand bundle "clang.arc.attachedcall" on a call indicates the call result is implicitly consumed by a call to retainRV or claimRV immediately after the call. More...
 

Variables

static cl::opt< bool > EnableNoAliasConversion ("enable-noalias-to-md-conversion", cl::init(true), cl::Hidden, cl::desc("Convert noalias attributes to metadata during inlining."))
 
static cl::opt< bool > UseNoAliasIntrinsic ("use-noalias-intrinsic-during-inlining", cl::Hidden, cl::init(true), cl::desc("Use the llvm.experimental.noalias.scope.decl " "intrinsic during inlining."))
 
static cl::opt< bool > PreserveAlignmentAssumptions ("preserve-alignment-assumptions-during-inlining", cl::init(false), cl::Hidden, cl::desc("Convert align attributes to assumptions during inlining."))
 
static cl::opt< bool > UpdateReturnAttributes ("update-return-attrs", cl::init(true), cl::Hidden, cl::desc("Update return attributes on calls within inlined body"))
 
static cl::opt< unsigned > InlinerAttributeWindow ("max-inst-checked-for-throw-during-inlining", cl::Hidden, cl::desc("the maximum number of instructions analyzed for may throw during " "attribute inference in inlined body"), cl::init(4))
 

Macro Definition Documentation

◆ DEBUG_TYPE [1/3]

#define DEBUG_TYPE   "inline-function"

Definition at line 1856 of file InlineFunction.cpp.

◆ DEBUG_TYPE [2/3]

#define DEBUG_TYPE   "assignment-tracking"

Definition at line 1856 of file InlineFunction.cpp.

◆ DEBUG_TYPE [3/3]

#define DEBUG_TYPE   "inline-function"

Definition at line 1856 of file InlineFunction.cpp.

Typedef Documentation

◆ ProfileCount

Definition at line 82 of file InlineFunction.cpp.

◆ UnwindDestMemoTy

Definition at line 244 of file InlineFunction.cpp.

Function Documentation

◆ AddAliasScopeMetadata()

static void AddAliasScopeMetadata ( CallBase CB,
ValueToValueMapTy VMap,
const DataLayout DL,
AAResults CalleeAAR,
ClonedCodeInfo InlinedFunctionInfo 
)
static

If the inlined function has noalias arguments, then add new alias scopes for each noalias argument, tag the mapped noalias parameters with noalias metadata specifying the new scope, and tag all non-derived loads, stores and memory intrinsics with the new alias scopes.

Definition at line 1139 of file InlineFunction.cpp.

References Arg, llvm::Function::args(), llvm::ValueMap< KeyT, ValueT, Config >::begin(), llvm::MDNode::concatenate(), llvm::MDBuilder::createAnonymousAliasScope(), llvm::MDBuilder::createAnonymousAliasScopeDomain(), llvm::IRBuilderBase::CreateNoAliasScopeDeclaration(), llvm::numbers::e, EnableNoAliasConversion, llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::MDNode::get(), llvm::CallBase::getCalledFunction(), llvm::Function::getContext(), llvm::AAResults::getMemoryEffects(), llvm::Instruction::getMetadata(), llvm::Value::getName(), llvm::getUnderlyingObjects(), i, I, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isEscapeSource(), llvm::isIdentifiedObject(), llvm::ClonedCodeInfo::isSimplified(), NoAliases, llvm::RISCVFenceField::O, llvm::MemoryEffects::onlyAccessesArgPointees(), llvm::MemoryEffects::onlyAccessesInaccessibleMem(), llvm::CallBase::paramHasAttr(), llvm::PointerMayBeCapturedBefore(), llvm::DominatorTreeBase< NodeT, IsPostDom >::recalculate(), llvm::Instruction::setMetadata(), SI, and UseNoAliasIntrinsic.

Referenced by llvm::InlineFunction().

◆ AddAlignmentAssumptions()

static void AddAlignmentAssumptions ( CallBase CB,
InlineFunctionInfo IFI 
)
static

◆ AddReturnAttributes()

static void AddReturnAttributes ( CallBase CB,
ValueToValueMapTy VMap 
)
static

◆ allocaWouldBeStaticInEntry()

static bool allocaWouldBeStaticInEntry ( const AllocaInst AI)
static

Return the result of AI->isStaticAlloca() if AI were moved to the entry block.

Allocas used in inalloca calls and allocas of dynamic array size cannot be static.

Definition at line 1677 of file InlineFunction.cpp.

References llvm::AllocaInst::getArraySize(), and llvm::AllocaInst::isUsedWithInAlloca().

Referenced by fixupLineNumbers(), and llvm::InlineFunction().

◆ collectEscapedLocals()

static at::StorageToVarsMap collectEscapedLocals ( const DataLayout DL,
const CallBase CB 
)
static

◆ fixupAssignments()

static void fixupAssignments ( Function::iterator  Start,
Function::iterator  End 
)
static

Update inlined instructions' DIAssignID metadata.

We need to do this otherwise a function inlined more than once into the same function will cause DIAssignID to be shared by many instructions.

Definition at line 1833 of file InlineFunction.cpp.

Referenced by llvm::InlineFunction().

◆ fixupLineNumbers()

static void fixupLineNumbers ( Function Fn,
Function::iterator  FI,
Instruction TheCall,
bool  CalleeHasDebugInfo 
)
static

◆ getParentPad()

static Value* getParentPad ( Value EHPad)
static

Helper for getUnwindDestToken/getUnwindDestTokenHelper.

Definition at line 238 of file InlineFunction.cpp.

Referenced by getUnwindDestToken(), and getUnwindDestTokenHelper().

◆ getUnwindDestToken()

static Value* getUnwindDestToken ( Instruction EHPad,
UnwindDestMemoTy MemoMap 
)
static

Given an EH pad, find where it unwinds.

If it unwinds to an EH pad, return that pad instruction. If it unwinds to caller, return ConstantTokenNone. If it does not have a definitive unwind destination, return nullptr.

This routine gets invoked for calls in funclets in inlinees when inlining an invoke. Since many funclets don't have calls inside them, it's queried on-demand rather than building a map of pads to unwind dests up front. Determining a funclet's unwind dest may require recursively searching its descendants, and also ancestors and cousins if the descendants don't provide an answer. Since most funclets will have their unwind dest immediately available as the unwind dest of a catchswitch or cleanupret, this routine searches top-down from the given pad and then up. To avoid worst-case quadratic run-time given that approach, it uses a memo map to avoid re-processing funclet trees. The callers that rewrite the IR as they go take advantage of this, for correctness, by checking/forcing rewritten pads' entries to match the original callee view.

Definition at line 399 of file InlineFunction.cpp.

References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), getParentPad(), getUnwindDestTokenHelper(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::Value::users().

Referenced by HandleCallsInBlockInlinedThroughInvoke(), HandleInlinedEHPad(), and llvm::InlineFunction().

◆ getUnwindDestTokenHelper()

static Value* getUnwindDestTokenHelper ( Instruction EHPad,
UnwindDestMemoTy MemoMap 
)
static

◆ HandleByValArgument()

static Value* HandleByValArgument ( Type ByValType,
Value Arg,
Instruction TheCall,
const Function CalledFunc,
InlineFunctionInfo IFI,
unsigned  ByValAlignment 
)
static

When inlining a call site that has a byval argument, we have to make the implicit memcpy explicit by adding it.

Definition at line 1594 of file InlineFunction.cpp.

References Align, Arg, assert(), DL, llvm::InlineFunctionInfo::GetAssumptionCache, llvm::Instruction::getFunction(), llvm::getOrEnforceKnownAlignment(), llvm::max(), llvm::Function::onlyReadsMemory(), and llvm::InlineFunctionInfo::StaticAllocas.

Referenced by llvm::InlineFunction().

◆ HandleByValArgumentInit()

static void HandleByValArgumentInit ( Type ByValType,
Value Dst,
Value Src,
Module M,
BasicBlock InsertBlock,
InlineFunctionInfo IFI 
)
static

Definition at line 1577 of file InlineFunction.cpp.

References Align, llvm::BasicBlock::begin(), Builder, and M.

Referenced by llvm::InlineFunction().

◆ HandleCallsInBlockInlinedThroughInvoke()

static BasicBlock* HandleCallsInBlockInlinedThroughInvoke ( BasicBlock BB,
BasicBlock UnwindEdge,
UnwindDestMemoTy FuncletUnwindMap = nullptr 
)
static

When we inline a basic block into an invoke, we have to turn all of the calls that can throw into invokes.

This function analyze BB to see if there are any calls, and if so, it rewrites them to be invokes that jump to InvokeDest and fills in the PHI nodes in that block with the values specified in InvokeDestPHIValues.

Definition at line 543 of file InlineFunction.cpp.

References assert(), BB, llvm::changeToInvokeAndSplitBasicBlock(), llvm::CallBase::doesNotThrow(), F, llvm::CallBase::getCalledFunction(), llvm::CallBase::getCalledOperand(), llvm::CallBase::getOperandBundle(), getUnwindDestToken(), I, llvm::AArch64PACKey::IA, llvm::CallBase::isInlineAsm(), llvm::make_early_inc_range(), and llvm::LLVMContext::OB_funclet.

Referenced by HandleInlinedEHPad(), and HandleInlinedLandingPad().

◆ HandleInlinedEHPad()

static void HandleInlinedEHPad ( InvokeInst II,
BasicBlock FirstNewBlock,
ClonedCodeInfo InlinedCodeInfo 
)
static

◆ HandleInlinedLandingPad()

static void HandleInlinedLandingPad ( InvokeInst II,
BasicBlock FirstNewBlock,
ClonedCodeInfo InlinedCodeInfo 
)
static

If we inlined an invoke site, we need to convert calls in the body of the inlined function into invokes.

II is the invoke instruction being inlined. FirstNewBlock is the first block of the inlined code (the last block is the end of the function), and InlineCodeInfo is information about the code that got inlined.

Definition at line 609 of file InlineFunction.cpp.

References BB, llvm::ClonedCodeInfo::ContainsCalls, E, llvm::LandingPadInst::getClause(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::InvokeInst::getLandingPadInst(), llvm::LandingPadInst::getNumClauses(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::InvokeInst::getUnwindDest(), HandleCallsInBlockInlinedThroughInvoke(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LandingPadInst::isCleanup(), and llvm::BasicBlock::removePredecessor().

Referenced by llvm::InlineFunction().

◆ hasLifetimeMarkers()

static bool hasLifetimeMarkers ( AllocaInst AI)
static

◆ haveCommonPrefix()

static bool haveCommonPrefix ( MDNode MIBStackContext,
MDNode CallsiteStackContext 
)
static

◆ IdentifyValidAttributes()

static AttrBuilder IdentifyValidAttributes ( CallBase CB)
static

◆ inlineDebugLoc()

static DebugLoc inlineDebugLoc ( DebugLoc  OrigDL,
DILocation InlinedAt,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode * > &  IANodes 
)
static

Returns a DebugLoc for a new DILocation which is a clone of OrigDL inlined at InlinedAt.

IANodes is an inlined-at cache.

Definition at line 1683 of file InlineFunction.cpp.

References llvm::DebugLoc::appendInlinedAt(), llvm::MDNode::get(), llvm::DebugLoc::getCol(), llvm::DebugLoc::getLine(), llvm::DebugLoc::getScope(), and llvm::AArch64PACKey::IA.

Referenced by fixupLineNumbers().

◆ inlineRetainOrClaimRVCalls()

static void inlineRetainOrClaimRVCalls ( CallBase CB,
objcarc::ARCInstKind  RVCallKind,
const SmallVectorImpl< ReturnInst * > &  Returns 
)
static

An operand bundle "clang.arc.attachedcall" on a call indicates the call result is implicitly consumed by a call to retainRV or claimRV immediately after the call.

This function inlines the retainRV/claimRV calls.

There are three cases to consider:

  1. If there is a call to autoreleaseRV that takes a pointer to the returned object in the callee return block, the autoreleaseRV call and the retainRV/claimRV call in the caller cancel out. If the call in the caller is a claimRV call, a call to objc_release is emitted.
  2. If there is a call in the callee return block that doesn't have operand bundle "clang.arc.attachedcall", the operand bundle on the original call is transferred to the call in the callee.
  3. Otherwise, a call to objc_retain is inserted if the call in the caller is a retainRV call.

Definition at line 1960 of file InlineFunction.cpp.

References llvm::CallBase::addOperandBundle(), assert(), Builder, llvm::Instruction::eraseFromParent(), llvm::Function::getArg(), llvm::objcarc::getAttachedARCFunction(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::CallBase::getIntrinsicID(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getModule(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::objcarc::GetRCIdentityRoot(), llvm::ilist_iterator< OptionsT, IsReverse, IsConst >::getReverse(), llvm::Value::getType(), llvm::objcarc::hasAttachedCallOpBundle(), llvm::Value::hasNUses(), I, llvm::objcarc::isRetainOrClaimRV(), llvm::make_early_inc_range(), llvm::make_range(), Mod, llvm::X86II::OB, llvm::LLVMContext::OB_clang_arc_attachedcall, llvm::BasicBlock::rend(), and llvm::objcarc::RetainRV.

Referenced by llvm::InlineFunction().

◆ isUsedByLifetimeMarker()

static bool isUsedByLifetimeMarker ( Value V)
static

◆ MayContainThrowingOrExitingCall()

static bool MayContainThrowingOrExitingCall ( Instruction Begin,
Instruction End 
)
static

Definition at line 1383 of file InlineFunction.cpp.

Referenced by AddReturnAttributes().

◆ PropagateCallSiteMetadata()

static void PropagateCallSiteMetadata ( CallBase CB,
Function::iterator  FStart,
Function::iterator  FEnd 
)
static

When inlining a call site that has !llvm.mem.parallel_loop_access, !llvm.access.group, !alias.scope or !noalias metadata, that metadata should be propagated to all memory-accessing cloned instructions.

Definition at line 960 of file InlineFunction.cpp.

References BB, llvm::MDNode::concatenate(), llvm::Instruction::getMetadata(), I, llvm::make_range(), and llvm::uniteAccessGroups().

Referenced by llvm::InlineFunction().

◆ propagateMemProfHelper()

static void propagateMemProfHelper ( const CallBase OrigCall,
CallBase ClonedCall,
MDNode InlinedCallsiteMD,
std::map< const CallBase *, std::vector< Metadata * >> &  OrigCallToNewMemProfMDMap 
)
static

◆ propagateMemProfMetadata()

static void propagateMemProfMetadata ( Function Callee,
CallBase CB,
bool  ContainsMemProfMetadata,
const ValueMap< const Value *, WeakTrackingVH > &  VMap 
)
static

Definition at line 905 of file InlineFunction.cpp.

References llvm::Instruction::getMetadata().

Referenced by llvm::InlineFunction().

◆ PropagateOperandBundles()

static void PropagateOperandBundles ( Function::iterator  InlinedBB,
Instruction CallSiteEHPad 
)
static

◆ removeCallsiteMetadata()

static void removeCallsiteMetadata ( CallBase Call)
static

Definition at line 814 of file InlineFunction.cpp.

Referenced by propagateMemProfHelper(), and updateMemprofMetadata().

◆ removeMemProfMetadata()

static void removeMemProfMetadata ( CallBase Call)
static

Definition at line 810 of file InlineFunction.cpp.

Referenced by propagateMemProfHelper(), and updateMemprofMetadata().

◆ trackInlinedStores()

static void trackInlinedStores ( Function::iterator  Start,
Function::iterator  End,
const CallBase CB 
)
static

Definition at line 1821 of file InlineFunction.cpp.

Referenced by llvm::InlineFunction().

◆ updateCallerBFI()

static void updateCallerBFI ( BasicBlock CallSiteBlock,
const ValueToValueMapTy VMap,
BlockFrequencyInfo CallerBFI,
BlockFrequencyInfo CalleeBFI,
const BasicBlock CalleeEntryBlock 
)
static

Update the block frequencies of the caller after a callee has been inlined.

Each block cloned into the caller has its block frequency scaled by the ratio of CallSiteFreq/CalleeEntryFreq. This ensures that the cloned copy of callee's entry block gets the same frequency as the callsite block and the relative frequencies of all cloned blocks remain the same after cloning.

Definition at line 1864 of file InlineFunction.cpp.

Referenced by llvm::InlineFunction().

◆ UpdateCallGraphAfterInlining()

static void UpdateCallGraphAfterInlining ( CallBase CB,
Function::iterator  FirstNewBlock,
ValueToValueMapTy VMap,
InlineFunctionInfo IFI 
)
static

Once we have cloned code over from a callee into the caller, update the specified callgraph to reflect the changes we made.

Note that it's possible that not all code was copied over, so only some edges of the callgraph may remain.

Definition at line 1506 of file InlineFunction.cpp.

References llvm::CallGraphNode::addCalledFunction(), llvm::CallGraphNode::begin(), Callee, llvm::InlineFunctionInfo::CG, E, llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::CallGraphNode::end(), F, llvm::ValueMap< KeyT, ValueT, Config >::find(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCaller(), I, llvm::InlineFunctionInfo::InlinedCalls, llvm::CallGraphNode::removeCallEdgeFor(), and llvm::ValueMapIterator< DenseMapT, KeyT >::ValueTypeProxy::second.

Referenced by llvm::InlineFunction().

◆ updateCallProfile()

static void updateCallProfile ( Function Callee,
const ValueToValueMapTy VMap,
const ProfileCount CalleeEntryCount,
const CallBase TheCall,
ProfileSummaryInfo PSI,
BlockFrequencyInfo CallerBFI 
)
static

◆ updateMemprofMetadata()

static void updateMemprofMetadata ( CallBase CI,
const std::vector< Metadata * > &  MIBList 
)
static

Variable Documentation

◆ EnableNoAliasConversion

cl::opt<bool> EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true), cl::Hidden, cl::desc("Convert noalias attributes to metadata during inlining."))
static

Referenced by AddAliasScopeMetadata().

◆ InlinerAttributeWindow

cl::opt<unsigned> InlinerAttributeWindow("max-inst-checked-for-throw-during-inlining", cl::Hidden, cl::desc("the maximum number of instructions analyzed for may throw during " "attribute inference in inlined body"), cl::init(4))
static

◆ PreserveAlignmentAssumptions

cl::opt<bool> PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining", cl::init(false), cl::Hidden, cl::desc("Convert align attributes to assumptions during inlining."))
static

Referenced by AddAlignmentAssumptions().

◆ UpdateReturnAttributes

cl::opt<bool> UpdateReturnAttributes("update-return-attrs", cl::init(true), cl::Hidden, cl::desc("Update return attributes on calls within inlined body"))
static

Referenced by AddReturnAttributes().

◆ UseNoAliasIntrinsic

cl::opt<bool> UseNoAliasIntrinsic("use-noalias-intrinsic-during-inlining", cl::Hidden, cl::init(true), cl::desc("Use the llvm.experimental.noalias.scope.decl " "intrinsic during inlining."))
static

Referenced by AddAliasScopeMetadata().