Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
SimplifyLibCalls.cpp File Reference

Go to the source code of this file.

Functions

static bool ignoreCallingConv (LibFunc Func)
static bool isOnlyUsedInEqualityComparison (Value *V, Value *With)
 Return true if it is only used in equality comparisons with With.
static bool callHasFloatingPointArgument (const CallInst *CI)
static bool callHasFP128Argument (const CallInst *CI)
static ValueconvertStrToInt (CallInst *CI, StringRef &Str, Value *EndPtr, uint64_t Base, bool AsSigned, IRBuilderBase &B)
static bool isOnlyUsedInComparisonWithZero (Value *V)
static bool canTransformToMemCmp (CallInst *CI, Value *Str, uint64_t Len, const DataLayout &DL)
static void annotateDereferenceableBytes (CallInst *CI, ArrayRef< unsigned > ArgNos, uint64_t DereferenceableBytes)
static void annotateNonNullNoUndefBasedOnAccess (CallInst *CI, ArrayRef< unsigned > ArgNos)
static void annotateNonNullAndDereferenceable (CallInst *CI, ArrayRef< unsigned > ArgNos, Value *Size, const DataLayout &DL)
static ValuecopyFlags (const CallInst &Old, Value *New)
static ValuemergeAttributesAndFlags (CallInst *NewCI, const CallInst &Old)
static StringRef substr (StringRef Str, uint64_t Len)
static ValuememChrToCharCompare (CallInst *CI, Value *NBytes, IRBuilderBase &B, const DataLayout &DL)
static ValueoptimizeMemCmpVarSize (CallInst *CI, Value *LHS, Value *RHS, Value *Size, bool StrNCmp, IRBuilderBase &B, const DataLayout &DL)
static ValueoptimizeMemCmpConstantSize (CallInst *CI, Value *LHS, Value *RHS, uint64_t Len, IRBuilderBase &B, const DataLayout &DL)
static ValuereplaceUnaryCall (CallInst *CI, IRBuilderBase &B, Intrinsic::ID IID)
static ValuevalueHasFloatPrecision (Value *Val)
 Return a variant of Val with float type.
static ValueoptimizeDoubleFP (CallInst *CI, IRBuilderBase &B, bool isBinary, const TargetLibraryInfo *TLI, bool isPrecise=false)
 Shrink double -> float functions.
static ValueoptimizeUnaryDoubleFP (CallInst *CI, IRBuilderBase &B, const TargetLibraryInfo *TLI, bool isPrecise=false)
 Shrink double -> float for unary functions.
static ValueoptimizeBinaryDoubleFP (CallInst *CI, IRBuilderBase &B, const TargetLibraryInfo *TLI, bool isPrecise=false)
 Shrink double -> float for binary functions.
static ValuegetIntToFPVal (Value *I2F, IRBuilderBase &B, unsigned DstWidth)
static ValuegetSqrtCall (Value *V, AttributeList Attrs, bool NoErrno, Module *M, IRBuilderBase &B, const TargetLibraryInfo *TLI)
static ValuecreatePowWithIntegerExponent (Value *Base, Value *Expo, Module *M, IRBuilderBase &B)
static bool isTrigLibCall (CallInst *CI)
static bool insertSinCosCall (IRBuilderBase &B, Function *OrigCallee, Value *Arg, bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos, const TargetLibraryInfo *TLI)
static ValueoptimizeSymmetricCall (CallInst *CI, bool IsEven, IRBuilderBase &B)
static bool isReportingError (Function *Callee, CallInst *CI, int StreamArg)
static ValueoptimizeNaN (CallInst *CI)
 Constant folding nan/nanf/nanl.

Variables

