LLVM API Documentation
#include "llvm/Transforms/IPO/InlinerPass.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionTracker.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
Go to the source code of this file.
Defines | |
#define | DEBUG_TYPE "inline" |
Typedefs | |
typedef DenseMap< ArrayType *, std::vector< AllocaInst * > > | InlinedArrayAllocasTy |
Functions | |
STATISTIC (NumInlined,"Number of functions inlined") | |
STATISTIC (NumCallsDeleted,"Number of call sites deleted, not inlined") | |
STATISTIC (NumDeleted,"Number of functions deleted because all callers found") | |
STATISTIC (NumMergedAllocas,"Number of allocas merged together") | |
STATISTIC (NumCallerCallersAnalyzed,"Number of caller-callers analyzed") | |
static void | AdjustCallerSSPLevel (Function *Caller, Function *Callee) |
If the inlined function had a higher stack protection level than the calling function, then bump up the caller's stack protection level. | |
static bool | InlineCallIfPossible (CallSite CS, InlineFunctionInfo &IFI, InlinedArrayAllocasTy &InlinedArrayAllocas, int InlineHistory, bool InsertLifetime, const DataLayout *DL) |
static void | emitAnalysis (CallSite CS, const Twine &Msg) |
static bool | InlineHistoryIncludes (Function *F, int InlineHistoryID, const SmallVectorImpl< std::pair< Function *, int > > &InlineHistory) |
Variables | |
static cl::opt< int > | InlineLimit ("inline-threshold", cl::Hidden, cl::init(225), cl::ZeroOrMore, cl::desc("Control the amount of inlining to perform (default = 225)")) |
static cl::opt< int > | HintThreshold ("inlinehint-threshold", cl::Hidden, cl::init(325), cl::desc("Threshold for inlining functions with inline hint")) |
static cl::opt< int > | ColdThreshold ("inlinecold-threshold", cl::Hidden, cl::init(225), cl::desc("Threshold for inlining functions with cold attribute")) |
const int | OptSizeThreshold = 75 |
#define DEBUG_TYPE "inline" |
Definition at line 37 of file Inliner.cpp.
typedef DenseMap<ArrayType*, std::vector<AllocaInst*> > InlinedArrayAllocasTy |
Definition at line 86 of file Inliner.cpp.
static void AdjustCallerSSPLevel | ( | Function * | Caller, |
Function * | Callee | ||
) | [static] |
If the inlined function had a higher stack protection level than the calling function, then bump up the caller's stack protection level.
Definition at line 90 of file Inliner.cpp.
References llvm::AttrBuilder::addAttribute(), llvm::Function::addFnAttr(), llvm::AttributeSet::FunctionIndex, llvm::Function::getAttributes(), llvm::Function::getContext(), llvm::Function::removeAttributes(), llvm::Attribute::StackProtect, llvm::Attribute::StackProtectReq, and llvm::Attribute::StackProtectStrong.
Referenced by InlineCallIfPossible().
static void emitAnalysis | ( | CallSite | CS, |
const Twine & | Msg | ||
) | [static] |
Definition at line 308 of file Inliner.cpp.
References DEBUG_TYPE, llvm::emitOptimizationRemarkAnalysis(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCaller(), llvm::Function::getContext(), llvm::Instruction::getDebugLoc(), and llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction().
static bool InlineCallIfPossible | ( | CallSite | CS, |
InlineFunctionInfo & | IFI, | ||
InlinedArrayAllocasTy & | InlinedArrayAllocas, | ||
int | InlineHistory, | ||
bool | InsertLifetime, | ||
const DataLayout * | DL | ||
) | [static] |
InlineCallIfPossible - If it is possible to inline the specified call site, do so and update the CallGraph for this operation.
This function also does some basic book-keeping to update the IR. The InlinedArrayAllocas map keeps track of any allocas that are already available from other functions inlined into the caller. If we are able to inline this call site we attempt to reuse already available allocas or add any new allocas to the set if not possible.
Definition at line 130 of file Inliner.cpp.
References AdjustCallerSSPLevel(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::DataLayout::getABITypeAlignment(), llvm::AllocaInst::getAlignment(), llvm::AllocaInst::getAllocatedType(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCaller(), llvm::Instruction::getParent(), llvm::InlineFunction(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::AllocaInst::isArrayAllocation(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::AllocaInst::setAlignment(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::InlineFunctionInfo::StaticAllocas.
Referenced by llvm::Inliner::runOnSCC().
static bool InlineHistoryIncludes | ( | Function * | F, |
int | InlineHistoryID, | ||
const SmallVectorImpl< std::pair< Function *, int > > & | InlineHistory | ||
) | [static] |
InlineHistoryIncludes - Return true if the specified inline history ID indicates an inline history that includes the specified function.
Definition at line 432 of file Inliner.cpp.
Referenced by llvm::Inliner::runOnSCC().
STATISTIC | ( | NumCallsDeleted | , |
"Number of call sites | deleted, | ||
not inlined" | |||
) |
STATISTIC | ( | NumMergedAllocas | , |
"Number of allocas merged together" | |||
) |
STATISTIC | ( | NumCallerCallersAnalyzed | , |
"Number of caller-callers analyzed" | |||
) |
cl::opt<int> ColdThreshold("inlinecold-threshold", cl::Hidden, cl::init(225), cl::desc("Threshold for inlining functions with cold attribute")) [static] |
Referenced by llvm::Inliner::getInlineThreshold().
cl::opt<int> HintThreshold("inlinehint-threshold", cl::Hidden, cl::init(325), cl::desc("Threshold for inlining functions with inline hint")) [static] |
Referenced by llvm::Inliner::getInlineThreshold().
cl::opt<int> InlineLimit("inline-threshold", cl::Hidden, cl::init(225), cl::ZeroOrMore, cl::desc("Control the amount of inlining to perform (default = 225)")) [static] |
Referenced by llvm::Inliner::getInlineThreshold().
const int OptSizeThreshold = 75 |
Definition at line 65 of file Inliner.cpp.
Referenced by llvm::Inliner::getInlineThreshold().