LLVM 17.0.0git
|
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallString.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/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <cmath>
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 215 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::NullPointerIsDefined(), llvm::CallBase::paramHasAttr(), and llvm::CallBase::removeParamAttr().
Referenced by annotateNonNullAndDereferenceable(), and annotateNonNullNoUndefBasedOnAccess().
|
static |
Definition at line 262 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(), Size, X, and Y.
|
static |
Definition at line 240 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 68 of file SimplifyLibCalls.cpp.
References llvm::any_of(), and llvm::User::operands().
Definition at line 74 of file SimplifyLibCalls.cpp.
References llvm::any_of(), and llvm::User::operands().
|
static |
Definition at line 201 of file SimplifyLibCalls.cpp.
References DL, llvm::Instruction::getFunction(), llvm::Function::hasFnAttribute(), llvm::isDereferenceableAndAlignedPointer(), and isOnlyUsedInComparisonWithZero().
|
static |
Definition at line 87 of file SimplifyLibCalls.cpp.
References B, llvm::sampleprof::Base, llvm::ConstantInt::get(), llvm::CallBase::getArgOperand(), llvm::Value::getType(), isDigit(), llvm::maxIntN(), llvm::maxUIntN(), llvm::Offset, RetTy, and llvm::SaturatingMultiplyAdd().
Definition at line 283 of file SimplifyLibCalls.cpp.
References assert(), llvm::CallInst::getTailCallKind(), llvm::CallInst::isMustTailCall(), and llvm::CallInst::isNoTailCall().
Referenced by mergeAttributesAndFlags(), optimizeTrigReflections(), and replaceUnaryCall().
|
static |
Definition at line 2092 of file SimplifyLibCalls.cpp.
References B, llvm::sampleprof::Base, F, llvm::Intrinsic::getDeclaration(), and llvm::Value::getType().
|
static |
Definition at line 1840 of file SimplifyLibCalls.cpp.
References B, and llvm::BitWidth.
|
static |
Definition at line 2017 of file SimplifyLibCalls.cpp.
References B, llvm::emitUnaryFloatFnCall(), llvm::Intrinsic::getDeclaration(), and llvm::hasFloatFn().
Definition at line 51 of file SimplifyLibCalls.cpp.
Referenced by llvm::FortifiedLibCallSimplifier::optimizeCall(), and llvm::LibCallSimplifier::optimizeCall().
|
static |
Definition at line 2535 of file SimplifyLibCalls.cpp.
References Arg, assert(), B, llvm::BasicBlock::begin(), Callee, llvm::StructType::get(), llvm::FixedVectorType::get(), llvm::ConstantInt::get(), llvm::Function::getAttributes(), llvm::TargetLibraryInfo::getLibFunc(), llvm::getOrInsertLibFunc(), llvm::GlobalValue::getParent(), llvm::Module::getTargetTriple(), llvm::Value::getType(), llvm::isLibFuncEmittable(), llvm::Type::isStructTy(), Name, llvm::Triple::x86, and llvm::Triple::x86_64.
Definition at line 189 of file SimplifyLibCalls.cpp.
References llvm::CallingConv::C.
Referenced by canTransformToMemCmp().
Return true if it is only used in equality comparisons with With.
Definition at line 57 of file SimplifyLibCalls.cpp.
Definition at line 2795 of file SimplifyLibCalls.cpp.
References llvm::CallBase::arg_size(), Callee, llvm::CallBase::getArgOperand(), llvm::Value::getName(), llvm::LoadInst::getPointerOperand(), and llvm::GlobalValue::isDeclaration().
Definition at line 2528 of file SimplifyLibCalls.cpp.
References llvm::CallBase::doesNotAccessMemory(), and llvm::CallBase::doesNotThrow().
|
static |
Definition at line 395 of file SimplifyLibCalls.cpp.
References llvm::And, B, llvm::ConstantInt::get(), llvm::CallBase::getArgOperand(), llvm::Constant::getNullValue(), and llvm::Value::getType().
Definition at line 291 of file SimplifyLibCalls.cpp.
References copyFlags(), llvm::AttributeList::get(), llvm::Value::getContext(), llvm::Value::getType(), llvm::CallBase::removeRetAttrs(), llvm::CallBase::setAttributes(), and llvm::AttributeFuncs::typeIncompatible().
|
static |
Shrink double -> float for binary functions.
Definition at line 1765 of file SimplifyLibCalls.cpp.
References B, and optimizeDoubleFP().
|
static |
Shrink double -> float functions.
Definition at line 1698 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(), llvm::StringRef::size(), llvm::StringRef::startswith(), llvm::Value::users(), and valueHasFloatPrecision().
Referenced by optimizeBinaryDoubleFP(), and optimizeUnaryDoubleFP().
|
static |
Definition at line 1458 of file SimplifyLibCalls.cpp.
References B, llvm::castToCStr(), llvm::ConstantFoldLoadFromConstPtr(), DL, llvm::IntegerType::get(), llvm::ConstantExpr::getBitCast(), llvm::Value::getContext(), llvm::getKnownAlignment(), llvm::Constant::getNullValue(), llvm::Type::getPointerAddressSpace(), llvm::Type::getPointerTo(), llvm::Value::getType(), llvm::isOnlyUsedInZeroEqualityComparison(), LHS, and RHS.
|
static |
Definition at line 1416 of file SimplifyLibCalls.cpp.
References B, llvm::ConstantInt::get(), llvm::getConstantStringInfo(), llvm::Constant::getNullValue(), llvm::Value::getType(), llvm::CmpInst::ICMP_ULE, LHS, RHS, llvm::StringRef::size(), and Size.
|
static |
Definition at line 1801 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 1758 of file SimplifyLibCalls.cpp.
References B, and optimizeDoubleFP().
|
static |
Definition at line 1661 of file SimplifyLibCalls.cpp.
References B, copyFlags(), F, llvm::CallBase::getArgOperand(), llvm::Intrinsic::getDeclaration(), llvm::Instruction::getFastMathFlags(), llvm::Instruction::getModule(), llvm::Value::getType(), and llvm::Value::takeName().
Definition at line 299 of file SimplifyLibCalls.cpp.
Referenced by llvm::StringRef::consume_back(), llvm::StringRef::consume_back_insensitive(), llvm::StringRef::consume_front(), llvm::StringRef::consume_front_insensitive(), llvm::StringRef::drop_back(), llvm::StringRef::drop_front(), llvm::StringRef::drop_until(), llvm::StringRef::drop_while(), llvm::X86TargetLowering::ExpandInlineAsm(), llvm::object::MachOObjectFile::getSectionContents(), llvm::streamFile(), llvm::StringRef::take_until(), and llvm::StringRef::take_while().
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 1680 of file SimplifyLibCalls.cpp.
References F, llvm::ConstantFP::get(), llvm::APFloatBase::IEEEsingle(), and llvm::APFloatBase::rmNearestTiesToEven.
Referenced by optimizeDoubleFP().
|
static |
Referenced by llvm::LibCallSimplifier::optimizeCall().