static cl::opt< boolEnableUnsafeFPShrink ("enable-double-float-shrink", cl::Hidden, cl::init(false), cl::desc("Enable unsafe double to float " "shrinking for math lib calls"))
static cl::opt< boolOptimizeHotColdNew ("optimize-hot-cold-new", cl::Hidden, cl::init(false), cl::desc("Enable hot/cold operator new library calls"))
static cl::opt< boolOptimizeExistingHotColdNew ("optimize-existing-hot-cold-new", cl::Hidden, cl::init(false), cl::desc("Enable optimization of existing hot/cold operator new library calls"))
static cl::opt< boolOptimizeNoBuiltinHotColdNew ("optimize-nobuiltin-hot-cold-new-new", cl::Hidden, cl::init(false), cl::desc("Enable transformation of nobuiltin operator new library calls"))
static cl::opt< unsigned, false, HotColdHintParser > ColdNewHintValue ("cold-new-hint-value", cl::Hidden, cl::init(1), cl::desc("Value to pass to hot/cold operator new for cold allocation"))
static cl::opt< unsigned, false, HotColdHintParser > NotColdNewHintValue ("notcold-new-hint-value", cl::Hidden, cl::init(128), cl::desc("Value to pass to hot/cold operator new for " "notcold (warm) allocation"))
static cl::opt< unsigned, false, HotColdHintParser > HotNewHintValue ("hot-new-hint-value", cl::Hidden, cl::init(254), cl::desc("Value to pass to hot/cold operator new for hot allocation"))
static cl::opt< unsigned, false, HotColdHintParser > AmbiguousNewHintValue ("ambiguous-new-hint-value", cl::Hidden, cl::init(222), cl::desc("Value to pass to hot/cold operator new for ambiguous allocation"))

Function Documentation

◆ annotateDereferenceableBytes()

◆ annotateNonNullAndDereferenceable()

◆ annotateNonNullNoUndefBasedOnAccess()

◆ callHasFloatingPointArgument()

bool callHasFloatingPointArgument ( const CallInst * CI)
static

Definition at line 129 of file SimplifyLibCalls.cpp.

References llvm::any_of(), and llvm::User::operands().

◆ callHasFP128Argument()

bool callHasFP128Argument ( const CallInst * CI)
static

Definition at line 135 of file SimplifyLibCalls.cpp.

References llvm::any_of(), and llvm::User::operands().

◆ canTransformToMemCmp()

◆ convertStrToInt()

◆ copyFlags()

◆ createPowWithIntegerExponent()

Value * createPowWithIntegerExponent ( Value * Base,
Value * Expo,
Module * M,
IRBuilderBase & B )
static

Definition at line 2348 of file SimplifyLibCalls.cpp.

References B(), llvm::sampleprof::Base, and llvm::Value::getType().

◆ getIntToFPVal()

Value * getIntToFPVal ( Value * I2F,
IRBuilderBase & B,
unsigned DstWidth )
static

Definition at line 2083 of file SimplifyLibCalls.cpp.

References B(), llvm::BitWidth, llvm::cast(), and llvm::isa().

◆ getSqrtCall()

Value * getSqrtCall ( Value * V,
AttributeList Attrs,
bool NoErrno,
Module * M,
IRBuilderBase & B,
const TargetLibraryInfo * TLI )
static

Definition at line 2277 of file SimplifyLibCalls.cpp.

References B(), llvm::emitUnaryFloatFnCall(), and llvm::hasFloatFn().

◆ ignoreCallingConv()

bool ignoreCallingConv ( LibFunc Func)
static

◆ insertSinCosCall()

◆ isOnlyUsedInComparisonWithZero()

bool isOnlyUsedInComparisonWithZero ( Value * V)
static

Definition at line 250 of file SimplifyLibCalls.cpp.

References llvm::CallingConv::C, llvm::dyn_cast(), and llvm::Value::users().

Referenced by canTransformToMemCmp().

◆ isOnlyUsedInEqualityComparison()

bool isOnlyUsedInEqualityComparison ( Value * V,
Value * With )
static

Return true if it is only used in equality comparisons with With.

Definition at line 118 of file SimplifyLibCalls.cpp.

References llvm::dyn_cast(), and llvm::Value::users().

◆ isReportingError()

◆ isTrigLibCall()

bool isTrigLibCall ( CallInst * CI)
static

◆ memChrToCharCompare()

Value * memChrToCharCompare ( CallInst * CI,
Value * NBytes,
IRBuilderBase & B,
const DataLayout & DL )
static

◆ mergeAttributesAndFlags()

◆ optimizeBinaryDoubleFP()

Value * optimizeBinaryDoubleFP ( CallInst * CI,
IRBuilderBase & B,
const TargetLibraryInfo * TLI,
bool isPrecise = false )
static

Shrink double -> float for binary functions.

Definition at line 2025 of file SimplifyLibCalls.cpp.

References B(), and optimizeDoubleFP().

◆ optimizeDoubleFP()

◆ optimizeMemCmpConstantSize()

◆ optimizeMemCmpVarSize()

Value * optimizeMemCmpVarSize ( CallInst * CI,
Value * LHS,
Value * RHS,
Value * Size,
bool StrNCmp,
IRBuilderBase & B,
const DataLayout & DL )
static

◆ optimizeNaN()

◆ optimizeSymmetricCall()

