LLVM
15.0.0git
|
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
Go to the source code of this file.
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")) |
|
static |
Definition at line 129 of file SimplifyLibCalls.cpp.
References llvm::CallBase::addParamAttr(), F, llvm::CallBase::getArgOperand(), llvm::CallBase::getCaller(), llvm::Value::getContext(), llvm::CallBase::getParamDereferenceableBytes(), llvm::CallBase::getParamDereferenceableOrNullBytes(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::Attribute::getWithDereferenceableBytes(), llvm::max(), llvm::NullPointerIsDefined(), llvm::CallBase::paramHasAttr(), and llvm::CallBase::removeParamAttr().
Referenced by annotateNonNullAndDereferenceable(), and annotateNonNullNoUndefBasedOnAccess().
|
static |
Definition at line 175 of file SimplifyLibCalls.cpp.
References annotateDereferenceableBytes(), annotateNonNullNoUndefBasedOnAccess(), DL, llvm::isKnownNonZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::min(), X, and Y.
|
static |
Definition at line 154 of file SimplifyLibCalls.cpp.
References llvm::CallBase::addParamAttr(), annotateDereferenceableBytes(), F, llvm::CallBase::getArgOperand(), llvm::CallBase::getCaller(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::NullPointerIsDefined(), and llvm::CallBase::paramHasAttr().
Referenced by annotateNonNullAndDereferenceable().
Definition at line 66 of file SimplifyLibCalls.cpp.
References llvm::any_of(), and llvm::User::operands().
Definition at line 72 of file SimplifyLibCalls.cpp.
References llvm::any_of(), and llvm::User::operands().
|
static |
Definition at line 115 of file SimplifyLibCalls.cpp.
References Align, DL, llvm::Instruction::getFunction(), llvm::Function::hasFnAttribute(), llvm::isDereferenceableAndAlignedPointer(), and isOnlyUsedInComparisonWithZero().
Definition at line 78 of file SimplifyLibCalls.cpp.
References llvm::sampleprof::Base.
Definition at line 196 of file SimplifyLibCalls.cpp.
References assert(), llvm::CallInst::getTailCallKind(), llvm::CallInst::isMustTailCall(), and llvm::CallInst::isNoTailCall().
Referenced by optimizeTrigReflections(), and replaceUnaryCall().
|
static |
Definition at line 1778 of file SimplifyLibCalls.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, B, llvm::sampleprof::Base, F, llvm::Intrinsic::getDeclaration(), llvm::Value::getType(), M, and powi().
|
static |
Definition at line 1531 of file SimplifyLibCalls.cpp.
References B, and llvm::BitWidth.
|
static |
Definition at line 1504 of file SimplifyLibCalls.cpp.
|
static |
Definition at line 1703 of file SimplifyLibCalls.cpp.
References Attrs, B, llvm::emitUnaryFloatFnCall(), llvm::Intrinsic::getDeclaration(), llvm::Value::getType(), llvm::hasFloatFn(), and M.
|
static |
Definition at line 49 of file SimplifyLibCalls.cpp.
Referenced by llvm::FortifiedLibCallSimplifier::optimizeCall(), and llvm::LibCallSimplifier::optimizeCall().
|
static |
Definition at line 2230 of file SimplifyLibCalls.cpp.
References Arg, assert(), B, llvm::BasicBlock::begin(), Callee, llvm::ConstantInt::get(), llvm::StructType::get(), llvm::FixedVectorType::get(), llvm::Function::getAttributes(), llvm::TargetLibraryInfo::getLibFunc(), llvm::getOrInsertLibFunc(), llvm::GlobalValue::getParent(), llvm::Module::getTargetTriple(), llvm::Value::getType(), llvm::isLibFuncEmittable(), llvm::Type::isStructTy(), M, llvm::Triple::x86, and llvm::Triple::x86_64.
|
static |
Definition at line 103 of file SimplifyLibCalls.cpp.
References llvm::Value::users().
Referenced by canTransformToMemCmp().
Return true if it is only used in equality comparisons with With.
Definition at line 55 of file SimplifyLibCalls.cpp.
References llvm::Value::users().
Definition at line 2475 of file SimplifyLibCalls.cpp.
References llvm::CallBase::arg_size(), Callee, llvm::CallBase::getArgOperand(), llvm::Value::getName(), llvm::LoadInst::getPointerOperand(), and llvm::GlobalValue::isDeclaration().
|
static |
Definition at line 2222 of file SimplifyLibCalls.cpp.
References llvm::CallBase::hasFnAttr().
|
static |
Shrink double -> float for binary functions.
Definition at line 1431 of file SimplifyLibCalls.cpp.
References B, and optimizeDoubleFP().
|
static |
Shrink double -> float functions.
Definition at line 1364 of file SimplifyLibCalls.cpp.
References B, llvm::StringRef::back(), llvm::emitBinaryFloatFnCall(), llvm::emitUnaryFloatFnCall(), llvm::StringRef::empty(), llvm::CallBase::getArgOperand(), llvm::Function::getAttributes(), llvm::CallBase::getCalledFunction(), llvm::Intrinsic::getDeclaration(), llvm::Instruction::getFastMathFlags(), llvm::Instruction::getFunction(), llvm::Function::getIntrinsicID(), llvm::Instruction::getModule(), llvm::Value::getName(), llvm::Value::getType(), isBinary(), llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), llvm::Function::isIntrinsic(), M, llvm::StringRef::size(), llvm::StringRef::startswith(), llvm::Value::users(), and valueHasFloatPrecision().
Referenced by optimizeBinaryDoubleFP(), and optimizeUnaryDoubleFP().
|
static |
Definition at line 1091 of file SimplifyLibCalls.cpp.
References B, llvm::castToCStr(), llvm::ConstantFoldLoadFromConstPtr(), llvm::StringRef::data(), DL, llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::ConstantExpr::getBitCast(), llvm::getConstantStringInfo(), llvm::Value::getContext(), llvm::getKnownAlignment(), llvm::Constant::getNullValue(), llvm::Type::getPointerAddressSpace(), llvm::Type::getPointerTo(), llvm::Value::getType(), llvm::isOnlyUsedInZeroEqualityComparison(), LHS, memcmp, llvm::MipsISD::Ret, RHS, and llvm::StringRef::size().
|
static |
Definition at line 1467 of file SimplifyLibCalls.cpp.
References B, copyFlags(), llvm::PatternMatch::m_FNeg(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
|
static |
Shrink double -> float for unary functions.
Definition at line 1424 of file SimplifyLibCalls.cpp.
References B, and optimizeDoubleFP().
|
static |
Definition at line 1327 of file SimplifyLibCalls.cpp.
References B, copyFlags(), F, llvm::CallBase::getArgOperand(), llvm::Intrinsic::getDeclaration(), llvm::Instruction::getFastMathFlags(), llvm::Instruction::getModule(), llvm::Value::getType(), M, and llvm::Value::takeName().
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 1346 of file SimplifyLibCalls.cpp.
References F, llvm::ConstantFP::get(), llvm::APFloatBase::IEEEsingle(), and llvm::APFloatBase::rmNearestTiesToEven.
Referenced by optimizeDoubleFP().