mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-23 11:49:50 +00:00
[Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC)
Summary: The LibFunc::Func enum holds enumerators named for libc functions. Unfortunately, there are real situations, including libc implementations, where function names are actually macros (musl uses "#define fopen64 fopen", for example; any other transitively visible macro would have similar effects). Strictly speaking, a conforming C++ Standard Library should provide any such macros as functions instead (via <cstdio>). However, there are some "library" functions which are not part of the standard, and thus not subject to this rule (fopen64, for example). So, in order to be both portable and consistent, the enum should not use the bare function names. The old enum naming used a namespace LibFunc and an enum Func, with bare enumerators. This patch changes LibFunc to be an enum with enumerators prefixed with "LibFFunc_". (Unfortunately, a scoped enum is not sufficient to override macros.) There are additional changes required in clang. Reviewers: rsmith Subscribers: mehdi_amini, mzolotukhin, nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D28476 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292848 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
50ca9e146b
commit
32028c8f08
@ -20,7 +20,7 @@
|
||||
// One of TLI_DEFINE_ENUM/STRING are defined.
|
||||
|
||||
#if defined(TLI_DEFINE_ENUM)
|
||||
#define TLI_DEFINE_ENUM_INTERNAL(enum_variant) enum_variant,
|
||||
#define TLI_DEFINE_ENUM_INTERNAL(enum_variant) LibFunc_##enum_variant,
|
||||
#define TLI_DEFINE_STRING_INTERNAL(string_repr)
|
||||
#else
|
||||
#define TLI_DEFINE_ENUM_INTERNAL(enum_variant)
|
||||
|
@ -30,14 +30,12 @@ struct VecDesc {
|
||||
unsigned VectorizationFactor;
|
||||
};
|
||||
|
||||
namespace LibFunc {
|
||||
enum Func {
|
||||
enum LibFunc {
|
||||
#define TLI_DEFINE_ENUM
|
||||
#include "llvm/Analysis/TargetLibraryInfo.def"
|
||||
|
||||
NumLibFuncs
|
||||
};
|
||||
}
|
||||
NumLibFuncs
|
||||
};
|
||||
|
||||
/// Implementation of the target library information.
|
||||
///
|
||||
@ -48,9 +46,9 @@ struct VecDesc {
|
||||
class TargetLibraryInfoImpl {
|
||||
friend class TargetLibraryInfo;
|
||||
|
||||
unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4];
|
||||
unsigned char AvailableArray[(NumLibFuncs+3)/4];
|
||||
llvm::DenseMap<unsigned, std::string> CustomNames;
|
||||
static StringRef const StandardNames[LibFunc::NumLibFuncs];
|
||||
static StringRef const StandardNames[NumLibFuncs];
|
||||
bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param;
|
||||
|
||||
enum AvailabilityState {
|
||||
@ -58,11 +56,11 @@ class TargetLibraryInfoImpl {
|
||||
CustomName = 1,
|
||||
Unavailable = 0 // (memset to all zeros)
|
||||
};
|
||||
void setState(LibFunc::Func F, AvailabilityState State) {
|
||||
void setState(LibFunc F, AvailabilityState State) {
|
||||
AvailableArray[F/4] &= ~(3 << 2*(F&3));
|
||||
AvailableArray[F/4] |= State << 2*(F&3);
|
||||
}
|
||||
AvailabilityState getState(LibFunc::Func F) const {
|
||||
AvailabilityState getState(LibFunc F) const {
|
||||
return static_cast<AvailabilityState>((AvailableArray[F/4] >> 2*(F&3)) & 3);
|
||||
}
|
||||
|
||||
@ -74,7 +72,7 @@ class TargetLibraryInfoImpl {
|
||||
|
||||
/// Return true if the function type FTy is valid for the library function
|
||||
/// F, regardless of whether the function is available.
|
||||
bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc::Func F,
|
||||
bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
|
||||
const DataLayout *DL) const;
|
||||
|
||||
public:
|
||||
@ -104,28 +102,28 @@ public:
|
||||
///
|
||||
/// If it is one of the known library functions, return true and set F to the
|
||||
/// corresponding value.
|
||||
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const;
|
||||
bool getLibFunc(StringRef funcName, LibFunc &F) const;
|
||||
|
||||
/// Searches for a particular function name, also checking that its type is
|
||||
/// valid for the library function matching that name.
|
||||
///
|
||||
/// If it is one of the known library functions, return true and set F to the
|
||||
/// corresponding value.
|
||||
bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const;
|
||||
bool getLibFunc(const Function &FDecl, LibFunc &F) const;
|
||||
|
||||
/// Forces a function to be marked as unavailable.
|
||||
void setUnavailable(LibFunc::Func F) {
|
||||
void setUnavailable(LibFunc F) {
|
||||
setState(F, Unavailable);
|
||||
}
|
||||
|
||||
/// Forces a function to be marked as available.
|
||||
void setAvailable(LibFunc::Func F) {
|
||||
void setAvailable(LibFunc F) {
|
||||
setState(F, StandardName);
|
||||
}
|
||||
|
||||
/// Forces a function to be marked as available and provide an alternate name
|
||||
/// that must be used.
|
||||
void setAvailableWithName(LibFunc::Func F, StringRef Name) {
|
||||
void setAvailableWithName(LibFunc F, StringRef Name) {
|
||||
if (StandardNames[F] != Name) {
|
||||
setState(F, CustomName);
|
||||
CustomNames[F] = Name;
|
||||
@ -225,16 +223,16 @@ public:
|
||||
///
|
||||
/// If it is one of the known library functions, return true and set F to the
|
||||
/// corresponding value.
|
||||
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const {
|
||||
bool getLibFunc(StringRef funcName, LibFunc &F) const {
|
||||
return Impl->getLibFunc(funcName, F);
|
||||
}
|
||||
|
||||
bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const {
|
||||
bool getLibFunc(const Function &FDecl, LibFunc &F) const {
|
||||
return Impl->getLibFunc(FDecl, F);
|
||||
}
|
||||
|
||||
/// Tests whether a library function is available.
|
||||
bool has(LibFunc::Func F) const {
|
||||
bool has(LibFunc F) const {
|
||||
return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
|
||||
}
|
||||
bool isFunctionVectorizable(StringRef F, unsigned VF) const {
|
||||
@ -249,37 +247,37 @@ public:
|
||||
|
||||
/// Tests if the function is both available and a candidate for optimized code
|
||||
/// generation.
|
||||
bool hasOptimizedCodeGen(LibFunc::Func F) const {
|
||||
bool hasOptimizedCodeGen(LibFunc F) const {
|
||||
if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable)
|
||||
return false;
|
||||
switch (F) {
|
||||
default: break;
|
||||
case LibFunc::copysign: case LibFunc::copysignf: case LibFunc::copysignl:
|
||||
case LibFunc::fabs: case LibFunc::fabsf: case LibFunc::fabsl:
|
||||
case LibFunc::sin: case LibFunc::sinf: case LibFunc::sinl:
|
||||
case LibFunc::cos: case LibFunc::cosf: case LibFunc::cosl:
|
||||
case LibFunc::sqrt: case LibFunc::sqrtf: case LibFunc::sqrtl:
|
||||
case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite:
|
||||
case LibFunc::sqrtl_finite:
|
||||
case LibFunc::fmax: case LibFunc::fmaxf: case LibFunc::fmaxl:
|
||||
case LibFunc::fmin: case LibFunc::fminf: case LibFunc::fminl:
|
||||
case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl:
|
||||
case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl:
|
||||
case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill:
|
||||
case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl:
|
||||
case LibFunc::round: case LibFunc::roundf: case LibFunc::roundl:
|
||||
case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl:
|
||||
case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l:
|
||||
case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l:
|
||||
case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy:
|
||||
case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen:
|
||||
case LibFunc::memchr: case LibFunc::mempcpy:
|
||||
case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl:
|
||||
case LibFunc_fabs: case LibFunc_fabsf: case LibFunc_fabsl:
|
||||
case LibFunc_sin: case LibFunc_sinf: case LibFunc_sinl:
|
||||
case LibFunc_cos: case LibFunc_cosf: case LibFunc_cosl:
|
||||
case LibFunc_sqrt: case LibFunc_sqrtf: case LibFunc_sqrtl:
|
||||
case LibFunc_sqrt_finite: case LibFunc_sqrtf_finite:
|
||||
case LibFunc_sqrtl_finite:
|
||||
case LibFunc_fmax: case LibFunc_fmaxf: case LibFunc_fmaxl:
|
||||
case LibFunc_fmin: case LibFunc_fminf: case LibFunc_fminl:
|
||||
case LibFunc_floor: case LibFunc_floorf: case LibFunc_floorl:
|
||||
case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_nearbyintl:
|
||||
case LibFunc_ceil: case LibFunc_ceilf: case LibFunc_ceill:
|
||||
case LibFunc_rint: case LibFunc_rintf: case LibFunc_rintl:
|
||||
case LibFunc_round: case LibFunc_roundf: case LibFunc_roundl:
|
||||
case LibFunc_trunc: case LibFunc_truncf: case LibFunc_truncl:
|
||||
case LibFunc_log2: case LibFunc_log2f: case LibFunc_log2l:
|
||||
case LibFunc_exp2: case LibFunc_exp2f: case LibFunc_exp2l:
|
||||
case LibFunc_memcmp: case LibFunc_strcmp: case LibFunc_strcpy:
|
||||
case LibFunc_stpcpy: case LibFunc_strlen: case LibFunc_strnlen:
|
||||
case LibFunc_memchr: case LibFunc_mempcpy:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
StringRef getName(LibFunc::Func F) const {
|
||||
StringRef getName(LibFunc F) const {
|
||||
auto State = Impl->getState(F);
|
||||
if (State == TargetLibraryInfoImpl::Unavailable)
|
||||
return StringRef();
|
||||
|
@ -56,8 +56,8 @@ private:
|
||||
Value *optimizeMemSetChk(CallInst *CI, IRBuilder<> &B);
|
||||
|
||||
// Str/Stp cpy are similar enough to be handled in the same functions.
|
||||
Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func);
|
||||
Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func);
|
||||
Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func);
|
||||
Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func);
|
||||
|
||||
/// \brief Checks whether the call \p CI to a fortified libcall is foldable
|
||||
/// to the non-fortified version.
|
||||
|
@ -644,9 +644,9 @@ static bool isWriteOnlyParam(ImmutableCallSite CS, unsigned ArgIdx,
|
||||
// whenever possible.
|
||||
// FIXME Consider handling this in InferFunctionAttr.cpp together with other
|
||||
// attributes.
|
||||
LibFunc::Func F;
|
||||
LibFunc F;
|
||||
if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) &&
|
||||
F == LibFunc::memset_pattern16 && TLI.has(F))
|
||||
F == LibFunc_memset_pattern16 && TLI.has(F))
|
||||
if (ArgIdx == 0)
|
||||
return true;
|
||||
|
||||
|
@ -1639,74 +1639,74 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
|
||||
|
||||
switch (Name[0]) {
|
||||
case 'a':
|
||||
if ((Name == "acos" && TLI->has(LibFunc::acos)) ||
|
||||
(Name == "acosf" && TLI->has(LibFunc::acosf)))
|
||||
if ((Name == "acos" && TLI->has(LibFunc_acos)) ||
|
||||
(Name == "acosf" && TLI->has(LibFunc_acosf)))
|
||||
return ConstantFoldFP(acos, V, Ty);
|
||||
else if ((Name == "asin" && TLI->has(LibFunc::asin)) ||
|
||||
(Name == "asinf" && TLI->has(LibFunc::asinf)))
|
||||
else if ((Name == "asin" && TLI->has(LibFunc_asin)) ||
|
||||
(Name == "asinf" && TLI->has(LibFunc_asinf)))
|
||||
return ConstantFoldFP(asin, V, Ty);
|
||||
else if ((Name == "atan" && TLI->has(LibFunc::atan)) ||
|
||||
(Name == "atanf" && TLI->has(LibFunc::atanf)))
|
||||
else if ((Name == "atan" && TLI->has(LibFunc_atan)) ||
|
||||
(Name == "atanf" && TLI->has(LibFunc_atanf)))
|
||||
return ConstantFoldFP(atan, V, Ty);
|
||||
break;
|
||||
case 'c':
|
||||
if ((Name == "ceil" && TLI->has(LibFunc::ceil)) ||
|
||||
(Name == "ceilf" && TLI->has(LibFunc::ceilf)))
|
||||
if ((Name == "ceil" && TLI->has(LibFunc_ceil)) ||
|
||||
(Name == "ceilf" && TLI->has(LibFunc_ceilf)))
|
||||
return ConstantFoldFP(ceil, V, Ty);
|
||||
else if ((Name == "cos" && TLI->has(LibFunc::cos)) ||
|
||||
(Name == "cosf" && TLI->has(LibFunc::cosf)))
|
||||
else if ((Name == "cos" && TLI->has(LibFunc_cos)) ||
|
||||
(Name == "cosf" && TLI->has(LibFunc_cosf)))
|
||||
return ConstantFoldFP(cos, V, Ty);
|
||||
else if ((Name == "cosh" && TLI->has(LibFunc::cosh)) ||
|
||||
(Name == "coshf" && TLI->has(LibFunc::coshf)))
|
||||
else if ((Name == "cosh" && TLI->has(LibFunc_cosh)) ||
|
||||
(Name == "coshf" && TLI->has(LibFunc_coshf)))
|
||||
return ConstantFoldFP(cosh, V, Ty);
|
||||
break;
|
||||
case 'e':
|
||||
if ((Name == "exp" && TLI->has(LibFunc::exp)) ||
|
||||
(Name == "expf" && TLI->has(LibFunc::expf)))
|
||||
if ((Name == "exp" && TLI->has(LibFunc_exp)) ||
|
||||
(Name == "expf" && TLI->has(LibFunc_expf)))
|
||||
return ConstantFoldFP(exp, V, Ty);
|
||||
if ((Name == "exp2" && TLI->has(LibFunc::exp2)) ||
|
||||
(Name == "exp2f" && TLI->has(LibFunc::exp2f)))
|
||||
if ((Name == "exp2" && TLI->has(LibFunc_exp2)) ||
|
||||
(Name == "exp2f" && TLI->has(LibFunc_exp2f)))
|
||||
// Constant fold exp2(x) as pow(2,x) in case the host doesn't have a
|
||||
// C99 library.
|
||||
return ConstantFoldBinaryFP(pow, 2.0, V, Ty);
|
||||
break;
|
||||
case 'f':
|
||||
if ((Name == "fabs" && TLI->has(LibFunc::fabs)) ||
|
||||
(Name == "fabsf" && TLI->has(LibFunc::fabsf)))
|
||||
if ((Name == "fabs" && TLI->has(LibFunc_fabs)) ||
|
||||
(Name == "fabsf" && TLI->has(LibFunc_fabsf)))
|
||||
return ConstantFoldFP(fabs, V, Ty);
|
||||
else if ((Name == "floor" && TLI->has(LibFunc::floor)) ||
|
||||
(Name == "floorf" && TLI->has(LibFunc::floorf)))
|
||||
else if ((Name == "floor" && TLI->has(LibFunc_floor)) ||
|
||||
(Name == "floorf" && TLI->has(LibFunc_floorf)))
|
||||
return ConstantFoldFP(floor, V, Ty);
|
||||
break;
|
||||
case 'l':
|
||||
if ((Name == "log" && V > 0 && TLI->has(LibFunc::log)) ||
|
||||
(Name == "logf" && V > 0 && TLI->has(LibFunc::logf)))
|
||||
if ((Name == "log" && V > 0 && TLI->has(LibFunc_log)) ||
|
||||
(Name == "logf" && V > 0 && TLI->has(LibFunc_logf)))
|
||||
return ConstantFoldFP(log, V, Ty);
|
||||
else if ((Name == "log10" && V > 0 && TLI->has(LibFunc::log10)) ||
|
||||
(Name == "log10f" && V > 0 && TLI->has(LibFunc::log10f)))
|
||||
else if ((Name == "log10" && V > 0 && TLI->has(LibFunc_log10)) ||
|
||||
(Name == "log10f" && V > 0 && TLI->has(LibFunc_log10f)))
|
||||
return ConstantFoldFP(log10, V, Ty);
|
||||
break;
|
||||
case 'r':
|
||||
if ((Name == "round" && TLI->has(LibFunc::round)) ||
|
||||
(Name == "roundf" && TLI->has(LibFunc::roundf)))
|
||||
if ((Name == "round" && TLI->has(LibFunc_round)) ||
|
||||
(Name == "roundf" && TLI->has(LibFunc_roundf)))
|
||||
return ConstantFoldFP(round, V, Ty);
|
||||
case 's':
|
||||
if ((Name == "sin" && TLI->has(LibFunc::sin)) ||
|
||||
(Name == "sinf" && TLI->has(LibFunc::sinf)))
|
||||
if ((Name == "sin" && TLI->has(LibFunc_sin)) ||
|
||||
(Name == "sinf" && TLI->has(LibFunc_sinf)))
|
||||
return ConstantFoldFP(sin, V, Ty);
|
||||
else if ((Name == "sinh" && TLI->has(LibFunc::sinh)) ||
|
||||
(Name == "sinhf" && TLI->has(LibFunc::sinhf)))
|
||||
else if ((Name == "sinh" && TLI->has(LibFunc_sinh)) ||
|
||||
(Name == "sinhf" && TLI->has(LibFunc_sinhf)))
|
||||
return ConstantFoldFP(sinh, V, Ty);
|
||||
else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc::sqrt)) ||
|
||||
(Name == "sqrtf" && V >= 0 && TLI->has(LibFunc::sqrtf)))
|
||||
else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc_sqrt)) ||
|
||||
(Name == "sqrtf" && V >= 0 && TLI->has(LibFunc_sqrtf)))
|
||||
return ConstantFoldFP(sqrt, V, Ty);
|
||||
break;
|
||||
case 't':
|
||||
if ((Name == "tan" && TLI->has(LibFunc::tan)) ||
|
||||
(Name == "tanf" && TLI->has(LibFunc::tanf)))
|
||||
if ((Name == "tan" && TLI->has(LibFunc_tan)) ||
|
||||
(Name == "tanf" && TLI->has(LibFunc_tanf)))
|
||||
return ConstantFoldFP(tan, V, Ty);
|
||||
else if ((Name == "tanh" && TLI->has(LibFunc::tanh)) ||
|
||||
(Name == "tanhf" && TLI->has(LibFunc::tanhf)))
|
||||
else if ((Name == "tanh" && TLI->has(LibFunc_tanh)) ||
|
||||
(Name == "tanhf" && TLI->has(LibFunc_tanhf)))
|
||||
return ConstantFoldFP(tanh, V, Ty);
|
||||
break;
|
||||
default:
|
||||
@ -1811,14 +1811,14 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
|
||||
|
||||
if (!TLI)
|
||||
return nullptr;
|
||||
if ((Name == "pow" && TLI->has(LibFunc::pow)) ||
|
||||
(Name == "powf" && TLI->has(LibFunc::powf)))
|
||||
if ((Name == "pow" && TLI->has(LibFunc_pow)) ||
|
||||
(Name == "powf" && TLI->has(LibFunc_powf)))
|
||||
return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty);
|
||||
if ((Name == "fmod" && TLI->has(LibFunc::fmod)) ||
|
||||
(Name == "fmodf" && TLI->has(LibFunc::fmodf)))
|
||||
if ((Name == "fmod" && TLI->has(LibFunc_fmod)) ||
|
||||
(Name == "fmodf" && TLI->has(LibFunc_fmodf)))
|
||||
return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty);
|
||||
if ((Name == "atan2" && TLI->has(LibFunc::atan2)) ||
|
||||
(Name == "atan2f" && TLI->has(LibFunc::atan2f)))
|
||||
if ((Name == "atan2" && TLI->has(LibFunc_atan2)) ||
|
||||
(Name == "atan2f" && TLI->has(LibFunc_atan2f)))
|
||||
return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty);
|
||||
} else if (auto *Op2C = dyn_cast<ConstantInt>(Operands[1])) {
|
||||
if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy())
|
||||
@ -2011,7 +2011,7 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
if (!F)
|
||||
return false;
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!TLI || !TLI->getLibFunc(*F, Func))
|
||||
return false;
|
||||
|
||||
@ -2019,20 +2019,20 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
if (ConstantFP *OpC = dyn_cast<ConstantFP>(CS.getArgOperand(0))) {
|
||||
const APFloat &Op = OpC->getValueAPF();
|
||||
switch (Func) {
|
||||
case LibFunc::logl:
|
||||
case LibFunc::log:
|
||||
case LibFunc::logf:
|
||||
case LibFunc::log2l:
|
||||
case LibFunc::log2:
|
||||
case LibFunc::log2f:
|
||||
case LibFunc::log10l:
|
||||
case LibFunc::log10:
|
||||
case LibFunc::log10f:
|
||||
case LibFunc_logl:
|
||||
case LibFunc_log:
|
||||
case LibFunc_logf:
|
||||
case LibFunc_log2l:
|
||||
case LibFunc_log2:
|
||||
case LibFunc_log2f:
|
||||
case LibFunc_log10l:
|
||||
case LibFunc_log10:
|
||||
case LibFunc_log10f:
|
||||
return Op.isNaN() || (!Op.isZero() && !Op.isNegative());
|
||||
|
||||
case LibFunc::expl:
|
||||
case LibFunc::exp:
|
||||
case LibFunc::expf:
|
||||
case LibFunc_expl:
|
||||
case LibFunc_exp:
|
||||
case LibFunc_expf:
|
||||
// FIXME: These boundaries are slightly conservative.
|
||||
if (OpC->getType()->isDoubleTy())
|
||||
return Op.compare(APFloat(-745.0)) != APFloat::cmpLessThan &&
|
||||
@ -2042,9 +2042,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
Op.compare(APFloat(88.0f)) != APFloat::cmpGreaterThan;
|
||||
break;
|
||||
|
||||
case LibFunc::exp2l:
|
||||
case LibFunc::exp2:
|
||||
case LibFunc::exp2f:
|
||||
case LibFunc_exp2l:
|
||||
case LibFunc_exp2:
|
||||
case LibFunc_exp2f:
|
||||
// FIXME: These boundaries are slightly conservative.
|
||||
if (OpC->getType()->isDoubleTy())
|
||||
return Op.compare(APFloat(-1074.0)) != APFloat::cmpLessThan &&
|
||||
@ -2054,17 +2054,17 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
Op.compare(APFloat(127.0f)) != APFloat::cmpGreaterThan;
|
||||
break;
|
||||
|
||||
case LibFunc::sinl:
|
||||
case LibFunc::sin:
|
||||
case LibFunc::sinf:
|
||||
case LibFunc::cosl:
|
||||
case LibFunc::cos:
|
||||
case LibFunc::cosf:
|
||||
case LibFunc_sinl:
|
||||
case LibFunc_sin:
|
||||
case LibFunc_sinf:
|
||||
case LibFunc_cosl:
|
||||
case LibFunc_cos:
|
||||
case LibFunc_cosf:
|
||||
return !Op.isInfinity();
|
||||
|
||||
case LibFunc::tanl:
|
||||
case LibFunc::tan:
|
||||
case LibFunc::tanf: {
|
||||
case LibFunc_tanl:
|
||||
case LibFunc_tan:
|
||||
case LibFunc_tanf: {
|
||||
// FIXME: Stop using the host math library.
|
||||
// FIXME: The computation isn't done in the right precision.
|
||||
Type *Ty = OpC->getType();
|
||||
@ -2075,23 +2075,23 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
break;
|
||||
}
|
||||
|
||||
case LibFunc::asinl:
|
||||
case LibFunc::asin:
|
||||
case LibFunc::asinf:
|
||||
case LibFunc::acosl:
|
||||
case LibFunc::acos:
|
||||
case LibFunc::acosf:
|
||||
case LibFunc_asinl:
|
||||
case LibFunc_asin:
|
||||
case LibFunc_asinf:
|
||||
case LibFunc_acosl:
|
||||
case LibFunc_acos:
|
||||
case LibFunc_acosf:
|
||||
return Op.compare(APFloat(Op.getSemantics(), "-1")) !=
|
||||
APFloat::cmpLessThan &&
|
||||
Op.compare(APFloat(Op.getSemantics(), "1")) !=
|
||||
APFloat::cmpGreaterThan;
|
||||
|
||||
case LibFunc::sinh:
|
||||
case LibFunc::cosh:
|
||||
case LibFunc::sinhf:
|
||||
case LibFunc::coshf:
|
||||
case LibFunc::sinhl:
|
||||
case LibFunc::coshl:
|
||||
case LibFunc_sinh:
|
||||
case LibFunc_cosh:
|
||||
case LibFunc_sinhf:
|
||||
case LibFunc_coshf:
|
||||
case LibFunc_sinhl:
|
||||
case LibFunc_coshl:
|
||||
// FIXME: These boundaries are slightly conservative.
|
||||
if (OpC->getType()->isDoubleTy())
|
||||
return Op.compare(APFloat(-710.0)) != APFloat::cmpLessThan &&
|
||||
@ -2101,9 +2101,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
Op.compare(APFloat(89.0f)) != APFloat::cmpGreaterThan;
|
||||
break;
|
||||
|
||||
case LibFunc::sqrtl:
|
||||
case LibFunc::sqrt:
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc_sqrtl:
|
||||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtf:
|
||||
return Op.isNaN() || Op.isZero() || !Op.isNegative();
|
||||
|
||||
// FIXME: Add more functions: sqrt_finite, atanh, expm1, log1p,
|
||||
@ -2122,9 +2122,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
const APFloat &Op1 = Op1C->getValueAPF();
|
||||
|
||||
switch (Func) {
|
||||
case LibFunc::powl:
|
||||
case LibFunc::pow:
|
||||
case LibFunc::powf: {
|
||||
case LibFunc_powl:
|
||||
case LibFunc_pow:
|
||||
case LibFunc_powf: {
|
||||
// FIXME: Stop using the host math library.
|
||||
// FIXME: The computation isn't done in the right precision.
|
||||
Type *Ty = Op0C->getType();
|
||||
@ -2138,9 +2138,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
|
||||
break;
|
||||
}
|
||||
|
||||
case LibFunc::fmodl:
|
||||
case LibFunc::fmod:
|
||||
case LibFunc::fmodf:
|
||||
case LibFunc_fmodl:
|
||||
case LibFunc_fmod:
|
||||
case LibFunc_fmodf:
|
||||
return Op0.isNaN() || Op1.isNaN() ||
|
||||
(!Op0.isInfinity() && !Op1.isZero());
|
||||
|
||||
|
@ -50,30 +50,30 @@ struct AllocFnsTy {
|
||||
|
||||
// FIXME: certain users need more information. E.g., SimplifyLibCalls needs to
|
||||
// know which functions are nounwind, noalias, nocapture parameters, etc.
|
||||
static const std::pair<LibFunc::Func, AllocFnsTy> AllocationFnData[] = {
|
||||
{LibFunc::malloc, {MallocLike, 1, 0, -1}},
|
||||
{LibFunc::valloc, {MallocLike, 1, 0, -1}},
|
||||
{LibFunc::Znwj, {OpNewLike, 1, 0, -1}}, // new(unsigned int)
|
||||
{LibFunc::ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow)
|
||||
{LibFunc::Znwm, {OpNewLike, 1, 0, -1}}, // new(unsigned long)
|
||||
{LibFunc::ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned long, nothrow)
|
||||
{LibFunc::Znaj, {OpNewLike, 1, 0, -1}}, // new[](unsigned int)
|
||||
{LibFunc::ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow)
|
||||
{LibFunc::Znam, {OpNewLike, 1, 0, -1}}, // new[](unsigned long)
|
||||
{LibFunc::ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned long, nothrow)
|
||||
{LibFunc::msvc_new_int, {OpNewLike, 1, 0, -1}}, // new(unsigned int)
|
||||
{LibFunc::msvc_new_int_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow)
|
||||
{LibFunc::msvc_new_longlong, {OpNewLike, 1, 0, -1}}, // new(unsigned long long)
|
||||
{LibFunc::msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned long long, nothrow)
|
||||
{LibFunc::msvc_new_array_int, {OpNewLike, 1, 0, -1}}, // new[](unsigned int)
|
||||
{LibFunc::msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow)
|
||||
{LibFunc::msvc_new_array_longlong, {OpNewLike, 1, 0, -1}}, // new[](unsigned long long)
|
||||
{LibFunc::msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned long long, nothrow)
|
||||
{LibFunc::calloc, {CallocLike, 2, 0, 1}},
|
||||
{LibFunc::realloc, {ReallocLike, 2, 1, -1}},
|
||||
{LibFunc::reallocf, {ReallocLike, 2, 1, -1}},
|
||||
{LibFunc::strdup, {StrDupLike, 1, -1, -1}},
|
||||
{LibFunc::strndup, {StrDupLike, 2, 1, -1}}
|
||||
static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
|
||||
{LibFunc_malloc, {MallocLike, 1, 0, -1}},
|
||||
{LibFunc_valloc, {MallocLike, 1, 0, -1}},
|
||||
{LibFunc_Znwj, {OpNewLike, 1, 0, -1}}, // new(unsigned int)
|
||||
{LibFunc_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow)
|
||||
{LibFunc_Znwm, {OpNewLike, 1, 0, -1}}, // new(unsigned long)
|
||||
{LibFunc_ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned long, nothrow)
|
||||
{LibFunc_Znaj, {OpNewLike, 1, 0, -1}}, // new[](unsigned int)
|
||||
{LibFunc_ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow)
|
||||
{LibFunc_Znam, {OpNewLike, 1, 0, -1}}, // new[](unsigned long)
|
||||
{LibFunc_ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned long, nothrow)
|
||||
{LibFunc_msvc_new_int, {OpNewLike, 1, 0, -1}}, // new(unsigned int)
|
||||
{LibFunc_msvc_new_int_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow)
|
||||
{LibFunc_msvc_new_longlong, {OpNewLike, 1, 0, -1}}, // new(unsigned long long)
|
||||
{LibFunc_msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned long long, nothrow)
|
||||
{LibFunc_msvc_new_array_int, {OpNewLike, 1, 0, -1}}, // new[](unsigned int)
|
||||
{LibFunc_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow)
|
||||
{LibFunc_msvc_new_array_longlong, {OpNewLike, 1, 0, -1}}, // new[](unsigned long long)
|
||||
{LibFunc_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned long long, nothrow)
|
||||
{LibFunc_calloc, {CallocLike, 2, 0, 1}},
|
||||
{LibFunc_realloc, {ReallocLike, 2, 1, -1}},
|
||||
{LibFunc_reallocf, {ReallocLike, 2, 1, -1}},
|
||||
{LibFunc_strdup, {StrDupLike, 1, -1, -1}},
|
||||
{LibFunc_strndup, {StrDupLike, 2, 1, -1}}
|
||||
// TODO: Handle "int posix_memalign(void **, size_t, size_t)"
|
||||
};
|
||||
|
||||
@ -106,12 +106,12 @@ getAllocationDataForFunction(const Function *Callee, AllocType AllocTy,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
// Make sure that the function is available.
|
||||
StringRef FnName = Callee->getName();
|
||||
LibFunc::Func TLIFn;
|
||||
LibFunc TLIFn;
|
||||
if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
|
||||
return None;
|
||||
|
||||
const auto *Iter = find_if(
|
||||
AllocationFnData, [TLIFn](const std::pair<LibFunc::Func, AllocFnsTy> &P) {
|
||||
AllocationFnData, [TLIFn](const std::pair<LibFunc, AllocFnsTy> &P) {
|
||||
return P.first == TLIFn;
|
||||
});
|
||||
|
||||
@ -333,33 +333,33 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
|
||||
return nullptr;
|
||||
|
||||
StringRef FnName = Callee->getName();
|
||||
LibFunc::Func TLIFn;
|
||||
LibFunc TLIFn;
|
||||
if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
|
||||
return nullptr;
|
||||
|
||||
unsigned ExpectedNumParams;
|
||||
if (TLIFn == LibFunc::free ||
|
||||
TLIFn == LibFunc::ZdlPv || // operator delete(void*)
|
||||
TLIFn == LibFunc::ZdaPv || // operator delete[](void*)
|
||||
TLIFn == LibFunc::msvc_delete_ptr32 || // operator delete(void*)
|
||||
TLIFn == LibFunc::msvc_delete_ptr64 || // operator delete(void*)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr32 || // operator delete[](void*)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr64) // operator delete[](void*)
|
||||
if (TLIFn == LibFunc_free ||
|
||||
TLIFn == LibFunc_ZdlPv || // operator delete(void*)
|
||||
TLIFn == LibFunc_ZdaPv || // operator delete[](void*)
|
||||
TLIFn == LibFunc_msvc_delete_ptr32 || // operator delete(void*)
|
||||
TLIFn == LibFunc_msvc_delete_ptr64 || // operator delete(void*)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr32 || // operator delete[](void*)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64) // operator delete[](void*)
|
||||
ExpectedNumParams = 1;
|
||||
else if (TLIFn == LibFunc::ZdlPvj || // delete(void*, uint)
|
||||
TLIFn == LibFunc::ZdlPvm || // delete(void*, ulong)
|
||||
TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc::ZdaPvj || // delete[](void*, uint)
|
||||
TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong)
|
||||
TLIFn == LibFunc::ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc::msvc_delete_ptr32_int || // delete(void*, uint)
|
||||
TLIFn == LibFunc::msvc_delete_ptr64_longlong || // delete(void*, ulonglong)
|
||||
TLIFn == LibFunc::msvc_delete_ptr32_nothrow || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc::msvc_delete_ptr64_nothrow || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr32_int || // delete[](void*, uint)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc::msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow)
|
||||
else if (TLIFn == LibFunc_ZdlPvj || // delete(void*, uint)
|
||||
TLIFn == LibFunc_ZdlPvm || // delete(void*, ulong)
|
||||
TLIFn == LibFunc_ZdlPvRKSt9nothrow_t || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc_ZdaPvj || // delete[](void*, uint)
|
||||
TLIFn == LibFunc_ZdaPvm || // delete[](void*, ulong)
|
||||
TLIFn == LibFunc_ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_ptr32_int || // delete(void*, uint)
|
||||
TLIFn == LibFunc_msvc_delete_ptr64_longlong || // delete(void*, ulonglong)
|
||||
TLIFn == LibFunc_msvc_delete_ptr32_nothrow || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_ptr64_nothrow || // delete(void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr32_int || // delete[](void*, uint)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow)
|
||||
ExpectedNumParams = 2;
|
||||
else
|
||||
return nullptr;
|
||||
|
@ -142,9 +142,9 @@ MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS,
|
||||
// for memcpy/memset. This is particularly important because the
|
||||
// LoopIdiomRecognizer likes to turn loops into calls to memset_pattern16
|
||||
// whenever possible.
|
||||
LibFunc::Func F;
|
||||
LibFunc F;
|
||||
if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) &&
|
||||
F == LibFunc::memset_pattern16 && TLI.has(F)) {
|
||||
F == LibFunc_memset_pattern16 && TLI.has(F)) {
|
||||
assert((ArgIdx == 0 || ArgIdx == 1) &&
|
||||
"Invalid argument index for memset_pattern16");
|
||||
if (ArgIdx == 1)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2448,7 +2448,7 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS,
|
||||
if (!TLI)
|
||||
return Intrinsic::not_intrinsic;
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
// We're going to make assumptions on the semantics of the functions, check
|
||||
// that the target knows that it's available in this environment and it does
|
||||
// not have local linkage.
|
||||
@ -2463,81 +2463,81 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS,
|
||||
switch (Func) {
|
||||
default:
|
||||
break;
|
||||
case LibFunc::sin:
|
||||
case LibFunc::sinf:
|
||||
case LibFunc::sinl:
|
||||
case LibFunc_sin:
|
||||
case LibFunc_sinf:
|
||||
case LibFunc_sinl:
|
||||
return Intrinsic::sin;
|
||||
case LibFunc::cos:
|
||||
case LibFunc::cosf:
|
||||
case LibFunc::cosl:
|
||||
case LibFunc_cos:
|
||||
case LibFunc_cosf:
|
||||
case LibFunc_cosl:
|
||||
return Intrinsic::cos;
|
||||
case LibFunc::exp:
|
||||
case LibFunc::expf:
|
||||
case LibFunc::expl:
|
||||
case LibFunc_exp:
|
||||
case LibFunc_expf:
|
||||
case LibFunc_expl:
|
||||
return Intrinsic::exp;
|
||||
case LibFunc::exp2:
|
||||
case LibFunc::exp2f:
|
||||
case LibFunc::exp2l:
|
||||
case LibFunc_exp2:
|
||||
case LibFunc_exp2f:
|
||||
case LibFunc_exp2l:
|
||||
return Intrinsic::exp2;
|
||||
case LibFunc::log:
|
||||
case LibFunc::logf:
|
||||
case LibFunc::logl:
|
||||
case LibFunc_log:
|
||||
case LibFunc_logf:
|
||||
case LibFunc_logl:
|
||||
return Intrinsic::log;
|
||||
case LibFunc::log10:
|
||||
case LibFunc::log10f:
|
||||
case LibFunc::log10l:
|
||||
case LibFunc_log10:
|
||||
case LibFunc_log10f:
|
||||
case LibFunc_log10l:
|
||||
return Intrinsic::log10;
|
||||
case LibFunc::log2:
|
||||
case LibFunc::log2f:
|
||||
case LibFunc::log2l:
|
||||
case LibFunc_log2:
|
||||
case LibFunc_log2f:
|
||||
case LibFunc_log2l:
|
||||
return Intrinsic::log2;
|
||||
case LibFunc::fabs:
|
||||
case LibFunc::fabsf:
|
||||
case LibFunc::fabsl:
|
||||
case LibFunc_fabs:
|
||||
case LibFunc_fabsf:
|
||||
case LibFunc_fabsl:
|
||||
return Intrinsic::fabs;
|
||||
case LibFunc::fmin:
|
||||
case LibFunc::fminf:
|
||||
case LibFunc::fminl:
|
||||
case LibFunc_fmin:
|
||||
case LibFunc_fminf:
|
||||
case LibFunc_fminl:
|
||||
return Intrinsic::minnum;
|
||||
case LibFunc::fmax:
|
||||
case LibFunc::fmaxf:
|
||||
case LibFunc::fmaxl:
|
||||
case LibFunc_fmax:
|
||||
case LibFunc_fmaxf:
|
||||
case LibFunc_fmaxl:
|
||||
return Intrinsic::maxnum;
|
||||
case LibFunc::copysign:
|
||||
case LibFunc::copysignf:
|
||||
case LibFunc::copysignl:
|
||||
case LibFunc_copysign:
|
||||
case LibFunc_copysignf:
|
||||
case LibFunc_copysignl:
|
||||
return Intrinsic::copysign;
|
||||
case LibFunc::floor:
|
||||
case LibFunc::floorf:
|
||||
case LibFunc::floorl:
|
||||
case LibFunc_floor:
|
||||
case LibFunc_floorf:
|
||||
case LibFunc_floorl:
|
||||
return Intrinsic::floor;
|
||||
case LibFunc::ceil:
|
||||
case LibFunc::ceilf:
|
||||
case LibFunc::ceill:
|
||||
case LibFunc_ceil:
|
||||
case LibFunc_ceilf:
|
||||
case LibFunc_ceill:
|
||||
return Intrinsic::ceil;
|
||||
case LibFunc::trunc:
|
||||
case LibFunc::truncf:
|
||||
case LibFunc::truncl:
|
||||
case LibFunc_trunc:
|
||||
case LibFunc_truncf:
|
||||
case LibFunc_truncl:
|
||||
return Intrinsic::trunc;
|
||||
case LibFunc::rint:
|
||||
case LibFunc::rintf:
|
||||
case LibFunc::rintl:
|
||||
case LibFunc_rint:
|
||||
case LibFunc_rintf:
|
||||
case LibFunc_rintl:
|
||||
return Intrinsic::rint;
|
||||
case LibFunc::nearbyint:
|
||||
case LibFunc::nearbyintf:
|
||||
case LibFunc::nearbyintl:
|
||||
case LibFunc_nearbyint:
|
||||
case LibFunc_nearbyintf:
|
||||
case LibFunc_nearbyintl:
|
||||
return Intrinsic::nearbyint;
|
||||
case LibFunc::round:
|
||||
case LibFunc::roundf:
|
||||
case LibFunc::roundl:
|
||||
case LibFunc_round:
|
||||
case LibFunc_roundf:
|
||||
case LibFunc_roundl:
|
||||
return Intrinsic::round;
|
||||
case LibFunc::pow:
|
||||
case LibFunc::powf:
|
||||
case LibFunc::powl:
|
||||
case LibFunc_pow:
|
||||
case LibFunc_powf:
|
||||
case LibFunc_powl:
|
||||
return Intrinsic::pow;
|
||||
case LibFunc::sqrt:
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc::sqrtl:
|
||||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrtl:
|
||||
if (ICS->hasNoNaNs())
|
||||
return Intrinsic::sqrt;
|
||||
return Intrinsic::not_intrinsic;
|
||||
|
@ -1362,7 +1362,7 @@ bool FastISel::selectInstruction(const Instruction *I) {
|
||||
|
||||
if (const auto *Call = dyn_cast<CallInst>(I)) {
|
||||
const Function *F = Call->getCalledFunction();
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
|
||||
// As a special case, don't handle calls to builtin library functions that
|
||||
// may be translated directly to target instructions.
|
||||
|
@ -6329,15 +6329,15 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
|
||||
// Check for well-known libc/libm calls. If the function is internal, it
|
||||
// can't be a library call. Don't do the check if marked as nobuiltin for
|
||||
// some reason.
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() &&
|
||||
LibInfo->getLibFunc(F->getName(), Func) &&
|
||||
LibInfo->hasOptimizedCodeGen(Func)) {
|
||||
switch (Func) {
|
||||
default: break;
|
||||
case LibFunc::copysign:
|
||||
case LibFunc::copysignf:
|
||||
case LibFunc::copysignl:
|
||||
case LibFunc_copysign:
|
||||
case LibFunc_copysignf:
|
||||
case LibFunc_copysignl:
|
||||
if (I.getNumArgOperands() == 2 && // Basic sanity checks.
|
||||
I.getArgOperand(0)->getType()->isFloatingPointTy() &&
|
||||
I.getType() == I.getArgOperand(0)->getType() &&
|
||||
@ -6350,122 +6350,122 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case LibFunc::fabs:
|
||||
case LibFunc::fabsf:
|
||||
case LibFunc::fabsl:
|
||||
case LibFunc_fabs:
|
||||
case LibFunc_fabsf:
|
||||
case LibFunc_fabsl:
|
||||
if (visitUnaryFloatCall(I, ISD::FABS))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::fmin:
|
||||
case LibFunc::fminf:
|
||||
case LibFunc::fminl:
|
||||
case LibFunc_fmin:
|
||||
case LibFunc_fminf:
|
||||
case LibFunc_fminl:
|
||||
if (visitBinaryFloatCall(I, ISD::FMINNUM))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::fmax:
|
||||
case LibFunc::fmaxf:
|
||||
case LibFunc::fmaxl:
|
||||
case LibFunc_fmax:
|
||||
case LibFunc_fmaxf:
|
||||
case LibFunc_fmaxl:
|
||||
if (visitBinaryFloatCall(I, ISD::FMAXNUM))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::sin:
|
||||
case LibFunc::sinf:
|
||||
case LibFunc::sinl:
|
||||
case LibFunc_sin:
|
||||
case LibFunc_sinf:
|
||||
case LibFunc_sinl:
|
||||
if (visitUnaryFloatCall(I, ISD::FSIN))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::cos:
|
||||
case LibFunc::cosf:
|
||||
case LibFunc::cosl:
|
||||
case LibFunc_cos:
|
||||
case LibFunc_cosf:
|
||||
case LibFunc_cosl:
|
||||
if (visitUnaryFloatCall(I, ISD::FCOS))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::sqrt:
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc::sqrtl:
|
||||
case LibFunc::sqrt_finite:
|
||||
case LibFunc::sqrtf_finite:
|
||||
case LibFunc::sqrtl_finite:
|
||||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrtl:
|
||||
case LibFunc_sqrt_finite:
|
||||
case LibFunc_sqrtf_finite:
|
||||
case LibFunc_sqrtl_finite:
|
||||
if (visitUnaryFloatCall(I, ISD::FSQRT))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::floor:
|
||||
case LibFunc::floorf:
|
||||
case LibFunc::floorl:
|
||||
case LibFunc_floor:
|
||||
case LibFunc_floorf:
|
||||
case LibFunc_floorl:
|
||||
if (visitUnaryFloatCall(I, ISD::FFLOOR))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::nearbyint:
|
||||
case LibFunc::nearbyintf:
|
||||
case LibFunc::nearbyintl:
|
||||
case LibFunc_nearbyint:
|
||||
case LibFunc_nearbyintf:
|
||||
case LibFunc_nearbyintl:
|
||||
if (visitUnaryFloatCall(I, ISD::FNEARBYINT))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::ceil:
|
||||
case LibFunc::ceilf:
|
||||
case LibFunc::ceill:
|
||||
case LibFunc_ceil:
|
||||
case LibFunc_ceilf:
|
||||
case LibFunc_ceill:
|
||||
if (visitUnaryFloatCall(I, ISD::FCEIL))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::rint:
|
||||
case LibFunc::rintf:
|
||||
case LibFunc::rintl:
|
||||
case LibFunc_rint:
|
||||
case LibFunc_rintf:
|
||||
case LibFunc_rintl:
|
||||
if (visitUnaryFloatCall(I, ISD::FRINT))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::round:
|
||||
case LibFunc::roundf:
|
||||
case LibFunc::roundl:
|
||||
case LibFunc_round:
|
||||
case LibFunc_roundf:
|
||||
case LibFunc_roundl:
|
||||
if (visitUnaryFloatCall(I, ISD::FROUND))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::trunc:
|
||||
case LibFunc::truncf:
|
||||
case LibFunc::truncl:
|
||||
case LibFunc_trunc:
|
||||
case LibFunc_truncf:
|
||||
case LibFunc_truncl:
|
||||
if (visitUnaryFloatCall(I, ISD::FTRUNC))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::log2:
|
||||
case LibFunc::log2f:
|
||||
case LibFunc::log2l:
|
||||
case LibFunc_log2:
|
||||
case LibFunc_log2f:
|
||||
case LibFunc_log2l:
|
||||
if (visitUnaryFloatCall(I, ISD::FLOG2))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::exp2:
|
||||
case LibFunc::exp2f:
|
||||
case LibFunc::exp2l:
|
||||
case LibFunc_exp2:
|
||||
case LibFunc_exp2f:
|
||||
case LibFunc_exp2l:
|
||||
if (visitUnaryFloatCall(I, ISD::FEXP2))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::memcmp:
|
||||
case LibFunc_memcmp:
|
||||
if (visitMemCmpCall(I))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::mempcpy:
|
||||
case LibFunc_mempcpy:
|
||||
if (visitMemPCpyCall(I))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::memchr:
|
||||
case LibFunc_memchr:
|
||||
if (visitMemChrCall(I))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::strcpy:
|
||||
case LibFunc_strcpy:
|
||||
if (visitStrCpyCall(I, false))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::stpcpy:
|
||||
case LibFunc_stpcpy:
|
||||
if (visitStrCpyCall(I, true))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::strcmp:
|
||||
case LibFunc_strcmp:
|
||||
if (visitStrCmpCall(I))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::strlen:
|
||||
case LibFunc_strlen:
|
||||
if (visitStrLenCall(I))
|
||||
return;
|
||||
break;
|
||||
case LibFunc::strnlen:
|
||||
case LibFunc_strnlen:
|
||||
if (visitStrNLenCall(I))
|
||||
return;
|
||||
break;
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
// target.
|
||||
for (unsigned I = 0, E = static_cast<unsigned>(LibFunc::NumLibFuncs);
|
||||
I != E; ++I) {
|
||||
LibFunc::Func F = static_cast<LibFunc::Func>(I);
|
||||
LibFunc F = static_cast<LibFunc>(I);
|
||||
if (TLI.has(F))
|
||||
Libcalls.insert(TLI.getName(F));
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) {
|
||||
// (i.e. soft float or atomics). If adapting for targets that do,
|
||||
// additional care is required here.
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!F->hasLocalLinkage() && F->hasName() && LibInfo &&
|
||||
LibInfo->getLibFunc(F->getName(), Func) &&
|
||||
LibInfo->hasOptimizedCodeGen(Func)) {
|
||||
@ -329,50 +329,50 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) {
|
||||
|
||||
switch (Func) {
|
||||
default: return true;
|
||||
case LibFunc::copysign:
|
||||
case LibFunc::copysignf:
|
||||
case LibFunc_copysign:
|
||||
case LibFunc_copysignf:
|
||||
continue; // ISD::FCOPYSIGN is never a library call.
|
||||
case LibFunc::copysignl:
|
||||
case LibFunc_copysignl:
|
||||
return true;
|
||||
case LibFunc::fabs:
|
||||
case LibFunc::fabsf:
|
||||
case LibFunc::fabsl:
|
||||
case LibFunc_fabs:
|
||||
case LibFunc_fabsf:
|
||||
case LibFunc_fabsl:
|
||||
continue; // ISD::FABS is never a library call.
|
||||
case LibFunc::sqrt:
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc::sqrtl:
|
||||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrtl:
|
||||
Opcode = ISD::FSQRT; break;
|
||||
case LibFunc::floor:
|
||||
case LibFunc::floorf:
|
||||
case LibFunc::floorl:
|
||||
case LibFunc_floor:
|
||||
case LibFunc_floorf:
|
||||
case LibFunc_floorl:
|
||||
Opcode = ISD::FFLOOR; break;
|
||||
case LibFunc::nearbyint:
|
||||
case LibFunc::nearbyintf:
|
||||
case LibFunc::nearbyintl:
|
||||
case LibFunc_nearbyint:
|
||||
case LibFunc_nearbyintf:
|
||||
case LibFunc_nearbyintl:
|
||||
Opcode = ISD::FNEARBYINT; break;
|
||||
case LibFunc::ceil:
|
||||
case LibFunc::ceilf:
|
||||
case LibFunc::ceill:
|
||||
case LibFunc_ceil:
|
||||
case LibFunc_ceilf:
|
||||
case LibFunc_ceill:
|
||||
Opcode = ISD::FCEIL; break;
|
||||
case LibFunc::rint:
|
||||
case LibFunc::rintf:
|
||||
case LibFunc::rintl:
|
||||
case LibFunc_rint:
|
||||
case LibFunc_rintf:
|
||||
case LibFunc_rintl:
|
||||
Opcode = ISD::FRINT; break;
|
||||
case LibFunc::round:
|
||||
case LibFunc::roundf:
|
||||
case LibFunc::roundl:
|
||||
case LibFunc_round:
|
||||
case LibFunc_roundf:
|
||||
case LibFunc_roundl:
|
||||
Opcode = ISD::FROUND; break;
|
||||
case LibFunc::trunc:
|
||||
case LibFunc::truncf:
|
||||
case LibFunc::truncl:
|
||||
case LibFunc_trunc:
|
||||
case LibFunc_truncf:
|
||||
case LibFunc_truncl:
|
||||
Opcode = ISD::FTRUNC; break;
|
||||
case LibFunc::fmin:
|
||||
case LibFunc::fminf:
|
||||
case LibFunc::fminl:
|
||||
case LibFunc_fmin:
|
||||
case LibFunc_fminf:
|
||||
case LibFunc_fminl:
|
||||
Opcode = ISD::FMINNUM; break;
|
||||
case LibFunc::fmax:
|
||||
case LibFunc::fmaxf:
|
||||
case LibFunc::fmaxl:
|
||||
case LibFunc_fmax:
|
||||
case LibFunc_fmaxf:
|
||||
case LibFunc_fmaxl:
|
||||
Opcode = ISD::FMAXNUM; break;
|
||||
}
|
||||
}
|
||||
|
@ -2387,7 +2387,7 @@ OptimizeGlobalAliases(Module &M,
|
||||
}
|
||||
|
||||
static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) {
|
||||
LibFunc::Func F = LibFunc::cxa_atexit;
|
||||
LibFunc F = LibFunc_cxa_atexit;
|
||||
if (!TLI->has(F))
|
||||
return nullptr;
|
||||
|
||||
@ -2396,7 +2396,7 @@ static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) {
|
||||
return nullptr;
|
||||
|
||||
// Make sure that the function has the correct prototype.
|
||||
if (!TLI->getLibFunc(*Fn, F) || F != LibFunc::cxa_atexit)
|
||||
if (!TLI->getLibFunc(*Fn, F) || F != LibFunc_cxa_atexit)
|
||||
return nullptr;
|
||||
|
||||
return Fn;
|
||||
|
@ -135,13 +135,13 @@ static bool hasMemoryWrite(Instruction *I, const TargetLibraryInfo &TLI) {
|
||||
if (auto CS = CallSite(I)) {
|
||||
if (Function *F = CS.getCalledFunction()) {
|
||||
StringRef FnName = F->getName();
|
||||
if (TLI.has(LibFunc::strcpy) && FnName == TLI.getName(LibFunc::strcpy))
|
||||
if (TLI.has(LibFunc_strcpy) && FnName == TLI.getName(LibFunc_strcpy))
|
||||
return true;
|
||||
if (TLI.has(LibFunc::strncpy) && FnName == TLI.getName(LibFunc::strncpy))
|
||||
if (TLI.has(LibFunc_strncpy) && FnName == TLI.getName(LibFunc_strncpy))
|
||||
return true;
|
||||
if (TLI.has(LibFunc::strcat) && FnName == TLI.getName(LibFunc::strcat))
|
||||
if (TLI.has(LibFunc_strcat) && FnName == TLI.getName(LibFunc_strcat))
|
||||
return true;
|
||||
if (TLI.has(LibFunc::strncat) && FnName == TLI.getName(LibFunc::strncat))
|
||||
if (TLI.has(LibFunc_strncat) && FnName == TLI.getName(LibFunc_strncat))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -236,9 +236,9 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) {
|
||||
ApplyCodeSizeHeuristics =
|
||||
L->getHeader()->getParent()->optForSize() && UseLIRCodeSizeHeurs;
|
||||
|
||||
HasMemset = TLI->has(LibFunc::memset);
|
||||
HasMemsetPattern = TLI->has(LibFunc::memset_pattern16);
|
||||
HasMemcpy = TLI->has(LibFunc::memcpy);
|
||||
HasMemset = TLI->has(LibFunc_memset);
|
||||
HasMemsetPattern = TLI->has(LibFunc_memset_pattern16);
|
||||
HasMemcpy = TLI->has(LibFunc_memcpy);
|
||||
|
||||
if (HasMemset || HasMemsetPattern || HasMemcpy)
|
||||
if (SE->hasLoopInvariantBackedgeTakenCount(L))
|
||||
|
@ -1274,7 +1274,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M) {
|
||||
bool MemCpyOptPass::processMemMove(MemMoveInst *M) {
|
||||
AliasAnalysis &AA = LookupAliasAnalysis();
|
||||
|
||||
if (!TLI->has(LibFunc::memmove))
|
||||
if (!TLI->has(LibFunc_memmove))
|
||||
return false;
|
||||
|
||||
// See if the pointers alias.
|
||||
@ -1449,7 +1449,7 @@ bool MemCpyOptPass::runImpl(
|
||||
// If we don't have at least memset and memcpy, there is little point of doing
|
||||
// anything here. These are required by a freestanding implementation, so if
|
||||
// even they are disabled, there is no point in trying hard.
|
||||
if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy))
|
||||
if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy))
|
||||
return false;
|
||||
|
||||
while (true) {
|
||||
|
@ -98,14 +98,14 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
|
||||
|
||||
// Skip if function either has local linkage or is not a known library
|
||||
// function.
|
||||
LibFunc::Func LibFunc;
|
||||
LibFunc LF;
|
||||
if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() ||
|
||||
!TLI->getLibFunc(CalledFunc->getName(), LibFunc))
|
||||
!TLI->getLibFunc(CalledFunc->getName(), LF))
|
||||
continue;
|
||||
|
||||
switch (LibFunc) {
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc::sqrt:
|
||||
switch (LF) {
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrt:
|
||||
if (TTI->haveFastSqrt(Call->getType()) &&
|
||||
optimizeSQRT(Call, CalledFunc, *CurrBB, BB))
|
||||
break;
|
||||
|
@ -107,255 +107,255 @@ static bool setNonNull(Function &F, unsigned n) {
|
||||
}
|
||||
|
||||
bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
||||
LibFunc::Func TheLibFunc;
|
||||
LibFunc TheLibFunc;
|
||||
if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc)))
|
||||
return false;
|
||||
|
||||
bool Changed = false;
|
||||
switch (TheLibFunc) {
|
||||
case LibFunc::strlen:
|
||||
case LibFunc_strlen:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::strchr:
|
||||
case LibFunc::strrchr:
|
||||
case LibFunc_strchr:
|
||||
case LibFunc_strrchr:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
case LibFunc::strtol:
|
||||
case LibFunc::strtod:
|
||||
case LibFunc::strtof:
|
||||
case LibFunc::strtoul:
|
||||
case LibFunc::strtoll:
|
||||
case LibFunc::strtold:
|
||||
case LibFunc::strtoull:
|
||||
case LibFunc_strtol:
|
||||
case LibFunc_strtod:
|
||||
case LibFunc_strtof:
|
||||
case LibFunc_strtoul:
|
||||
case LibFunc_strtoll:
|
||||
case LibFunc_strtold:
|
||||
case LibFunc_strtoull:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::strcpy:
|
||||
case LibFunc::stpcpy:
|
||||
case LibFunc::strcat:
|
||||
case LibFunc::strncat:
|
||||
case LibFunc::strncpy:
|
||||
case LibFunc::stpncpy:
|
||||
case LibFunc_strcpy:
|
||||
case LibFunc_stpcpy:
|
||||
case LibFunc_strcat:
|
||||
case LibFunc_strncat:
|
||||
case LibFunc_strncpy:
|
||||
case LibFunc_stpncpy:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::strxfrm:
|
||||
case LibFunc_strxfrm:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::strcmp: // 0,1
|
||||
case LibFunc::strspn: // 0,1
|
||||
case LibFunc::strncmp: // 0,1
|
||||
case LibFunc::strcspn: // 0,1
|
||||
case LibFunc::strcoll: // 0,1
|
||||
case LibFunc::strcasecmp: // 0,1
|
||||
case LibFunc::strncasecmp: //
|
||||
case LibFunc_strcmp: // 0,1
|
||||
case LibFunc_strspn: // 0,1
|
||||
case LibFunc_strncmp: // 0,1
|
||||
case LibFunc_strcspn: // 0,1
|
||||
case LibFunc_strcoll: // 0,1
|
||||
case LibFunc_strcasecmp: // 0,1
|
||||
case LibFunc_strncasecmp: //
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::strstr:
|
||||
case LibFunc::strpbrk:
|
||||
case LibFunc_strstr:
|
||||
case LibFunc_strpbrk:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::strtok:
|
||||
case LibFunc::strtok_r:
|
||||
case LibFunc_strtok:
|
||||
case LibFunc_strtok_r:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::scanf:
|
||||
case LibFunc_scanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::setbuf:
|
||||
case LibFunc::setvbuf:
|
||||
case LibFunc_setbuf:
|
||||
case LibFunc_setvbuf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::strdup:
|
||||
case LibFunc::strndup:
|
||||
case LibFunc_strdup:
|
||||
case LibFunc_strndup:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::stat:
|
||||
case LibFunc::statvfs:
|
||||
case LibFunc_stat:
|
||||
case LibFunc_statvfs:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::sscanf:
|
||||
case LibFunc_sscanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::sprintf:
|
||||
case LibFunc_sprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::snprintf:
|
||||
case LibFunc_snprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 3);
|
||||
Changed |= setOnlyReadsMemory(F, 3);
|
||||
return Changed;
|
||||
case LibFunc::setitimer:
|
||||
case LibFunc_setitimer:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setDoesNotCapture(F, 3);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::system:
|
||||
case LibFunc_system:
|
||||
// May throw; "system" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::malloc:
|
||||
case LibFunc_malloc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::memcmp:
|
||||
case LibFunc_memcmp:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::memchr:
|
||||
case LibFunc::memrchr:
|
||||
case LibFunc_memchr:
|
||||
case LibFunc_memrchr:
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
case LibFunc::modf:
|
||||
case LibFunc::modff:
|
||||
case LibFunc::modfl:
|
||||
case LibFunc_modf:
|
||||
case LibFunc_modff:
|
||||
case LibFunc_modfl:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::memcpy:
|
||||
case LibFunc::mempcpy:
|
||||
case LibFunc::memccpy:
|
||||
case LibFunc::memmove:
|
||||
case LibFunc_memcpy:
|
||||
case LibFunc_mempcpy:
|
||||
case LibFunc_memccpy:
|
||||
case LibFunc_memmove:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::memcpy_chk:
|
||||
case LibFunc_memcpy_chk:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
case LibFunc::memalign:
|
||||
case LibFunc_memalign:
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::mkdir:
|
||||
case LibFunc_mkdir:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::mktime:
|
||||
case LibFunc_mktime:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::realloc:
|
||||
case LibFunc_realloc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::read:
|
||||
case LibFunc_read:
|
||||
// May throw; "read" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::rewind:
|
||||
case LibFunc_rewind:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::rmdir:
|
||||
case LibFunc::remove:
|
||||
case LibFunc::realpath:
|
||||
case LibFunc_rmdir:
|
||||
case LibFunc_remove:
|
||||
case LibFunc_realpath:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::rename:
|
||||
case LibFunc_rename:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::readlink:
|
||||
case LibFunc_readlink:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::write:
|
||||
case LibFunc_write:
|
||||
// May throw; "write" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::bcopy:
|
||||
case LibFunc_bcopy:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::bcmp:
|
||||
case LibFunc_bcmp:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::bzero:
|
||||
case LibFunc_bzero:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::calloc:
|
||||
case LibFunc_calloc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::chmod:
|
||||
case LibFunc::chown:
|
||||
case LibFunc_chmod:
|
||||
case LibFunc_chown:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::ctermid:
|
||||
case LibFunc::clearerr:
|
||||
case LibFunc::closedir:
|
||||
case LibFunc_ctermid:
|
||||
case LibFunc_clearerr:
|
||||
case LibFunc_closedir:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::atoi:
|
||||
case LibFunc::atol:
|
||||
case LibFunc::atof:
|
||||
case LibFunc::atoll:
|
||||
case LibFunc_atoi:
|
||||
case LibFunc_atol:
|
||||
case LibFunc_atof:
|
||||
case LibFunc_atoll:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::access:
|
||||
case LibFunc_access:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::fopen:
|
||||
case LibFunc_fopen:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
@ -363,150 +363,150 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::fdopen:
|
||||
case LibFunc_fdopen:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::feof:
|
||||
case LibFunc::free:
|
||||
case LibFunc::fseek:
|
||||
case LibFunc::ftell:
|
||||
case LibFunc::fgetc:
|
||||
case LibFunc::fseeko:
|
||||
case LibFunc::ftello:
|
||||
case LibFunc::fileno:
|
||||
case LibFunc::fflush:
|
||||
case LibFunc::fclose:
|
||||
case LibFunc::fsetpos:
|
||||
case LibFunc::flockfile:
|
||||
case LibFunc::funlockfile:
|
||||
case LibFunc::ftrylockfile:
|
||||
case LibFunc_feof:
|
||||
case LibFunc_free:
|
||||
case LibFunc_fseek:
|
||||
case LibFunc_ftell:
|
||||
case LibFunc_fgetc:
|
||||
case LibFunc_fseeko:
|
||||
case LibFunc_ftello:
|
||||
case LibFunc_fileno:
|
||||
case LibFunc_fflush:
|
||||
case LibFunc_fclose:
|
||||
case LibFunc_fsetpos:
|
||||
case LibFunc_flockfile:
|
||||
case LibFunc_funlockfile:
|
||||
case LibFunc_ftrylockfile:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::ferror:
|
||||
case LibFunc_ferror:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
return Changed;
|
||||
case LibFunc::fputc:
|
||||
case LibFunc::fstat:
|
||||
case LibFunc::frexp:
|
||||
case LibFunc::frexpf:
|
||||
case LibFunc::frexpl:
|
||||
case LibFunc::fstatvfs:
|
||||
case LibFunc_fputc:
|
||||
case LibFunc_fstat:
|
||||
case LibFunc_frexp:
|
||||
case LibFunc_frexpf:
|
||||
case LibFunc_frexpl:
|
||||
case LibFunc_fstatvfs:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::fgets:
|
||||
case LibFunc_fgets:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 3);
|
||||
return Changed;
|
||||
case LibFunc::fread:
|
||||
case LibFunc_fread:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 4);
|
||||
return Changed;
|
||||
case LibFunc::fwrite:
|
||||
case LibFunc_fwrite:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 4);
|
||||
// FIXME: readonly #1?
|
||||
return Changed;
|
||||
case LibFunc::fputs:
|
||||
case LibFunc_fputs:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::fscanf:
|
||||
case LibFunc::fprintf:
|
||||
case LibFunc_fscanf:
|
||||
case LibFunc_fprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::fgetpos:
|
||||
case LibFunc_fgetpos:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::getc:
|
||||
case LibFunc::getlogin_r:
|
||||
case LibFunc::getc_unlocked:
|
||||
case LibFunc_getc:
|
||||
case LibFunc_getlogin_r:
|
||||
case LibFunc_getc_unlocked:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::getenv:
|
||||
case LibFunc_getenv:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setOnlyReadsMemory(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::gets:
|
||||
case LibFunc::getchar:
|
||||
case LibFunc_gets:
|
||||
case LibFunc_getchar:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
case LibFunc::getitimer:
|
||||
case LibFunc_getitimer:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::getpwnam:
|
||||
case LibFunc_getpwnam:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::ungetc:
|
||||
case LibFunc_ungetc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::uname:
|
||||
case LibFunc_uname:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::unlink:
|
||||
case LibFunc_unlink:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::unsetenv:
|
||||
case LibFunc_unsetenv:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::utime:
|
||||
case LibFunc::utimes:
|
||||
case LibFunc_utime:
|
||||
case LibFunc_utimes:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::putc:
|
||||
case LibFunc_putc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::puts:
|
||||
case LibFunc::printf:
|
||||
case LibFunc::perror:
|
||||
case LibFunc_puts:
|
||||
case LibFunc_printf:
|
||||
case LibFunc_perror:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::pread:
|
||||
case LibFunc_pread:
|
||||
// May throw; "pread" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::pwrite:
|
||||
case LibFunc_pwrite:
|
||||
// May throw; "pwrite" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::putchar:
|
||||
case LibFunc_putchar:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
case LibFunc::popen:
|
||||
case LibFunc_popen:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
@ -514,132 +514,132 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::pclose:
|
||||
case LibFunc_pclose:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::vscanf:
|
||||
case LibFunc_vscanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::vsscanf:
|
||||
case LibFunc_vsscanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::vfscanf:
|
||||
case LibFunc_vfscanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::valloc:
|
||||
case LibFunc_valloc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::vprintf:
|
||||
case LibFunc_vprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::vfprintf:
|
||||
case LibFunc::vsprintf:
|
||||
case LibFunc_vfprintf:
|
||||
case LibFunc_vsprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::vsnprintf:
|
||||
case LibFunc_vsnprintf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 3);
|
||||
Changed |= setOnlyReadsMemory(F, 3);
|
||||
return Changed;
|
||||
case LibFunc::open:
|
||||
case LibFunc_open:
|
||||
// May throw; "open" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::opendir:
|
||||
case LibFunc_opendir:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::tmpfile:
|
||||
case LibFunc_tmpfile:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::times:
|
||||
case LibFunc_times:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::htonl:
|
||||
case LibFunc::htons:
|
||||
case LibFunc::ntohl:
|
||||
case LibFunc::ntohs:
|
||||
case LibFunc_htonl:
|
||||
case LibFunc_htons:
|
||||
case LibFunc_ntohl:
|
||||
case LibFunc_ntohs:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAccessMemory(F);
|
||||
return Changed;
|
||||
case LibFunc::lstat:
|
||||
case LibFunc_lstat:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::lchown:
|
||||
case LibFunc_lchown:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::qsort:
|
||||
case LibFunc_qsort:
|
||||
// May throw; places call through function pointer.
|
||||
Changed |= setDoesNotCapture(F, 4);
|
||||
return Changed;
|
||||
case LibFunc::dunder_strdup:
|
||||
case LibFunc::dunder_strndup:
|
||||
case LibFunc_dunder_strdup:
|
||||
case LibFunc_dunder_strndup:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::dunder_strtok_r:
|
||||
case LibFunc_dunder_strtok_r:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::under_IO_getc:
|
||||
case LibFunc_under_IO_getc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::under_IO_putc:
|
||||
case LibFunc_under_IO_putc:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::dunder_isoc99_scanf:
|
||||
case LibFunc_dunder_isoc99_scanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::stat64:
|
||||
case LibFunc::lstat64:
|
||||
case LibFunc::statvfs64:
|
||||
case LibFunc_stat64:
|
||||
case LibFunc_lstat64:
|
||||
case LibFunc_statvfs64:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::dunder_isoc99_sscanf:
|
||||
case LibFunc_dunder_isoc99_sscanf:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::fopen64:
|
||||
case LibFunc_fopen64:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
@ -647,26 +647,26 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::fseeko64:
|
||||
case LibFunc::ftello64:
|
||||
case LibFunc_fseeko64:
|
||||
case LibFunc_ftello64:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::tmpfile64:
|
||||
case LibFunc_tmpfile64:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotAlias(F, 0);
|
||||
return Changed;
|
||||
case LibFunc::fstat64:
|
||||
case LibFunc::fstatvfs64:
|
||||
case LibFunc_fstat64:
|
||||
case LibFunc_fstatvfs64:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::open64:
|
||||
case LibFunc_open64:
|
||||
// May throw; "open" is a valid pthread cancellation point.
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setOnlyReadsMemory(F, 1);
|
||||
return Changed;
|
||||
case LibFunc::gettimeofday:
|
||||
case LibFunc_gettimeofday:
|
||||
// Currently some platforms have the restrict keyword on the arguments to
|
||||
// gettimeofday. To be conservative, do not add noalias to gettimeofday's
|
||||
// arguments.
|
||||
@ -674,29 +674,29 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
return Changed;
|
||||
case LibFunc::Znwj: // new(unsigned int)
|
||||
case LibFunc::Znwm: // new(unsigned long)
|
||||
case LibFunc::Znaj: // new[](unsigned int)
|
||||
case LibFunc::Znam: // new[](unsigned long)
|
||||
case LibFunc::msvc_new_int: // new(unsigned int)
|
||||
case LibFunc::msvc_new_longlong: // new(unsigned long long)
|
||||
case LibFunc::msvc_new_array_int: // new[](unsigned int)
|
||||
case LibFunc::msvc_new_array_longlong: // new[](unsigned long long)
|
||||
case LibFunc_Znwj: // new(unsigned int)
|
||||
case LibFunc_Znwm: // new(unsigned long)
|
||||
case LibFunc_Znaj: // new[](unsigned int)
|
||||
case LibFunc_Znam: // new[](unsigned long)
|
||||
case LibFunc_msvc_new_int: // new(unsigned int)
|
||||
case LibFunc_msvc_new_longlong: // new(unsigned long long)
|
||||
case LibFunc_msvc_new_array_int: // new[](unsigned int)
|
||||
case LibFunc_msvc_new_array_longlong: // new[](unsigned long long)
|
||||
// Operator new always returns a nonnull noalias pointer
|
||||
Changed |= setNonNull(F, AttributeSet::ReturnIndex);
|
||||
Changed |= setDoesNotAlias(F, AttributeSet::ReturnIndex);
|
||||
return Changed;
|
||||
//TODO: add LibFunc entries for:
|
||||
//case LibFunc::memset_pattern4:
|
||||
//case LibFunc::memset_pattern8:
|
||||
case LibFunc::memset_pattern16:
|
||||
//case LibFunc_memset_pattern4:
|
||||
//case LibFunc_memset_pattern8:
|
||||
case LibFunc_memset_pattern16:
|
||||
Changed |= setOnlyAccessesArgMemory(F);
|
||||
Changed |= setDoesNotCapture(F, 1);
|
||||
Changed |= setDoesNotCapture(F, 2);
|
||||
Changed |= setOnlyReadsMemory(F, 2);
|
||||
return Changed;
|
||||
// int __nvvm_reflect(const char *)
|
||||
case LibFunc::nvvm_reflect:
|
||||
case LibFunc_nvvm_reflect:
|
||||
Changed |= setDoesNotAccessMemory(F);
|
||||
Changed |= setDoesNotThrow(F);
|
||||
return Changed;
|
||||
@ -717,7 +717,7 @@ Value *llvm::castToCStr(Value *V, IRBuilder<> &B) {
|
||||
|
||||
Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::strlen))
|
||||
if (!TLI->has(LibFunc_strlen))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -734,7 +734,7 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL,
|
||||
|
||||
Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::strchr))
|
||||
if (!TLI->has(LibFunc_strchr))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -752,7 +752,7 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
|
||||
const DataLayout &DL, const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::strncmp))
|
||||
if (!TLI->has(LibFunc_strncmp))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -772,7 +772,7 @@ Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI, StringRef Name) {
|
||||
if (!TLI->has(LibFunc::strcpy))
|
||||
if (!TLI->has(LibFunc_strcpy))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -788,7 +788,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI, StringRef Name) {
|
||||
if (!TLI->has(LibFunc::strncpy))
|
||||
if (!TLI->has(LibFunc_strncpy))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -806,7 +806,7 @@ Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B,
|
||||
Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
||||
IRBuilder<> &B, const DataLayout &DL,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::memcpy_chk))
|
||||
if (!TLI->has(LibFunc_memcpy_chk))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -828,7 +828,7 @@ Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
||||
|
||||
Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B,
|
||||
const DataLayout &DL, const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::memchr))
|
||||
if (!TLI->has(LibFunc_memchr))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -847,7 +847,7 @@ Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
|
||||
const DataLayout &DL, const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::memcmp))
|
||||
if (!TLI->has(LibFunc_memcmp))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -914,7 +914,7 @@ Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name,
|
||||
|
||||
Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::putchar))
|
||||
if (!TLI->has(LibFunc_putchar))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -934,7 +934,7 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitPutS(Value *Str, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::puts))
|
||||
if (!TLI->has(LibFunc_puts))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -949,7 +949,7 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::fputc))
|
||||
if (!TLI->has(LibFunc_fputc))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
@ -968,11 +968,11 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||
const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::fputs))
|
||||
if (!TLI->has(LibFunc_fputs))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
StringRef FPutsName = TLI->getName(LibFunc::fputs);
|
||||
StringRef FPutsName = TLI->getName(LibFunc_fputs);
|
||||
Constant *F = M->getOrInsertFunction(
|
||||
FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType(), nullptr);
|
||||
if (File->getType()->isPointerTy())
|
||||
@ -986,12 +986,12 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||
|
||||
Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B,
|
||||
const DataLayout &DL, const TargetLibraryInfo *TLI) {
|
||||
if (!TLI->has(LibFunc::fwrite))
|
||||
if (!TLI->has(LibFunc_fwrite))
|
||||
return nullptr;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
|
||||
StringRef FWriteName = TLI->getName(LibFunc_fwrite);
|
||||
Constant *F = M->getOrInsertFunction(
|
||||
FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(),
|
||||
DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType(),
|
||||
|
@ -100,12 +100,12 @@ private:
|
||||
bool perform(CallInst *CI);
|
||||
void checkCandidate(CallInst &CI);
|
||||
void shrinkWrapCI(CallInst *CI, Value *Cond);
|
||||
bool performCallDomainErrorOnly(CallInst *CI, const LibFunc::Func &Func);
|
||||
bool performCallErrors(CallInst *CI, const LibFunc::Func &Func);
|
||||
bool performCallRangeErrorOnly(CallInst *CI, const LibFunc::Func &Func);
|
||||
Value *generateOneRangeCond(CallInst *CI, const LibFunc::Func &Func);
|
||||
Value *generateTwoRangeCond(CallInst *CI, const LibFunc::Func &Func);
|
||||
Value *generateCondForPow(CallInst *CI, const LibFunc::Func &Func);
|
||||
bool performCallDomainErrorOnly(CallInst *CI, const LibFunc &Func);
|
||||
bool performCallErrors(CallInst *CI, const LibFunc &Func);
|
||||
bool performCallRangeErrorOnly(CallInst *CI, const LibFunc &Func);
|
||||
Value *generateOneRangeCond(CallInst *CI, const LibFunc &Func);
|
||||
Value *generateTwoRangeCond(CallInst *CI, const LibFunc &Func);
|
||||
Value *generateCondForPow(CallInst *CI, const LibFunc &Func);
|
||||
|
||||
// Create an OR of two conditions.
|
||||
Value *createOrCond(CallInst *CI, CmpInst::Predicate Cmp, float Val,
|
||||
@ -141,44 +141,44 @@ private:
|
||||
|
||||
// Perform the transformation to calls with errno set by domain error.
|
||||
bool LibCallsShrinkWrap::performCallDomainErrorOnly(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
const LibFunc &Func) {
|
||||
Value *Cond = nullptr;
|
||||
|
||||
switch (Func) {
|
||||
case LibFunc::acos: // DomainError: (x < -1 || x > 1)
|
||||
case LibFunc::acosf: // Same as acos
|
||||
case LibFunc::acosl: // Same as acos
|
||||
case LibFunc::asin: // DomainError: (x < -1 || x > 1)
|
||||
case LibFunc::asinf: // Same as asin
|
||||
case LibFunc::asinl: // Same as asin
|
||||
case LibFunc_acos: // DomainError: (x < -1 || x > 1)
|
||||
case LibFunc_acosf: // Same as acos
|
||||
case LibFunc_acosl: // Same as acos
|
||||
case LibFunc_asin: // DomainError: (x < -1 || x > 1)
|
||||
case LibFunc_asinf: // Same as asin
|
||||
case LibFunc_asinl: // Same as asin
|
||||
{
|
||||
++NumWrappedTwoCond;
|
||||
Cond = createOrCond(CI, CmpInst::FCMP_OLT, -1.0f, CmpInst::FCMP_OGT, 1.0f);
|
||||
break;
|
||||
}
|
||||
case LibFunc::cos: // DomainError: (x == +inf || x == -inf)
|
||||
case LibFunc::cosf: // Same as cos
|
||||
case LibFunc::cosl: // Same as cos
|
||||
case LibFunc::sin: // DomainError: (x == +inf || x == -inf)
|
||||
case LibFunc::sinf: // Same as sin
|
||||
case LibFunc::sinl: // Same as sin
|
||||
case LibFunc_cos: // DomainError: (x == +inf || x == -inf)
|
||||
case LibFunc_cosf: // Same as cos
|
||||
case LibFunc_cosl: // Same as cos
|
||||
case LibFunc_sin: // DomainError: (x == +inf || x == -inf)
|
||||
case LibFunc_sinf: // Same as sin
|
||||
case LibFunc_sinl: // Same as sin
|
||||
{
|
||||
++NumWrappedTwoCond;
|
||||
Cond = createOrCond(CI, CmpInst::FCMP_OEQ, INFINITY, CmpInst::FCMP_OEQ,
|
||||
-INFINITY);
|
||||
break;
|
||||
}
|
||||
case LibFunc::acosh: // DomainError: (x < 1)
|
||||
case LibFunc::acoshf: // Same as acosh
|
||||
case LibFunc::acoshl: // Same as acosh
|
||||
case LibFunc_acosh: // DomainError: (x < 1)
|
||||
case LibFunc_acoshf: // Same as acosh
|
||||
case LibFunc_acoshl: // Same as acosh
|
||||
{
|
||||
++NumWrappedOneCond;
|
||||
Cond = createCond(CI, CmpInst::FCMP_OLT, 1.0f);
|
||||
break;
|
||||
}
|
||||
case LibFunc::sqrt: // DomainError: (x < 0)
|
||||
case LibFunc::sqrtf: // Same as sqrt
|
||||
case LibFunc::sqrtl: // Same as sqrt
|
||||
case LibFunc_sqrt: // DomainError: (x < 0)
|
||||
case LibFunc_sqrtf: // Same as sqrt
|
||||
case LibFunc_sqrtl: // Same as sqrt
|
||||
{
|
||||
++NumWrappedOneCond;
|
||||
Cond = createCond(CI, CmpInst::FCMP_OLT, 0.0f);
|
||||
@ -193,31 +193,31 @@ bool LibCallsShrinkWrap::performCallDomainErrorOnly(CallInst *CI,
|
||||
|
||||
// Perform the transformation to calls with errno set by range error.
|
||||
bool LibCallsShrinkWrap::performCallRangeErrorOnly(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
const LibFunc &Func) {
|
||||
Value *Cond = nullptr;
|
||||
|
||||
switch (Func) {
|
||||
case LibFunc::cosh:
|
||||
case LibFunc::coshf:
|
||||
case LibFunc::coshl:
|
||||
case LibFunc::exp:
|
||||
case LibFunc::expf:
|
||||
case LibFunc::expl:
|
||||
case LibFunc::exp10:
|
||||
case LibFunc::exp10f:
|
||||
case LibFunc::exp10l:
|
||||
case LibFunc::exp2:
|
||||
case LibFunc::exp2f:
|
||||
case LibFunc::exp2l:
|
||||
case LibFunc::sinh:
|
||||
case LibFunc::sinhf:
|
||||
case LibFunc::sinhl: {
|
||||
case LibFunc_cosh:
|
||||
case LibFunc_coshf:
|
||||
case LibFunc_coshl:
|
||||
case LibFunc_exp:
|
||||
case LibFunc_expf:
|
||||
case LibFunc_expl:
|
||||
case LibFunc_exp10:
|
||||
case LibFunc_exp10f:
|
||||
case LibFunc_exp10l:
|
||||
case LibFunc_exp2:
|
||||
case LibFunc_exp2f:
|
||||
case LibFunc_exp2l:
|
||||
case LibFunc_sinh:
|
||||
case LibFunc_sinhf:
|
||||
case LibFunc_sinhl: {
|
||||
Cond = generateTwoRangeCond(CI, Func);
|
||||
break;
|
||||
}
|
||||
case LibFunc::expm1: // RangeError: (709, inf)
|
||||
case LibFunc::expm1f: // RangeError: (88, inf)
|
||||
case LibFunc::expm1l: // RangeError: (11356, inf)
|
||||
case LibFunc_expm1: // RangeError: (709, inf)
|
||||
case LibFunc_expm1f: // RangeError: (88, inf)
|
||||
case LibFunc_expm1l: // RangeError: (11356, inf)
|
||||
{
|
||||
Cond = generateOneRangeCond(CI, Func);
|
||||
break;
|
||||
@ -231,15 +231,15 @@ bool LibCallsShrinkWrap::performCallRangeErrorOnly(CallInst *CI,
|
||||
|
||||
// Perform the transformation to calls with errno set by combination of errors.
|
||||
bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
const LibFunc &Func) {
|
||||
Value *Cond = nullptr;
|
||||
|
||||
switch (Func) {
|
||||
case LibFunc::atanh: // DomainError: (x < -1 || x > 1)
|
||||
case LibFunc_atanh: // DomainError: (x < -1 || x > 1)
|
||||
// PoleError: (x == -1 || x == 1)
|
||||
// Overall Cond: (x <= -1 || x >= 1)
|
||||
case LibFunc::atanhf: // Same as atanh
|
||||
case LibFunc::atanhl: // Same as atanh
|
||||
case LibFunc_atanhf: // Same as atanh
|
||||
case LibFunc_atanhl: // Same as atanh
|
||||
{
|
||||
if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError)
|
||||
return false;
|
||||
@ -247,20 +247,20 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
|
||||
Cond = createOrCond(CI, CmpInst::FCMP_OLE, -1.0f, CmpInst::FCMP_OGE, 1.0f);
|
||||
break;
|
||||
}
|
||||
case LibFunc::log: // DomainError: (x < 0)
|
||||
case LibFunc_log: // DomainError: (x < 0)
|
||||
// PoleError: (x == 0)
|
||||
// Overall Cond: (x <= 0)
|
||||
case LibFunc::logf: // Same as log
|
||||
case LibFunc::logl: // Same as log
|
||||
case LibFunc::log10: // Same as log
|
||||
case LibFunc::log10f: // Same as log
|
||||
case LibFunc::log10l: // Same as log
|
||||
case LibFunc::log2: // Same as log
|
||||
case LibFunc::log2f: // Same as log
|
||||
case LibFunc::log2l: // Same as log
|
||||
case LibFunc::logb: // Same as log
|
||||
case LibFunc::logbf: // Same as log
|
||||
case LibFunc::logbl: // Same as log
|
||||
case LibFunc_logf: // Same as log
|
||||
case LibFunc_logl: // Same as log
|
||||
case LibFunc_log10: // Same as log
|
||||
case LibFunc_log10f: // Same as log
|
||||
case LibFunc_log10l: // Same as log
|
||||
case LibFunc_log2: // Same as log
|
||||
case LibFunc_log2f: // Same as log
|
||||
case LibFunc_log2l: // Same as log
|
||||
case LibFunc_logb: // Same as log
|
||||
case LibFunc_logbf: // Same as log
|
||||
case LibFunc_logbl: // Same as log
|
||||
{
|
||||
if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError)
|
||||
return false;
|
||||
@ -268,11 +268,11 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
|
||||
Cond = createCond(CI, CmpInst::FCMP_OLE, 0.0f);
|
||||
break;
|
||||
}
|
||||
case LibFunc::log1p: // DomainError: (x < -1)
|
||||
case LibFunc_log1p: // DomainError: (x < -1)
|
||||
// PoleError: (x == -1)
|
||||
// Overall Cond: (x <= -1)
|
||||
case LibFunc::log1pf: // Same as log1p
|
||||
case LibFunc::log1pl: // Same as log1p
|
||||
case LibFunc_log1pf: // Same as log1p
|
||||
case LibFunc_log1pl: // Same as log1p
|
||||
{
|
||||
if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError)
|
||||
return false;
|
||||
@ -280,11 +280,11 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
|
||||
Cond = createCond(CI, CmpInst::FCMP_OLE, -1.0f);
|
||||
break;
|
||||
}
|
||||
case LibFunc::pow: // DomainError: x < 0 and y is noninteger
|
||||
case LibFunc_pow: // DomainError: x < 0 and y is noninteger
|
||||
// PoleError: x == 0 and y < 0
|
||||
// RangeError: overflow or underflow
|
||||
case LibFunc::powf:
|
||||
case LibFunc::powl: {
|
||||
case LibFunc_powf:
|
||||
case LibFunc_powl: {
|
||||
if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError ||
|
||||
!LibCallsShrinkWrapDoRangeError)
|
||||
return false;
|
||||
@ -313,7 +313,7 @@ void LibCallsShrinkWrap::checkCandidate(CallInst &CI) {
|
||||
if (!CI.use_empty())
|
||||
return;
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *Callee = CI.getCalledFunction();
|
||||
if (!Callee)
|
||||
return;
|
||||
@ -333,16 +333,16 @@ void LibCallsShrinkWrap::checkCandidate(CallInst &CI) {
|
||||
|
||||
// Generate the upper bound condition for RangeError.
|
||||
Value *LibCallsShrinkWrap::generateOneRangeCond(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
const LibFunc &Func) {
|
||||
float UpperBound;
|
||||
switch (Func) {
|
||||
case LibFunc::expm1: // RangeError: (709, inf)
|
||||
case LibFunc_expm1: // RangeError: (709, inf)
|
||||
UpperBound = 709.0f;
|
||||
break;
|
||||
case LibFunc::expm1f: // RangeError: (88, inf)
|
||||
case LibFunc_expm1f: // RangeError: (88, inf)
|
||||
UpperBound = 88.0f;
|
||||
break;
|
||||
case LibFunc::expm1l: // RangeError: (11356, inf)
|
||||
case LibFunc_expm1l: // RangeError: (11356, inf)
|
||||
UpperBound = 11356.0f;
|
||||
break;
|
||||
default:
|
||||
@ -355,57 +355,57 @@ Value *LibCallsShrinkWrap::generateOneRangeCond(CallInst *CI,
|
||||
|
||||
// Generate the lower and upper bound condition for RangeError.
|
||||
Value *LibCallsShrinkWrap::generateTwoRangeCond(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
const LibFunc &Func) {
|
||||
float UpperBound, LowerBound;
|
||||
switch (Func) {
|
||||
case LibFunc::cosh: // RangeError: (x < -710 || x > 710)
|
||||
case LibFunc::sinh: // Same as cosh
|
||||
case LibFunc_cosh: // RangeError: (x < -710 || x > 710)
|
||||
case LibFunc_sinh: // Same as cosh
|
||||
LowerBound = -710.0f;
|
||||
UpperBound = 710.0f;
|
||||
break;
|
||||
case LibFunc::coshf: // RangeError: (x < -89 || x > 89)
|
||||
case LibFunc::sinhf: // Same as coshf
|
||||
case LibFunc_coshf: // RangeError: (x < -89 || x > 89)
|
||||
case LibFunc_sinhf: // Same as coshf
|
||||
LowerBound = -89.0f;
|
||||
UpperBound = 89.0f;
|
||||
break;
|
||||
case LibFunc::coshl: // RangeError: (x < -11357 || x > 11357)
|
||||
case LibFunc::sinhl: // Same as coshl
|
||||
case LibFunc_coshl: // RangeError: (x < -11357 || x > 11357)
|
||||
case LibFunc_sinhl: // Same as coshl
|
||||
LowerBound = -11357.0f;
|
||||
UpperBound = 11357.0f;
|
||||
break;
|
||||
case LibFunc::exp: // RangeError: (x < -745 || x > 709)
|
||||
case LibFunc_exp: // RangeError: (x < -745 || x > 709)
|
||||
LowerBound = -745.0f;
|
||||
UpperBound = 709.0f;
|
||||
break;
|
||||
case LibFunc::expf: // RangeError: (x < -103 || x > 88)
|
||||
case LibFunc_expf: // RangeError: (x < -103 || x > 88)
|
||||
LowerBound = -103.0f;
|
||||
UpperBound = 88.0f;
|
||||
break;
|
||||
case LibFunc::expl: // RangeError: (x < -11399 || x > 11356)
|
||||
case LibFunc_expl: // RangeError: (x < -11399 || x > 11356)
|
||||
LowerBound = -11399.0f;
|
||||
UpperBound = 11356.0f;
|
||||
break;
|
||||
case LibFunc::exp10: // RangeError: (x < -323 || x > 308)
|
||||
case LibFunc_exp10: // RangeError: (x < -323 || x > 308)
|
||||
LowerBound = -323.0f;
|
||||
UpperBound = 308.0f;
|
||||
break;
|
||||
case LibFunc::exp10f: // RangeError: (x < -45 || x > 38)
|
||||
case LibFunc_exp10f: // RangeError: (x < -45 || x > 38)
|
||||
LowerBound = -45.0f;
|
||||
UpperBound = 38.0f;
|
||||
break;
|
||||
case LibFunc::exp10l: // RangeError: (x < -4950 || x > 4932)
|
||||
case LibFunc_exp10l: // RangeError: (x < -4950 || x > 4932)
|
||||
LowerBound = -4950.0f;
|
||||
UpperBound = 4932.0f;
|
||||
break;
|
||||
case LibFunc::exp2: // RangeError: (x < -1074 || x > 1023)
|
||||
case LibFunc_exp2: // RangeError: (x < -1074 || x > 1023)
|
||||
LowerBound = -1074.0f;
|
||||
UpperBound = 1023.0f;
|
||||
break;
|
||||
case LibFunc::exp2f: // RangeError: (x < -149 || x > 127)
|
||||
case LibFunc_exp2f: // RangeError: (x < -149 || x > 127)
|
||||
LowerBound = -149.0f;
|
||||
UpperBound = 127.0f;
|
||||
break;
|
||||
case LibFunc::exp2l: // RangeError: (x < -16445 || x > 11383)
|
||||
case LibFunc_exp2l: // RangeError: (x < -16445 || x > 11383)
|
||||
LowerBound = -16445.0f;
|
||||
UpperBound = 11383.0f;
|
||||
break;
|
||||
@ -434,9 +434,9 @@ Value *LibCallsShrinkWrap::generateTwoRangeCond(CallInst *CI,
|
||||
// (i.e. we might invoke the calls that will not set the errno.).
|
||||
//
|
||||
Value *LibCallsShrinkWrap::generateCondForPow(CallInst *CI,
|
||||
const LibFunc::Func &Func) {
|
||||
// FIXME: LibFunc::powf and powl TBD.
|
||||
if (Func != LibFunc::pow) {
|
||||
const LibFunc &Func) {
|
||||
// FIXME: LibFunc_powf and powl TBD.
|
||||
if (Func != LibFunc_pow) {
|
||||
DEBUG(dbgs() << "Not handled powf() and powl()\n");
|
||||
return nullptr;
|
||||
}
|
||||
@ -516,7 +516,7 @@ void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) {
|
||||
|
||||
// Perform the transformation to a single candidate.
|
||||
bool LibCallsShrinkWrap::perform(CallInst *CI) {
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
assert(Callee && "perform() should apply to a non-empty callee");
|
||||
TLI.getLibFunc(*Callee, Func);
|
||||
|
@ -2068,7 +2068,7 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
|
||||
void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(
|
||||
CallInst *CI, const TargetLibraryInfo *TLI) {
|
||||
Function *F = CI->getCalledFunction();
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (F && !F->hasLocalLinkage() && F->hasName() &&
|
||||
TLI->getLibFunc(F->getName(), Func) && TLI->hasOptimizedCodeGen(Func) &&
|
||||
!F->doesNotAccessMemory())
|
||||
|
@ -51,9 +51,9 @@ static cl::opt<bool>
|
||||
// Helper Functions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static bool ignoreCallingConv(LibFunc::Func Func) {
|
||||
return Func == LibFunc::abs || Func == LibFunc::labs ||
|
||||
Func == LibFunc::llabs || Func == LibFunc::strlen;
|
||||
static bool ignoreCallingConv(LibFunc Func) {
|
||||
return Func == LibFunc_abs || Func == LibFunc_labs ||
|
||||
Func == LibFunc_llabs || Func == LibFunc_strlen;
|
||||
}
|
||||
|
||||
static bool isCallingConvCCompatible(CallInst *CI) {
|
||||
@ -123,8 +123,8 @@ static bool callHasFloatingPointArgument(const CallInst *CI) {
|
||||
/// \brief Check whether the overloaded unary floating point function
|
||||
/// corresponding to \a Ty is available.
|
||||
static bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty,
|
||||
LibFunc::Func DoubleFn, LibFunc::Func FloatFn,
|
||||
LibFunc::Func LongDoubleFn) {
|
||||
LibFunc DoubleFn, LibFunc FloatFn,
|
||||
LibFunc LongDoubleFn) {
|
||||
switch (Ty->getTypeID()) {
|
||||
case Type::FloatTyID:
|
||||
return TLI->has(FloatFn);
|
||||
@ -811,7 +811,7 @@ Value *LibCallSimplifier::optimizeMemMove(CallInst *CI, IRBuilder<> &B) {
|
||||
// functions be moved here?
|
||||
static Value *emitCalloc(Value *Num, Value *Size, const AttributeSet &Attrs,
|
||||
IRBuilder<> &B, const TargetLibraryInfo &TLI) {
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!TLI.getLibFunc("calloc", Func) || !TLI.has(Func))
|
||||
return nullptr;
|
||||
|
||||
@ -846,9 +846,9 @@ static Value *foldMallocMemset(CallInst *Memset, IRBuilder<> &B,
|
||||
|
||||
// Is the inner call really malloc()?
|
||||
Function *InnerCallee = Malloc->getCalledFunction();
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!TLI.getLibFunc(*InnerCallee, Func) || !TLI.has(Func) ||
|
||||
Func != LibFunc::malloc)
|
||||
Func != LibFunc_malloc)
|
||||
return nullptr;
|
||||
|
||||
// The memset must cover the same number of bytes that are malloc'd.
|
||||
@ -1041,9 +1041,9 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
if (ConstantFP *Op1C = dyn_cast<ConstantFP>(Op1)) {
|
||||
// pow(10.0, x) -> exp10(x)
|
||||
if (Op1C->isExactlyValue(10.0) &&
|
||||
hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp10, LibFunc::exp10f,
|
||||
LibFunc::exp10l))
|
||||
return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc::exp10), B,
|
||||
hasUnaryFloatFn(TLI, Op1->getType(), LibFunc_exp10, LibFunc_exp10f,
|
||||
LibFunc_exp10l))
|
||||
return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc_exp10), B,
|
||||
Callee->getAttributes());
|
||||
}
|
||||
|
||||
@ -1055,10 +1055,10 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
// pow(exp(x), y) = pow(inf, 0.001) = inf, whereas exp(x*y) = exp(1).
|
||||
auto *OpC = dyn_cast<CallInst>(Op1);
|
||||
if (OpC && OpC->hasUnsafeAlgebra() && CI->hasUnsafeAlgebra()) {
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *OpCCallee = OpC->getCalledFunction();
|
||||
if (OpCCallee && TLI->getLibFunc(OpCCallee->getName(), Func) &&
|
||||
TLI->has(Func) && (Func == LibFunc::exp || Func == LibFunc::exp2)) {
|
||||
TLI->has(Func) && (Func == LibFunc_exp || Func == LibFunc_exp2)) {
|
||||
IRBuilder<>::FastMathFlagGuard Guard(B);
|
||||
B.setFastMathFlags(CI->getFastMathFlags());
|
||||
Value *FMul = B.CreateFMul(OpC->getArgOperand(0), Op2, "mul");
|
||||
@ -1075,8 +1075,8 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
return ConstantFP::get(CI->getType(), 1.0);
|
||||
|
||||
if (Op2C->isExactlyValue(-0.5) &&
|
||||
hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf,
|
||||
LibFunc::sqrtl)) {
|
||||
hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_sqrt, LibFunc_sqrtf,
|
||||
LibFunc_sqrtl)) {
|
||||
// If -ffast-math:
|
||||
// pow(x, -0.5) -> 1.0 / sqrt(x)
|
||||
if (CI->hasUnsafeAlgebra()) {
|
||||
@ -1085,7 +1085,7 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
// Here we cannot lower to an intrinsic because C99 sqrt() and llvm.sqrt
|
||||
// are not guaranteed to have the same semantics.
|
||||
Value *Sqrt = emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B,
|
||||
Value *Sqrt = emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc_sqrt), B,
|
||||
Callee->getAttributes());
|
||||
|
||||
return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Sqrt, "sqrtrecip");
|
||||
@ -1093,8 +1093,8 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
}
|
||||
|
||||
if (Op2C->isExactlyValue(0.5) &&
|
||||
hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf,
|
||||
LibFunc::sqrtl)) {
|
||||
hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_sqrt, LibFunc_sqrtf,
|
||||
LibFunc_sqrtl)) {
|
||||
|
||||
// In -ffast-math, pow(x, 0.5) -> sqrt(x).
|
||||
if (CI->hasUnsafeAlgebra()) {
|
||||
@ -1103,7 +1103,7 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
// Unlike other math intrinsics, sqrt has differerent semantics
|
||||
// from the libc function. See LangRef for details.
|
||||
return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B,
|
||||
return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc_sqrt), B,
|
||||
Callee->getAttributes());
|
||||
}
|
||||
|
||||
@ -1175,11 +1175,11 @@ Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilder<> &B) {
|
||||
Value *Op = CI->getArgOperand(0);
|
||||
// Turn exp2(sitofp(x)) -> ldexp(1.0, sext(x)) if sizeof(x) <= 32
|
||||
// Turn exp2(uitofp(x)) -> ldexp(1.0, zext(x)) if sizeof(x) < 32
|
||||
LibFunc::Func LdExp = LibFunc::ldexpl;
|
||||
LibFunc LdExp = LibFunc_ldexpl;
|
||||
if (Op->getType()->isFloatTy())
|
||||
LdExp = LibFunc::ldexpf;
|
||||
LdExp = LibFunc_ldexpf;
|
||||
else if (Op->getType()->isDoubleTy())
|
||||
LdExp = LibFunc::ldexp;
|
||||
LdExp = LibFunc_ldexp;
|
||||
|
||||
if (TLI->has(LdExp)) {
|
||||
Value *LdExpArg = nullptr;
|
||||
@ -1286,17 +1286,17 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) {
|
||||
FMF.setUnsafeAlgebra();
|
||||
B.setFastMathFlags(FMF);
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *F = OpC->getCalledFunction();
|
||||
if (F && ((TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) &&
|
||||
Func == LibFunc::pow) || F->getIntrinsicID() == Intrinsic::pow))
|
||||
Func == LibFunc_pow) || F->getIntrinsicID() == Intrinsic::pow))
|
||||
return B.CreateFMul(OpC->getArgOperand(1),
|
||||
emitUnaryFloatFnCall(OpC->getOperand(0), Callee->getName(), B,
|
||||
Callee->getAttributes()), "mul");
|
||||
|
||||
// log(exp2(y)) -> y*log(2)
|
||||
if (F && Name == "log" && TLI->getLibFunc(F->getName(), Func) &&
|
||||
TLI->has(Func) && Func == LibFunc::exp2)
|
||||
TLI->has(Func) && Func == LibFunc_exp2)
|
||||
return B.CreateFMul(
|
||||
OpC->getArgOperand(0),
|
||||
emitUnaryFloatFnCall(ConstantFP::get(CI->getType(), 2.0),
|
||||
@ -1308,8 +1308,8 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) {
|
||||
Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilder<> &B) {
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
Value *Ret = nullptr;
|
||||
if (TLI->has(LibFunc::sqrtf) && (Callee->getName() == "sqrt" ||
|
||||
Callee->getIntrinsicID() == Intrinsic::sqrt))
|
||||
if (TLI->has(LibFunc_sqrtf) && (Callee->getName() == "sqrt" ||
|
||||
Callee->getIntrinsicID() == Intrinsic::sqrt))
|
||||
Ret = optimizeUnaryDoubleFP(CI, B, true);
|
||||
|
||||
if (!CI->hasUnsafeAlgebra())
|
||||
@ -1391,12 +1391,12 @@ Value *LibCallSimplifier::optimizeTan(CallInst *CI, IRBuilder<> &B) {
|
||||
// tan(atan(x)) -> x
|
||||
// tanf(atanf(x)) -> x
|
||||
// tanl(atanl(x)) -> x
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *F = OpC->getCalledFunction();
|
||||
if (F && TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) &&
|
||||
((Func == LibFunc::atan && Callee->getName() == "tan") ||
|
||||
(Func == LibFunc::atanf && Callee->getName() == "tanf") ||
|
||||
(Func == LibFunc::atanl && Callee->getName() == "tanl")))
|
||||
((Func == LibFunc_atan && Callee->getName() == "tan") ||
|
||||
(Func == LibFunc_atanf && Callee->getName() == "tanf") ||
|
||||
(Func == LibFunc_atanl && Callee->getName() == "tanl")))
|
||||
Ret = OpC->getArgOperand(0);
|
||||
return Ret;
|
||||
}
|
||||
@ -1514,24 +1514,24 @@ void LibCallSimplifier::classifyArgUse(
|
||||
return;
|
||||
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
if (!Callee || !TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) ||
|
||||
!isTrigLibCall(CI))
|
||||
return;
|
||||
|
||||
if (IsFloat) {
|
||||
if (Func == LibFunc::sinpif)
|
||||
if (Func == LibFunc_sinpif)
|
||||
SinCalls.push_back(CI);
|
||||
else if (Func == LibFunc::cospif)
|
||||
else if (Func == LibFunc_cospif)
|
||||
CosCalls.push_back(CI);
|
||||
else if (Func == LibFunc::sincospif_stret)
|
||||
else if (Func == LibFunc_sincospif_stret)
|
||||
SinCosCalls.push_back(CI);
|
||||
} else {
|
||||
if (Func == LibFunc::sinpi)
|
||||
if (Func == LibFunc_sinpi)
|
||||
SinCalls.push_back(CI);
|
||||
else if (Func == LibFunc::cospi)
|
||||
else if (Func == LibFunc_cospi)
|
||||
CosCalls.push_back(CI);
|
||||
else if (Func == LibFunc::sincospi_stret)
|
||||
else if (Func == LibFunc_sincospi_stret)
|
||||
SinCosCalls.push_back(CI);
|
||||
}
|
||||
}
|
||||
@ -1705,7 +1705,7 @@ Value *LibCallSimplifier::optimizePrintF(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
// printf(format, ...) -> iprintf(format, ...) if no floating point
|
||||
// arguments.
|
||||
if (TLI->has(LibFunc::iprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
if (TLI->has(LibFunc_iprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
Constant *IPrintFFn =
|
||||
M->getOrInsertFunction("iprintf", FT, Callee->getAttributes());
|
||||
@ -1786,7 +1786,7 @@ Value *LibCallSimplifier::optimizeSPrintF(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
// sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating
|
||||
// point arguments.
|
||||
if (TLI->has(LibFunc::siprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
if (TLI->has(LibFunc_siprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
Constant *SIPrintFFn =
|
||||
M->getOrInsertFunction("siprintf", FT, Callee->getAttributes());
|
||||
@ -1856,7 +1856,7 @@ Value *LibCallSimplifier::optimizeFPrintF(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
// fprintf(stream, format, ...) -> fiprintf(stream, format, ...) if no
|
||||
// floating point arguments.
|
||||
if (TLI->has(LibFunc::fiprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
if (TLI->has(LibFunc_fiprintf) && !callHasFloatingPointArgument(CI)) {
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
Constant *FIPrintFFn =
|
||||
M->getOrInsertFunction("fiprintf", FT, Callee->getAttributes());
|
||||
@ -1935,7 +1935,7 @@ Value *LibCallSimplifier::optimizePuts(CallInst *CI, IRBuilder<> &B) {
|
||||
}
|
||||
|
||||
bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) {
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
SmallString<20> FloatFuncName = FuncName;
|
||||
FloatFuncName += 'f';
|
||||
if (TLI->getLibFunc(FloatFuncName, Func))
|
||||
@ -1945,7 +1945,7 @@ bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) {
|
||||
|
||||
Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI,
|
||||
IRBuilder<> &Builder) {
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
// Check for string/memory library functions.
|
||||
if (TLI->getLibFunc(*Callee, Func) && TLI->has(Func)) {
|
||||
@ -1954,51 +1954,51 @@ Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI,
|
||||
isCallingConvCCompatible(CI)) &&
|
||||
"Optimizing string/memory libcall would change the calling convention");
|
||||
switch (Func) {
|
||||
case LibFunc::strcat:
|
||||
case LibFunc_strcat:
|
||||
return optimizeStrCat(CI, Builder);
|
||||
case LibFunc::strncat:
|
||||
case LibFunc_strncat:
|
||||
return optimizeStrNCat(CI, Builder);
|
||||
case LibFunc::strchr:
|
||||
case LibFunc_strchr:
|
||||
return optimizeStrChr(CI, Builder);
|
||||
case LibFunc::strrchr:
|
||||
case LibFunc_strrchr:
|
||||
return optimizeStrRChr(CI, Builder);
|
||||
case LibFunc::strcmp:
|
||||
case LibFunc_strcmp:
|
||||
return optimizeStrCmp(CI, Builder);
|
||||
case LibFunc::strncmp:
|
||||
case LibFunc_strncmp:
|
||||
return optimizeStrNCmp(CI, Builder);
|
||||
case LibFunc::strcpy:
|
||||
case LibFunc_strcpy:
|
||||
return optimizeStrCpy(CI, Builder);
|
||||
case LibFunc::stpcpy:
|
||||
case LibFunc_stpcpy:
|
||||
return optimizeStpCpy(CI, Builder);
|
||||
case LibFunc::strncpy:
|
||||
case LibFunc_strncpy:
|
||||
return optimizeStrNCpy(CI, Builder);
|
||||
case LibFunc::strlen:
|
||||
case LibFunc_strlen:
|
||||
return optimizeStrLen(CI, Builder);
|
||||
case LibFunc::strpbrk:
|
||||
case LibFunc_strpbrk:
|
||||
return optimizeStrPBrk(CI, Builder);
|
||||
case LibFunc::strtol:
|
||||
case LibFunc::strtod:
|
||||
case LibFunc::strtof:
|
||||
case LibFunc::strtoul:
|
||||
case LibFunc::strtoll:
|
||||
case LibFunc::strtold:
|
||||
case LibFunc::strtoull:
|
||||
case LibFunc_strtol:
|
||||
case LibFunc_strtod:
|
||||
case LibFunc_strtof:
|
||||
case LibFunc_strtoul:
|
||||
case LibFunc_strtoll:
|
||||
case LibFunc_strtold:
|
||||
case LibFunc_strtoull:
|
||||
return optimizeStrTo(CI, Builder);
|
||||
case LibFunc::strspn:
|
||||
case LibFunc_strspn:
|
||||
return optimizeStrSpn(CI, Builder);
|
||||
case LibFunc::strcspn:
|
||||
case LibFunc_strcspn:
|
||||
return optimizeStrCSpn(CI, Builder);
|
||||
case LibFunc::strstr:
|
||||
case LibFunc_strstr:
|
||||
return optimizeStrStr(CI, Builder);
|
||||
case LibFunc::memchr:
|
||||
case LibFunc_memchr:
|
||||
return optimizeMemChr(CI, Builder);
|
||||
case LibFunc::memcmp:
|
||||
case LibFunc_memcmp:
|
||||
return optimizeMemCmp(CI, Builder);
|
||||
case LibFunc::memcpy:
|
||||
case LibFunc_memcpy:
|
||||
return optimizeMemCpy(CI, Builder);
|
||||
case LibFunc::memmove:
|
||||
case LibFunc_memmove:
|
||||
return optimizeMemMove(CI, Builder);
|
||||
case LibFunc::memset:
|
||||
case LibFunc_memset:
|
||||
return optimizeMemSet(CI, Builder);
|
||||
default:
|
||||
break;
|
||||
@ -2011,7 +2011,7 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
|
||||
if (CI->isNoBuiltin())
|
||||
return nullptr;
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
StringRef FuncName = Callee->getName();
|
||||
|
||||
@ -2071,114 +2071,114 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
|
||||
if (Value *V = optimizeStringMemoryLibCall(CI, Builder))
|
||||
return V;
|
||||
switch (Func) {
|
||||
case LibFunc::cosf:
|
||||
case LibFunc::cos:
|
||||
case LibFunc::cosl:
|
||||
case LibFunc_cosf:
|
||||
case LibFunc_cos:
|
||||
case LibFunc_cosl:
|
||||
return optimizeCos(CI, Builder);
|
||||
case LibFunc::sinpif:
|
||||
case LibFunc::sinpi:
|
||||
case LibFunc::cospif:
|
||||
case LibFunc::cospi:
|
||||
case LibFunc_sinpif:
|
||||
case LibFunc_sinpi:
|
||||
case LibFunc_cospif:
|
||||
case LibFunc_cospi:
|
||||
return optimizeSinCosPi(CI, Builder);
|
||||
case LibFunc::powf:
|
||||
case LibFunc::pow:
|
||||
case LibFunc::powl:
|
||||
case LibFunc_powf:
|
||||
case LibFunc_pow:
|
||||
case LibFunc_powl:
|
||||
return optimizePow(CI, Builder);
|
||||
case LibFunc::exp2l:
|
||||
case LibFunc::exp2:
|
||||
case LibFunc::exp2f:
|
||||
case LibFunc_exp2l:
|
||||
case LibFunc_exp2:
|
||||
case LibFunc_exp2f:
|
||||
return optimizeExp2(CI, Builder);
|
||||
case LibFunc::fabsf:
|
||||
case LibFunc::fabs:
|
||||
case LibFunc::fabsl:
|
||||
case LibFunc_fabsf:
|
||||
case LibFunc_fabs:
|
||||
case LibFunc_fabsl:
|
||||
return optimizeFabs(CI, Builder);
|
||||
case LibFunc::sqrtf:
|
||||
case LibFunc::sqrt:
|
||||
case LibFunc::sqrtl:
|
||||
case LibFunc_sqrtf:
|
||||
case LibFunc_sqrt:
|
||||
case LibFunc_sqrtl:
|
||||
return optimizeSqrt(CI, Builder);
|
||||
case LibFunc::ffs:
|
||||
case LibFunc::ffsl:
|
||||
case LibFunc::ffsll:
|
||||
case LibFunc_ffs:
|
||||
case LibFunc_ffsl:
|
||||
case LibFunc_ffsll:
|
||||
return optimizeFFS(CI, Builder);
|
||||
case LibFunc::fls:
|
||||
case LibFunc::flsl:
|
||||
case LibFunc::flsll:
|
||||
case LibFunc_fls:
|
||||
case LibFunc_flsl:
|
||||
case LibFunc_flsll:
|
||||
return optimizeFls(CI, Builder);
|
||||
case LibFunc::abs:
|
||||
case LibFunc::labs:
|
||||
case LibFunc::llabs:
|
||||
case LibFunc_abs:
|
||||
case LibFunc_labs:
|
||||
case LibFunc_llabs:
|
||||
return optimizeAbs(CI, Builder);
|
||||
case LibFunc::isdigit:
|
||||
case LibFunc_isdigit:
|
||||
return optimizeIsDigit(CI, Builder);
|
||||
case LibFunc::isascii:
|
||||
case LibFunc_isascii:
|
||||
return optimizeIsAscii(CI, Builder);
|
||||
case LibFunc::toascii:
|
||||
case LibFunc_toascii:
|
||||
return optimizeToAscii(CI, Builder);
|
||||
case LibFunc::printf:
|
||||
case LibFunc_printf:
|
||||
return optimizePrintF(CI, Builder);
|
||||
case LibFunc::sprintf:
|
||||
case LibFunc_sprintf:
|
||||
return optimizeSPrintF(CI, Builder);
|
||||
case LibFunc::fprintf:
|
||||
case LibFunc_fprintf:
|
||||
return optimizeFPrintF(CI, Builder);
|
||||
case LibFunc::fwrite:
|
||||
case LibFunc_fwrite:
|
||||
return optimizeFWrite(CI, Builder);
|
||||
case LibFunc::fputs:
|
||||
case LibFunc_fputs:
|
||||
return optimizeFPuts(CI, Builder);
|
||||
case LibFunc::log:
|
||||
case LibFunc::log10:
|
||||
case LibFunc::log1p:
|
||||
case LibFunc::log2:
|
||||
case LibFunc::logb:
|
||||
case LibFunc_log:
|
||||
case LibFunc_log10:
|
||||
case LibFunc_log1p:
|
||||
case LibFunc_log2:
|
||||
case LibFunc_logb:
|
||||
return optimizeLog(CI, Builder);
|
||||
case LibFunc::puts:
|
||||
case LibFunc_puts:
|
||||
return optimizePuts(CI, Builder);
|
||||
case LibFunc::tan:
|
||||
case LibFunc::tanf:
|
||||
case LibFunc::tanl:
|
||||
case LibFunc_tan:
|
||||
case LibFunc_tanf:
|
||||
case LibFunc_tanl:
|
||||
return optimizeTan(CI, Builder);
|
||||
case LibFunc::perror:
|
||||
case LibFunc_perror:
|
||||
return optimizeErrorReporting(CI, Builder);
|
||||
case LibFunc::vfprintf:
|
||||
case LibFunc::fiprintf:
|
||||
case LibFunc_vfprintf:
|
||||
case LibFunc_fiprintf:
|
||||
return optimizeErrorReporting(CI, Builder, 0);
|
||||
case LibFunc::fputc:
|
||||
case LibFunc_fputc:
|
||||
return optimizeErrorReporting(CI, Builder, 1);
|
||||
case LibFunc::ceil:
|
||||
case LibFunc::floor:
|
||||
case LibFunc::rint:
|
||||
case LibFunc::round:
|
||||
case LibFunc::nearbyint:
|
||||
case LibFunc::trunc:
|
||||
case LibFunc_ceil:
|
||||
case LibFunc_floor:
|
||||
case LibFunc_rint:
|
||||
case LibFunc_round:
|
||||
case LibFunc_nearbyint:
|
||||
case LibFunc_trunc:
|
||||
if (hasFloatVersion(FuncName))
|
||||
return optimizeUnaryDoubleFP(CI, Builder, false);
|
||||
return nullptr;
|
||||
case LibFunc::acos:
|
||||
case LibFunc::acosh:
|
||||
case LibFunc::asin:
|
||||
case LibFunc::asinh:
|
||||
case LibFunc::atan:
|
||||
case LibFunc::atanh:
|
||||
case LibFunc::cbrt:
|
||||
case LibFunc::cosh:
|
||||
case LibFunc::exp:
|
||||
case LibFunc::exp10:
|
||||
case LibFunc::expm1:
|
||||
case LibFunc::sin:
|
||||
case LibFunc::sinh:
|
||||
case LibFunc::tanh:
|
||||
case LibFunc_acos:
|
||||
case LibFunc_acosh:
|
||||
case LibFunc_asin:
|
||||
case LibFunc_asinh:
|
||||
case LibFunc_atan:
|
||||
case LibFunc_atanh:
|
||||
case LibFunc_cbrt:
|
||||
case LibFunc_cosh:
|
||||
case LibFunc_exp:
|
||||
case LibFunc_exp10:
|
||||
case LibFunc_expm1:
|
||||
case LibFunc_sin:
|
||||
case LibFunc_sinh:
|
||||
case LibFunc_tanh:
|
||||
if (UnsafeFPShrink && hasFloatVersion(FuncName))
|
||||
return optimizeUnaryDoubleFP(CI, Builder, true);
|
||||
return nullptr;
|
||||
case LibFunc::copysign:
|
||||
case LibFunc_copysign:
|
||||
if (hasFloatVersion(FuncName))
|
||||
return optimizeBinaryDoubleFP(CI, Builder);
|
||||
return nullptr;
|
||||
case LibFunc::fminf:
|
||||
case LibFunc::fmin:
|
||||
case LibFunc::fminl:
|
||||
case LibFunc::fmaxf:
|
||||
case LibFunc::fmax:
|
||||
case LibFunc::fmaxl:
|
||||
case LibFunc_fminf:
|
||||
case LibFunc_fmin:
|
||||
case LibFunc_fminl:
|
||||
case LibFunc_fmaxf:
|
||||
case LibFunc_fmax:
|
||||
case LibFunc_fmaxl:
|
||||
return optimizeFMinFMax(CI, Builder);
|
||||
default:
|
||||
return nullptr;
|
||||
@ -2304,7 +2304,7 @@ Value *FortifiedLibCallSimplifier::optimizeMemSetChk(CallInst *CI,
|
||||
|
||||
Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
|
||||
IRBuilder<> &B,
|
||||
LibFunc::Func Func) {
|
||||
LibFunc Func) {
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
StringRef Name = Callee->getName();
|
||||
const DataLayout &DL = CI->getModule()->getDataLayout();
|
||||
@ -2312,7 +2312,7 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
|
||||
*ObjSize = CI->getArgOperand(2);
|
||||
|
||||
// __stpcpy_chk(x,x,...) -> x+strlen(x)
|
||||
if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
|
||||
if (Func == LibFunc_stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
|
||||
Value *StrLen = emitStrLen(Src, B, DL, TLI);
|
||||
return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr;
|
||||
}
|
||||
@ -2338,14 +2338,14 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
|
||||
Value *Ret = emitMemCpyChk(Dst, Src, LenV, ObjSize, B, DL, TLI);
|
||||
// If the function was an __stpcpy_chk, and we were able to fold it into
|
||||
// a __memcpy_chk, we still need to return the correct end pointer.
|
||||
if (Ret && Func == LibFunc::stpcpy_chk)
|
||||
if (Ret && Func == LibFunc_stpcpy_chk)
|
||||
return B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(SizeTTy, Len - 1));
|
||||
return Ret;
|
||||
}
|
||||
|
||||
Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(CallInst *CI,
|
||||
IRBuilder<> &B,
|
||||
LibFunc::Func Func) {
|
||||
LibFunc Func) {
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
StringRef Name = Callee->getName();
|
||||
if (isFortifiedCallFoldable(CI, 3, 2, false)) {
|
||||
@ -2370,7 +2370,7 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) {
|
||||
//
|
||||
// PR23093.
|
||||
|
||||
LibFunc::Func Func;
|
||||
LibFunc Func;
|
||||
Function *Callee = CI->getCalledFunction();
|
||||
|
||||
SmallVector<OperandBundleDef, 2> OpBundles;
|
||||
@ -2388,17 +2388,17 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) {
|
||||
return nullptr;
|
||||
|
||||
switch (Func) {
|
||||
case LibFunc::memcpy_chk:
|
||||
case LibFunc_memcpy_chk:
|
||||
return optimizeMemCpyChk(CI, Builder);
|
||||
case LibFunc::memmove_chk:
|
||||
case LibFunc_memmove_chk:
|
||||
return optimizeMemMoveChk(CI, Builder);
|
||||
case LibFunc::memset_chk:
|
||||
case LibFunc_memset_chk:
|
||||
return optimizeMemSetChk(CI, Builder);
|
||||
case LibFunc::stpcpy_chk:
|
||||
case LibFunc::strcpy_chk:
|
||||
case LibFunc_stpcpy_chk:
|
||||
case LibFunc_strcpy_chk:
|
||||
return optimizeStrpCpyChk(CI, Builder, Func);
|
||||
case LibFunc::stpncpy_chk:
|
||||
case LibFunc::strncpy_chk:
|
||||
case LibFunc_stpncpy_chk:
|
||||
case LibFunc_strncpy_chk:
|
||||
return optimizeStrpNCpyChk(CI, Builder, Func);
|
||||
default:
|
||||
break;
|
||||
|
@ -42,13 +42,13 @@ protected:
|
||||
}
|
||||
|
||||
::testing::AssertionResult isLibFunc(const Function *FDecl,
|
||||
LibFunc::Func ExpectedLF) {
|
||||
LibFunc ExpectedLF) {
|
||||
StringRef ExpectedLFName = TLI.getName(ExpectedLF);
|
||||
|
||||
if (!FDecl)
|
||||
return ::testing::AssertionFailure() << ExpectedLFName << " not found";
|
||||
|
||||
LibFunc::Func F;
|
||||
LibFunc F;
|
||||
if (!TLI.getLibFunc(*FDecl, F))
|
||||
return ::testing::AssertionFailure() << ExpectedLFName << " invalid";
|
||||
|
||||
@ -66,7 +66,7 @@ TEST_F(TargetLibraryInfoTest, InvalidProto) {
|
||||
auto *InvalidFTy = FunctionType::get(StructTy, /*isVarArg=*/false);
|
||||
|
||||
for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
|
||||
LibFunc::Func LF = (LibFunc::Func)FI;
|
||||
LibFunc LF = (LibFunc)FI;
|
||||
auto *F = cast<Function>(
|
||||
M->getOrInsertFunction(TLI.getName(LF), InvalidFTy));
|
||||
EXPECT_FALSE(isLibFunc(F, LF));
|
||||
@ -472,7 +472,7 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
|
||||
);
|
||||
|
||||
for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
|
||||
LibFunc::Func LF = (LibFunc::Func)FI;
|
||||
LibFunc LF = (LibFunc)FI;
|
||||
// Make sure everything is available; we're not testing target defaults.
|
||||
TLII.setAvailable(LF);
|
||||
Function *F = M->getFunction(TLI.getName(LF));
|
||||
|
Loading…
Reference in New Issue
Block a user