|
LLVM
4.0.0
|
#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/Transforms/Utils/BuildLibCalls.h"#include "llvm/Transforms/Utils/Local.h"Go to the source code of this file.
Functions | |
| static bool | ignoreCallingConv (LibFunc::Func Func) |
| static bool | isCallingConvCCompatible (CallInst *CI) |
| static bool | isOnlyUsedInZeroEqualityComparison (Value *V) |
| Return true if it only matters that the value is equal or not-equal to zero. More... | |
| 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::Func DoubleFn, LibFunc::Func FloatFn, LibFunc::Func LongDoubleFn) |
| Check whether the overloaded unary floating point function corresponding to Ty is available. More... | |
| static Value * | emitCalloc (Value *Num, Value *Size, const AttributeSet &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 * | 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 > | ColdErrorCalls ("error-reporting-is-cold", cl::init(true), cl::Hidden, cl::desc("Treat error-reporting calls as cold")) |
| 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")) |
Definition at line 117 of file SimplifyLibCalls.cpp.
References llvm::any_of(), and llvm::User::operands().
|
static |
Definition at line 812 of file SimplifyLibCalls.cpp.
References llvm::IRBuilder< T, Inserter >::CreateCall(), F, llvm::BasicBlock::getContext(), llvm::Module::getDataLayout(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::DataLayout::getIntPtrType(), llvm::TargetLibraryInfo::getLibFunc(), llvm::BasicBlock::getModule(), llvm::Module::getOrInsertFunction(), llvm::TargetLibraryInfo::has(), llvm::CallInst::setCallingConv(), and llvm::Value::stripPointerCasts().
Referenced by foldMallocMemset().
|
static |
Fold memset[_chk](malloc(n), 0, n) –> calloc(1, n).
Definition at line 832 of file SimplifyLibCalls.cpp.
References B, llvm::dyn_cast(), emitCalloc(), llvm::ConstantInt::get(), llvm::CallInst::getArgOperand(), llvm::BasicBlock::getContext(), llvm::IRBuilderBase::GetInsertBlock(), llvm::DataLayout::getIntPtrType(), llvm::TargetLibraryInfo::getLibFunc(), llvm::TargetLibraryInfo::has(), llvm::Value::replaceAllUsesWith(), and llvm::IRBuilderBase::SetInsertPoint().
Definition at line 995 of file SimplifyLibCalls.cpp.
References assert(), and llvm::IRBuilder< T, Inserter >::CreateFMul().
|
static |
Check whether the overloaded unary floating point function corresponding to Ty is available.
Definition at line 125 of file SimplifyLibCalls.cpp.
References llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::getTypeID(), and llvm::TargetLibraryInfo::has().
|
static |
Definition at line 54 of file SimplifyLibCalls.cpp.
References llvm::abs().
Referenced by llvm::FortifiedLibCallSimplifier::optimizeCall(), and llvm::LibCallSimplifier::optimizeCall().
|
static |
Definition at line 1406 of file SimplifyLibCalls.cpp.
References assert(), llvm::BasicBlock::begin(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateExtractElement(), llvm::IRBuilder< T, Inserter >::CreateExtractValue(), llvm::ConstantInt::get(), llvm::StructType::get(), llvm::VectorType::get(), llvm::Function::getAttributes(), llvm::Function::getEntryBlock(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32Ty(), llvm::Module::getOrInsertFunction(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Module::getTargetTriple(), llvm::Value::getType(), llvm::Type::isStructTy(), llvm::IRBuilderBase::SetInsertPoint(), T, llvm::Triple::x86, and llvm::Triple::x86_64.
Definition at line 59 of file SimplifyLibCalls.cpp.
References llvm::CallingConv::ARM_AAPCS, llvm::CallingConv::ARM_AAPCS_VFP, llvm::CallingConv::ARM_APCS, llvm::CallingConv::C, llvm::CallInst::getCallingConv(), llvm::CallInst::getFunctionType(), llvm::Instruction::getModule(), and llvm::Module::getTargetTriple().
Referenced by llvm::FortifiedLibCallSimplifier::optimizeCall(), and llvm::LibCallSimplifier::optimizeCall().
Return true if it is only used in equality comparisons with With.
Definition at line 106 of file SimplifyLibCalls.cpp.
References llvm::Value::users().
Return true if it only matters that the value is equal or not-equal to zero.
Definition at line 92 of file SimplifyLibCalls.cpp.
References C, and llvm::Value::users().
Definition at line 1618 of file SimplifyLibCalls.cpp.
References ColdErrorCalls, llvm::dyn_cast(), llvm::CallInst::getArgOperand(), llvm::Value::getName(), llvm::CallInst::getNumArgOperands(), llvm::LoadInst::getPointerOperand(), and llvm::GlobalValue::isDeclaration().
Definition at line 1398 of file SimplifyLibCalls.cpp.
References llvm::CallInst::hasFnAttr().
Shrink double -> float for binary functions like 'fmin/fmax'.
Definition at line 952 of file SimplifyLibCalls.cpp.
References B, llvm::IRBuilder< T, Inserter >::CreateFPExt(), llvm::emitBinaryFloatFnCall(), llvm::CallInst::getArgOperand(), llvm::Function::getAttributes(), llvm::CallInst::getCalledFunction(), llvm::IRBuilderBase::getDoubleTy(), llvm::Instruction::getFastMathFlags(), llvm::Value::getName(), llvm::Value::getType(), llvm::Type::isDoubleTy(), llvm::IRBuilderBase::setFastMathFlags(), llvm::NVPTX::PTXLdStInstCode::V2, and valueHasFloatPrecision().
Referenced by llvm::LibCallSimplifier::optimizeCall().
Shrink double -> float for unary functions like 'floor'.
Definition at line 912 of file SimplifyLibCalls.cpp.
References B, llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateFPExt(), llvm::dyn_cast(), llvm::emitUnaryFloatFnCall(), F, llvm::CallInst::getArgOperand(), llvm::Function::getAttributes(), llvm::CallInst::getCalledFunction(), llvm::Intrinsic::getDeclaration(), llvm::IRBuilderBase::getDoubleTy(), llvm::Instruction::getFastMathFlags(), llvm::IRBuilderBase::getFloatTy(), llvm::Function::getIntrinsicID(), llvm::Instruction::getModule(), llvm::Value::getName(), llvm::Value::getType(), llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::Function::isIntrinsic(), llvm::IRBuilderBase::setFastMathFlags(), llvm::Value::users(), and valueHasFloatPrecision().
Referenced by llvm::LibCallSimplifier::optimizeCall().
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 894 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().
|
static |
Referenced by isReportingError().
1.8.6