38 #define DEBUG_TYPE "inline-cost"
40 STATISTIC(NumCallsAnalyzed,
"Number of call sites analyzed");
44 class CallAnalyzer :
public InstVisitor<CallAnalyzer, bool> {
65 bool IsCallerRecursive;
67 bool ExposesReturnsTwice;
68 bool HasDynamicAlloca;
69 bool ContainsNoDuplicateCall;
75 uint64_t AllocatedSize;
76 unsigned NumInstructions, NumVectorInstructions;
77 int FiftyPercentVectorBonus, TenPercentVectorBonus;
102 bool isAllocaDerivedArg(
Value *V);
103 bool lookupSROAArgAndCost(
Value *V,
Value *&Arg,
106 void disableSROA(
Value *V);
108 int InstructionCost);
123 bool isKnownNonNullInCallee(
Value *V);
164 : TTI(TTI), ACT(ACT),
F(Callee), CandidateCS(CSArg), Threshold(Threshold),
165 Cost(0), IsCallerRecursive(
false), IsRecursiveCall(
false),
166 ExposesReturnsTwice(
false), HasDynamicAlloca(
false),
167 ContainsNoDuplicateCall(
false), HasReturn(
false), HasIndirectBr(
false),
168 HasFrameEscape(
false), AllocatedSize(0), NumInstructions(0),
169 NumVectorInstructions(0), FiftyPercentVectorBonus(0),
170 TenPercentVectorBonus(0), VectorBonus(0), NumConstantArgs(0),
171 NumConstantOffsetPtrArgs(0), NumAllocaArgs(0), NumConstantPtrCmps(0),
172 NumConstantPtrDiffs(0), NumInstructionsSimplified(0),
173 SROACostSavings(0), SROACostSavingsLost(0) {}
178 int getCost() {
return Cost; }
182 unsigned NumConstantArgs;
183 unsigned NumConstantOffsetPtrArgs;
184 unsigned NumAllocaArgs;
185 unsigned NumConstantPtrCmps;
186 unsigned NumConstantPtrDiffs;
187 unsigned NumInstructionsSimplified;
188 unsigned SROACostSavings;
189 unsigned SROACostSavingsLost;
197 bool CallAnalyzer::isAllocaDerivedArg(
Value *V) {
198 return SROAArgValues.count(V);
203 bool CallAnalyzer::lookupSROAArgAndCost(
205 if (SROAArgValues.empty() || SROAArgCosts.empty())
209 if (ArgIt == SROAArgValues.
end())
213 CostIt = SROAArgCosts.
find(Arg);
214 return CostIt != SROAArgCosts.
end();
224 Cost += CostIt->second;
225 SROACostSavings -= CostIt->second;
226 SROACostSavingsLost += CostIt->second;
227 SROAArgCosts.
erase(CostIt);
231 void CallAnalyzer::disableSROA(
Value *V) {
234 if (lookupSROAArgAndCost(V, SROAArg, CostIt))
240 int InstructionCost) {
241 CostIt->second += InstructionCost;
242 SROACostSavings += InstructionCost;
250 if (!isa<Constant>(*
I) && !SimplifiedValues.lookup(*
I))
269 if (
Constant *SimpleOp = SimplifiedValues.lookup(GTI.getOperand()))
273 if (OpC->
isZero())
continue;
276 if (
StructType *STy = dyn_cast<StructType>(*GTI)) {
295 assert(AllocSize &&
"Allocation size not a constant int?");
298 return Base::visitAlloca(I);
304 const DataLayout &DL =
F.getParent()->getDataLayout();
311 return Base::visitAlloca(I);
317 HasDynamicAlloca =
true;
321 bool CallAnalyzer::visitPHI(
PHINode &I) {
345 std::pair<Value *, APInt> BaseAndOffset = ConstantOffsetPtrs.lookup(Ptr);
346 if (BaseAndOffset.first) {
349 if (!accumulateGEPOffset(cast<GEPOperator>(I), BaseAndOffset.second)) {
357 ConstantOffsetPtrs[&
I] = BaseAndOffset;
362 SROAArgValues[&
I] = SROAArg;
368 if (isGEPOffsetConstant(I)) {
370 SROAArgValues[&
I] = SROAArg;
386 COp = SimplifiedValues.lookup(I.
getOperand(0));
389 SimplifiedValues[&
I] =
C;
394 std::pair<Value *, APInt> BaseAndOffset
397 if (BaseAndOffset.first)
398 ConstantOffsetPtrs[&
I] = BaseAndOffset;
403 if (lookupSROAArgAndCost(I.
getOperand(0), SROAArg, CostIt))
404 SROAArgValues[&
I] = SROAArg;
414 COp = SimplifiedValues.lookup(I.
getOperand(0));
417 SimplifiedValues[&
I] =
C;
424 const DataLayout &DL =
F.getParent()->getDataLayout();
426 std::pair<Value *, APInt> BaseAndOffset
428 if (BaseAndOffset.first)
429 ConstantOffsetPtrs[&
I] = BaseAndOffset;
441 if (lookupSROAArgAndCost(I.
getOperand(0), SROAArg, CostIt))
442 SROAArgValues[&
I] = SROAArg;
451 COp = SimplifiedValues.lookup(I.
getOperand(0));
454 SimplifiedValues[&
I] =
C;
462 const DataLayout &DL =
F.getParent()->getDataLayout();
464 std::pair<Value *, APInt> BaseAndOffset = ConstantOffsetPtrs.lookup(Op);
465 if (BaseAndOffset.first)
466 ConstantOffsetPtrs[&
I] = BaseAndOffset;
472 if (lookupSROAArgAndCost(Op, SROAArg, CostIt))
473 SROAArgValues[&
I] = SROAArg;
478 bool CallAnalyzer::visitCastInst(
CastInst &I) {
482 COp = SimplifiedValues.lookup(I.
getOperand(0));
485 SimplifiedValues[&
I] =
C;
499 COp = SimplifiedValues.lookup(Operand);
501 const DataLayout &DL =
F.getParent()->getDataLayout();
504 SimplifiedValues[&
I] =
C;
510 disableSROA(Operand);
517 return CandidateCS.paramHasAttr(ArgNo+1, Attr);
520 bool CallAnalyzer::isKnownNonNullInCallee(
Value *V) {
526 if (
Argument *A = dyn_cast<Argument>(V))
533 if (isAllocaDerivedArg(V))
542 bool CallAnalyzer::visitCmpInst(
CmpInst &I) {
545 if (!isa<Constant>(LHS))
546 if (
Constant *SimpleLHS = SimplifiedValues.lookup(LHS))
548 if (!isa<Constant>(RHS))
549 if (
Constant *SimpleRHS = SimplifiedValues.lookup(RHS))
551 if (
Constant *CLHS = dyn_cast<Constant>(LHS)) {
552 if (
Constant *CRHS = dyn_cast<Constant>(RHS))
554 SimplifiedValues[&
I] =
C;
564 Value *LHSBase, *RHSBase;
565 APInt LHSOffset, RHSOffset;
566 std::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
568 std::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
569 if (RHSBase && LHSBase == RHSBase) {
575 SimplifiedValues[&
I] =
C;
576 ++NumConstantPtrCmps;
594 if (lookupSROAArgAndCost(I.
getOperand(0), SROAArg, CostIt)) {
595 if (isa<ConstantPointerNull>(I.
getOperand(1))) {
610 Value *LHSBase, *RHSBase;
611 APInt LHSOffset, RHSOffset;
612 std::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
614 std::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
615 if (RHSBase && LHSBase == RHSBase) {
621 SimplifiedValues[&
I] =
C;
622 ++NumConstantPtrDiffs;
630 return Base::visitSub(I);
635 const DataLayout &DL =
F.getParent()->getDataLayout();
636 if (!isa<Constant>(LHS))
637 if (
Constant *SimpleLHS = SimplifiedValues.lookup(LHS))
639 if (!isa<Constant>(RHS))
640 if (
Constant *SimpleRHS = SimplifiedValues.lookup(RHS))
642 Value *SimpleV =
nullptr;
643 if (
auto FI = dyn_cast<FPMathOperator>(&I))
649 if (
Constant *
C = dyn_cast_or_null<Constant>(SimpleV)) {
650 SimplifiedValues[&
I] =
C;
661 bool CallAnalyzer::visitLoad(
LoadInst &I) {
676 bool CallAnalyzer::visitStore(
StoreInst &I) {
713 if (AggC && InsertedC) {
744 C = dyn_cast_or_null<Constant>(SimplifiedValues.lookup(*I));
758 bool CallAnalyzer::visitCallSite(
CallSite CS) {
762 ExposesReturnsTwice =
true;
767 ContainsNoDuplicateCall =
true;
771 if (simplifyCallSite(F, CS))
777 switch (II->getIntrinsicID()) {
779 return Base::visitCallSite(CS);
781 case Intrinsic::memset:
782 case Intrinsic::memcpy:
783 case Intrinsic::memmove:
786 case Intrinsic::localescape:
787 HasFrameEscape =
true;
795 IsRecursiveCall =
true;
799 if (TTI.isLoweredToCall(F)) {
810 return Base::visitCallSite(CS);
823 Function *F = dyn_cast_or_null<Function>(SimplifiedValues.lookup(Callee));
825 return Base::visitCallSite(CS);
833 if (CA.analyzeCall(CS)) {
839 return Base::visitCallSite(CS);
842 bool CallAnalyzer::visitReturnInst(
ReturnInst &RI) {
844 bool Free = !HasReturn;
849 bool CallAnalyzer::visitBranchInst(
BranchInst &BI) {
855 dyn_cast_or_null<ConstantInt>(
865 if (isa<ConstantInt>(V))
880 SuccessorBlocks.
insert(I.getCaseSuccessor());
896 HasIndirectBr =
true;
900 bool CallAnalyzer::visitResumeInst(
ResumeInst &RI) {
913 bool CallAnalyzer::visitInstruction(
Instruction &I) {
916 if (TargetTransformInfo::TCC_Free == TTI.getUserCost(&I))
935 bool CallAnalyzer::analyzeBlock(
BasicBlock *BB,
945 if (isa<DbgInfoIntrinsic>(I))
949 if (EphValues.
count(I))
954 ++NumVectorInstructions;
960 bool hasSoftFloatAttr =
false;
967 hasSoftFloatAttr =
true;
981 ++NumInstructionsSimplified;
986 if (IsRecursiveCall || ExposesReturnsTwice || HasDynamicAlloca ||
987 HasIndirectBr || HasFrameEscape)
993 if (IsCallerRecursive &&
1012 ConstantInt *CallAnalyzer::stripAndComputeInBoundsConstantOffsets(
Value *&V) {
1025 if (
GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
1026 if (!GEP->
isInBounds() || !accumulateGEPOffset(*GEP, Offset))
1030 V = cast<Operator>(V)->getOperand(0);
1031 }
else if (
GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
1032 if (GA->mayBeOverridden())
1034 V = GA->getAliasee();
1039 }
while (Visited.
insert(V).second);
1052 bool CallAnalyzer::analyzeCall(
CallSite CS) {
1065 assert(NumInstructions == 0);
1066 assert(NumVectorInstructions == 0);
1067 FiftyPercentVectorBonus = 3 *
Threshold / 2;
1068 TenPercentVectorBonus = 3 *
Threshold / 4;
1074 bool SingleBB =
true;
1080 Threshold += (SingleBBBonus + FiftyPercentVectorBonus);
1084 for (
unsigned I = 0, E = CS.
arg_size(); I != E; ++
I) {
1092 unsigned NumStores = (TypeSize + PointerSize - 1) / PointerSize;
1100 NumStores =
std::min(NumStores, 8U);
1114 if (OnlyOneCallAndLocalLinkage)
1122 if (
InvokeInst *II = dyn_cast<InvokeInst>(Instr)) {
1123 if (isa<UnreachableInst>(II->getNormalDest()->begin()))
1148 IsCallerRecursive =
true;
1157 FAI != FAE; ++FAI, ++CAI) {
1159 if (
Constant *C = dyn_cast<Constant>(CAI))
1160 SimplifiedValues[FAI] = C;
1162 Value *PtrArg = *CAI;
1163 if (
ConstantInt *C = stripAndComputeInBoundsConstantOffsets(PtrArg)) {
1164 ConstantOffsetPtrs[FAI] = std::make_pair(PtrArg, C->getValue());
1167 if (isa<AllocaInst>(PtrArg)) {
1168 SROAArgValues[FAI] = PtrArg;
1169 SROAArgCosts[PtrArg] = 0;
1173 NumConstantArgs = SimplifiedValues.size();
1174 NumConstantOffsetPtrArgs = ConstantOffsetPtrs.size();
1175 NumAllocaArgs = SROAArgValues.size();
1192 BBSetVector BBWorklist;
1195 for (
unsigned Idx = 0; Idx != BBWorklist.size(); ++Idx) {
1216 if (!analyzeBlock(BB, EphValues)) {
1217 if (IsRecursiveCall || ExposesReturnsTwice || HasDynamicAlloca ||
1218 HasIndirectBr || HasFrameEscape)
1224 if (IsCallerRecursive &&
1235 if (
BranchInst *BI = dyn_cast<BranchInst>(TI)) {
1239 = dyn_cast_or_null<ConstantInt>(SimplifiedValues.lookup(Cond))) {
1240 BBWorklist.insert(BI->
getSuccessor(SimpleCond->isZero() ? 1 : 0));
1244 }
else if (
SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
1247 = dyn_cast_or_null<ConstantInt>(SimplifiedValues.lookup(Cond))) {
1273 if (!OnlyOneCallAndLocalLinkage && ContainsNoDuplicateCall)
1279 if (NumVectorInstructions <= NumInstructions / 10)
1281 else if (NumVectorInstructions <= NumInstructions / 2)
1282 Threshold -= (FiftyPercentVectorBonus - TenPercentVectorBonus);
1287 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1290 #define DEBUG_PRINT_STAT(x) dbgs() << " " #x ": " << x << "\n"
1303 #undef DEBUG_PRINT_STAT
1314 char InlineCostAnalysis::
ID = 0;
1328 TTIWP = &getAnalysis<TargetTransformInfoWrapperPass>();
1329 ACT = &getAnalysis<AssumptionCacheTracker>();
1339 template<
typename AttrKind>
1390 bool ShouldInline = CA.analyzeCall(CS);
1395 if (!ShouldInline && CA.getCost() < CA.getThreshold())
1397 if (ShouldInline && CA.getCost() >= CA.getThreshold())
1408 if (isa<IndirectBrInst>(BI->getTerminator()) || BI->hasAddressTaken())
1423 if (!ReturnsTwice && CS.
isCall() &&
1431 llvm::Intrinsic::localescape)
ReturnInst - Return a value (possibly void), from a function.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
static ConstantInt * getFalse(LLVMContext &Context)
Value * getPointerOperand()
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
This class is the base class for the comparison instructions.
LLVM Argument representation.
Base class for instruction visitors.
Value * getAggregateOperand()
STATISTIC(NumFunctions,"Total number of functions")
ArrayRef< unsigned > getIndices() const
ValTy * getArgument(unsigned ArgNo) const
bool canConstantFoldCallTo(const Function *F)
canConstantFoldCallTo - Return true if its even possible to fold a call to the specified function...
A Module instance is used to store all the information related to an LLVM module. ...
InstrTy * getInstruction() const
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
An immutable pass that tracks lazily created AssumptionCache objects.
gep_type_iterator gep_type_end(const User *GEP)
CaseIt case_begin()
Returns a read/write iterator that points to the first case in SwitchInst.
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
const Function * getParent() const
Return the enclosing method, or null if none.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
FunTy * getCaller() const
getCaller - Return the caller function for this call site
LoadInst - an instruction for reading from memory.
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
User::op_iterator arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
void reserve(size_type N)
void getAnalysisUsage(AnalysisUsage &Info) const override
getAnalysisUsage - For this class, we declare that we require and preserve the call graph...
Represents the cost of inlining a function.
bool isEquality() const
This is just a convenience that dispatches to the subclasses.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
StringRef getName() const
Return a constant reference to the value's name.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator begin()
Instruction iterator methods.
bool isArrayAllocation() const
isArrayAllocation - Return true if there is an allocation size parameter to the allocation instructio...
AnalysisUsage & addRequired()
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isUnconditional() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - For this class, we declare that we require and preserve the call graph...
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
This is the base class for all instructions that perform data casts.
const APInt & getValue() const
Return the constant as an APInt value reference.
StructType - Class to represent struct types.
A Use represents the edge between a Value definition and its users.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool hasFnAttr(Attribute::AttrKind A) const
Return true if this function has the given attribute.
#define DEBUG_PRINT_STAT(x)
This class represents a cast from a pointer to an integer.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
BasicBlock * getSuccessor(unsigned i) const
This class represents a no-op cast from one type to another.
Value * getInsertedValueOperand()
bool isFloatingPointTy() const
isFloatingPointTy - Return true if this is one of the six floating point types
const int LastCallToStaticBonus
StoreInst - an instruction for storing to memory.
Type * getElementType() const
bool isInBounds() const
isInBounds - Determine whether the GEP has the inbounds flag.
PointerType - Class to represent pointers.
uint64_t getElementOffset(unsigned Idx) const
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
bool erase(const KeyT &Val)
bool isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Subclasses of this class are all able to terminate a basic block.
const int IndirectCallThreshold
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
static bool mayBeOverridden(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time...
BranchInst - Conditional or Unconditional Branch instruction.
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
UnreachableInst - This function has undefined behavior.
This is an important base class in LLVM.
ResumeInst - Resume the propagation of an exception.
Cost analyzer used by inliner.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
IndirectBrInst - Indirect Branch Instruction.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Represent the analysis usage information of a pass.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static InlineCost getNever()
Value * getPointerOperand()
Value * getOperand(unsigned i) const
bool runOnSCC(CallGraphSCC &SCC) override
runOnSCC - This method should be implemented by the subclass to perform whatever action is necessary ...
Value * getPointerOperand()
Value * SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS, const FastMathFlags &FMF, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr)
SimplifyFPBinOp - Given operands for a BinaryOperator, see if we can fold the result.
static Constant * getICmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
get* - Return some common constants without having to specify the full Instruction::OPCODE identifier...
Predicate getPredicate() const
Return the predicate for this instruction.
inline Inline Cost Analysis
This class represents a cast from an integer to a pointer.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
LLVMContext & getContext() const
All values hold a context through their type.
Pointer is known to be not null.
static bool functionsHaveCompatibleAttributes(Function *Caller, Function *Callee, TargetTransformInfo &TTI)
Test that there are no attribute conflicts between Caller and Callee that prevent inlining...
bool isConditional() const
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static bool attributeMatches(Function *F1, Function *F2, AttrKind Attr)
Test that two functions either have or have not the given attribute at the same time.
BinaryOps getOpcode() const
~InlineCostAnalysis() override
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
unsigned getScalarSizeInBits() const LLVM_READONLY
getScalarSizeInBits - If this is a vector type, return the getPrimitiveSizeInBits value for the eleme...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Constant * ConstantFoldInstOperands(unsigned Opcode, Type *DestTy, ArrayRef< Constant * > Ops, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldInstOperands - Attempt to constant fold an instruction with the specified operands...
bool isStaticAlloca() const
isStaticAlloca - Return true if this alloca is in the entry block of the function and is a constant s...
Type * getType() const
All values are typed, get the type of this value.
BasicBlockTy * getCaseSuccessor()
Resolves successor for current case.
unsigned arg_size() const
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
const BasicBlock & getEntryBlock() const
CaseIt findCaseValue(const ConstantInt *C)
findCaseValue - Search all of the case values for the specified constant.
static ConstantInt * getTrue(LLVMContext &Context)
bool isNoInline() const
Return true if the call should not be inlined.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
INITIALIZE_PASS_BEGIN(InlineCostAnalysis,"inline-cost","Inline Cost Analysis", true, true) INITIALIZE_PASS_END(InlineCostAnalysis
Class for arbitrary precision integers.
Function must not be optimized.
void setPreservesAll()
Set by analyses that do not transform their input at all.
iterator_range< user_iterator > users()
Value * SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr)
SimplifyBinOp - Given operands for a BinaryOperator, see if we can fold the result.
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Value * getCondition() const
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Value * getCondition() const
BasicBlock * getDefaultDest() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool hasOneUse() const
Return true if there is exactly one user of this value.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
iterator find(const KeyT &Val)
InlineCost getInlineCost(CallSite CS, int Threshold)
Get an InlineCost object representing the cost of inlining this callsite.
bool hasLocalLinkage() const
OtherOps getOpcode() const
Get the opcode casted to the right type.
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
SwitchInst - Multiway switch.
StringRef getValueAsString() const
Return the attribute's value as a string.
const unsigned TotalAllocaSizeRecursiveCaller
Do not inline functions which allocate this many bytes on the stack when the caller is recursive...
Function can return twice.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
A vector that has set insertion semantics.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
const Value * getArraySize() const
getArraySize - Get the number of elements allocated.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
InvokeInst - Invoke instruction.
IterTy arg_begin() const
arg_begin/arg_end - Return iterators corresponding to the actual argument list for a call site...
C - The default llvm calling convention, compatible with C.
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
StringRef - Represent a constant reference to a string, i.e.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
static void collectEphemeralValues(const Loop *L, AssumptionCache *AC, SmallPtrSetImpl< const Value * > &EphValues)
Collect a loop's ephemeral values (those used only by an assume or similar intrinsics in the loop)...
Type * getAllocatedType() const
getAllocatedType - Return the type that is being allocated by the instruction.
bool isCall() const
isCall - true if a CallInst is enclosed.
static InlineCost getAlways()
Value * getPointerOperand()
const BasicBlock * getParent() const
static InlineCost get(int Cost, int Threshold)
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
Constant * ConstantFoldCall(Function *F, ArrayRef< Constant * > Operands, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldCall - Attempt to constant fold a call to the specified function with the specified argum...
AllocaInst - an instruction to allocate memory on the stack.
InsertValueInst - This instruction inserts a struct field of array element value into an aggregate va...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
gep_type_iterator gep_type_begin(const User *GEP)