◆ optimizeUnaryDoubleFP()

Value * optimizeUnaryDoubleFP ( CallInst * CI,
IRBuilderBase & B,
const TargetLibraryInfo * TLI,
bool isPrecise = false )
static

Shrink double -> float for unary functions.

Definition at line 2018 of file SimplifyLibCalls.cpp.

References B(), and optimizeDoubleFP().

Referenced by llvm::LibCallSimplifier::optimizeCall().

◆ replaceUnaryCall()

Value * replaceUnaryCall ( CallInst * CI,
IRBuilderBase & B,
Intrinsic::ID IID )
static

◆ substr()

◆ valueHasFloatPrecision()

Value * valueHasFloatPrecision ( Value * Val)
static

Return a variant of Val with float type.

Currently this works in two cases: If Val is an FPExtension of a float value to something bigger, simply return the operand. If Val is a ConstantFP but can be converted to a float ConstantFP without loss of precision do so.

Definition at line 1941 of file SimplifyLibCalls.cpp.

References llvm::dyn_cast(), F, llvm::APFloatBase::IEEEsingle(), and llvm::APFloatBase::rmNearestTiesToEven.

Referenced by optimizeDoubleFP().

Variable Documentation

◆ AmbiguousNewHintValue

cl::opt< unsigned, false, HotColdHintParser > AmbiguousNewHintValue("ambiguous-new-hint-value", cl::Hidden, cl::init(222), cl::desc( "Value to pass to hot/cold operator new for ambiguous allocation")) ( "ambiguous-new-hint-value" ,
cl::Hidden ,
cl::init(222) ,
cl::desc( "Value to pass to hot/cold operator new for ambiguous allocation")  )
static

◆ ColdNewHintValue

cl::opt< unsigned, false, HotColdHintParser > ColdNewHintValue("cold-new-hint-value", cl::Hidden, cl::init(1), cl::desc("Value to pass to hot/cold operator new for cold allocation")) ( "cold-new-hint-value" ,
cl::Hidden ,
cl::init(1) ,
cl::desc("Value to pass to hot/cold operator new for cold allocation")  )
static

◆ EnableUnsafeFPShrink

cl::opt< bool > EnableUnsafeFPShrink("enable-double-float-shrink", cl::Hidden, cl::init(false), cl::desc("Enable unsafe double to float " "shrinking for math lib calls")) ( "enable-double-float-shrink" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Enable unsafe double to float " "shrinking for math lib calls")  )
static

◆ HotNewHintValue

cl::opt< unsigned, false, HotColdHintParser > HotNewHintValue("hot-new-hint-value", cl::Hidden, cl::init(254), cl::desc("Value to pass to hot/cold operator new for hot allocation")) ( "hot-new-hint-value" ,
cl::Hidden ,
cl::init(254) ,
cl::desc("Value to pass to hot/cold operator new for hot allocation")  )
static

◆ NotColdNewHintValue

cl::opt< unsigned, false, HotColdHintParser > NotColdNewHintValue("notcold-new-hint-value", cl::Hidden, cl::init(128), cl::desc("Value to pass to hot/cold operator new for " "notcold (warm) allocation")) ( "notcold-new-hint-value" ,
cl::Hidden ,
cl::init(128) ,
cl::desc("Value to pass to hot/cold operator new for " "notcold (warm) allocation")  )
static

◆ OptimizeExistingHotColdNew

cl::opt< bool > OptimizeExistingHotColdNew("optimize-existing-hot-cold-new", cl::Hidden, cl::init(false), cl::desc( "Enable optimization of existing hot/cold operator new library calls")) ( "optimize-existing-hot-cold-new" ,
cl::Hidden ,
cl::init(false) ,
cl::desc( "Enable optimization of existing hot/cold operator new library calls")  )
static

◆ OptimizeHotColdNew

cl::opt< bool > OptimizeHotColdNew("optimize-hot-cold-new", cl::Hidden, cl::init(false), cl::desc("Enable hot/cold operator new library calls")) ( "optimize-hot-cold-new" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Enable hot/cold operator new library calls")  )
static

◆ OptimizeNoBuiltinHotColdNew

cl::opt< bool > OptimizeNoBuiltinHotColdNew("optimize-nobuiltin-hot-cold-new-new", cl::Hidden, cl::init(false), cl::desc("Enable transformation of nobuiltin operator new library calls")) ( "optimize-nobuiltin-hot-cold-new-new" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Enable transformation of nobuiltin operator new library calls")  )
static