LLVM  5.0.0
Functions | Variables
SimplifyLibCalls.cpp File Reference
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
Include dependency graph for SimplifyLibCalls.cpp:

Go to the source code of this file.

Functions

static bool ignoreCallingConv (LibFunc Func)
 
static bool isCallingConvCCompatible (CallInst *CI)
 
static bool isOnlyUsedInEqualityComparison (Value *V, Value *With)
 Return true if it is only used in equality comparisons with With. More...
 
static bool callHasFloatingPointArgument (const CallInst *CI)
 
static bool hasUnaryFloatFn (const TargetLibraryInfo *TLI, Type *Ty, LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn)
 Check whether the overloaded unary floating point function corresponding to Ty is available. More...
 
static Value * emitCalloc (Value *Num, Value *Size, const AttributeList &Attrs, IRBuilder<> &B, const TargetLibraryInfo &TLI)
 
static Value * foldMallocMemset (CallInst *Memset, IRBuilder<> &B, const TargetLibraryInfo &TLI)
 Fold memset[_chk](malloc(n), 0, n) –> calloc(1, n). More...
 
static Value * valueHasFloatPrecision (Value *Val)
 Return a variant of Val with float type. More...
 
static Value * optimizeUnaryDoubleFP (CallInst *CI, IRBuilder<> &B, bool CheckRetType)
 Shrink double -> float for unary functions like 'floor'. More...
 
static Value * replaceUnaryCall (CallInst *CI, IRBuilder<> &B, Intrinsic::ID IID)
 
static Value * optimizeBinaryDoubleFP (CallInst *CI, IRBuilder<> &B)
 Shrink double -> float for binary functions like 'fmin/fmax'. More...
 
static Value * getPow (Value *InnerChain[33], unsigned Exp, IRBuilder<> &B)
 
static bool isTrigLibCall (CallInst *CI)
 
static void insertSinCosCall (IRBuilder<> &B, Function *OrigCallee, Value *Arg, bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos)
 
static bool isReportingError (Function *Callee, CallInst *CI, int StreamArg)
 

Variables

static 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"))
 

Function Documentation

static bool callHasFloatingPointArgument ( const CallInst *  CI)
static

Definition at line 100 of file SimplifyLibCalls.cpp.

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

static Value* emitCalloc ( Value *  Num,
Value *  Size,
const AttributeList &  Attrs,
IRBuilder<> &  B,
const TargetLibraryInfo &  TLI 
)
static
static Value* foldMallocMemset ( CallInst *  Memset,
IRBuilder<> &  B,
const TargetLibraryInfo &  TLI 
)
static
static Value* getPow ( Value *  InnerChain[33],
unsigned  Exp,
IRBuilder<> &  B 
)
static
static bool hasUnaryFloatFn ( const TargetLibraryInfo *  TLI,
Type *  Ty,
LibFunc  DoubleFn,
LibFunc  FloatFn,
LibFunc  LongDoubleFn 
)
static

Check whether the overloaded unary floating point function corresponding to Ty is available.

Definition at line 108 of file SimplifyLibCalls.cpp.

References llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::getTypeID(), and llvm::TargetLibraryInfo::has().

static bool ignoreCallingConv ( LibFunc  Func)
static
static void insertSinCosCall ( IRBuilder<> &  B,
Function *  OrigCallee,
Value *  Arg,
bool  UseFloat,
Value *&  Sin,
Value *&  Cos,
Value *&  SinCos 
)
static
static bool isCallingConvCCompatible ( CallInst *  CI)
static
static bool isOnlyUsedInEqualityComparison ( Value *  V,
Value *  With 
)
static

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

Definition at line 89 of file SimplifyLibCalls.cpp.

References llvm::Value::users().

static bool isReportingError ( Function *  Callee,
CallInst *  CI,
int  StreamArg 
)
static
static bool isTrigLibCall ( CallInst *  CI)
static

Definition at line 1438 of file SimplifyLibCalls.cpp.

References llvm::CallInst::hasFnAttr().

static Value* optimizeBinaryDoubleFP ( CallInst *  CI,
IRBuilder<> &  B 
)
static
static Value* optimizeUnaryDoubleFP ( CallInst *  CI,
IRBuilder<> &  B,
bool  CheckRetType 
)
static
static Value* replaceUnaryCall ( CallInst *  CI,
IRBuilder<> &  B,
Intrinsic::ID  IID 
)
static
static 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 900 of file SimplifyLibCalls.cpp.

References llvm::APFloat::convert(), F, llvm::ConstantFP::get(), llvm::Value::getType(), llvm::APFloatBase::IEEEsingle(), llvm::Type::isFloatTy(), and llvm::APFloatBase::rmNearestTiesToEven.

Referenced by optimizeBinaryDoubleFP(), and optimizeUnaryDoubleFP().

Variable Documentation

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"))
static