Index: include/llvm/Analysis/TargetLibraryInfo.h =================================================================== --- include/llvm/Analysis/TargetLibraryInfo.h +++ include/llvm/Analysis/TargetLibraryInfo.h @@ -30,14 +30,12 @@ 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 @@ class TargetLibraryInfoImpl { friend class TargetLibraryInfo; - unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4]; + unsigned char AvailableArray[(NumLibFuncs+3)/4]; llvm::DenseMap CustomNames; - static StringRef const StandardNames[LibFunc::NumLibFuncs]; + static StringRef const StandardNames[NumLibFuncs]; bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param; enum AvailabilityState { @@ -58,11 +56,11 @@ 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((AvailableArray[F/4] >> 2*(F&3)) & 3); } @@ -74,7 +72,7 @@ /// 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 @@ /// /// 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 @@ /// /// 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,36 @@ /// 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 LF_copysign: case LF_copysignf: case LF_copysignl: + case LF_fabs: case LF_fabsf: case LF_fabsl: + case LF_sin: case LF_sinf: case LF_sinl: + case LF_cos: case LF_cosf: case LF_cosl: + case LF_sqrt: case LF_sqrtf: case LF_sqrtl: + case LF_sqrt_finite: case LF_sqrtf_finite: case LF_sqrtl_finite: + case LF_fmax: case LF_fmaxf: case LF_fmaxl: + case LF_fmin: case LF_fminf: case LF_fminl: + case LF_floor: case LF_floorf: case LF_floorl: + case LF_nearbyint: case LF_nearbyintf: case LF_nearbyintl: + case LF_ceil: case LF_ceilf: case LF_ceill: + case LF_rint: case LF_rintf: case LF_rintl: + case LF_round: case LF_roundf: case LF_roundl: + case LF_trunc: case LF_truncf: case LF_truncl: + case LF_log2: case LF_log2f: case LF_log2l: + case LF_exp2: case LF_exp2f: case LF_exp2l: + case LF_memcmp: case LF_strcmp: case LF_strcpy: + case LF_stpcpy: case LF_strlen: case LF_strnlen: + case LF_memchr: case LF_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(); Index: include/llvm/Analysis/TargetLibraryInfo.def =================================================================== --- include/llvm/Analysis/TargetLibraryInfo.def +++ include/llvm/Analysis/TargetLibraryInfo.def @@ -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) LF_##enum_variant, #define TLI_DEFINE_STRING_INTERNAL(string_repr) #else #define TLI_DEFINE_ENUM_INTERNAL(enum_variant) Index: include/llvm/Transforms/Utils/SimplifyLibCalls.h =================================================================== --- include/llvm/Transforms/Utils/SimplifyLibCalls.h +++ include/llvm/Transforms/Utils/SimplifyLibCalls.h @@ -56,8 +56,8 @@ 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. Index: lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- lib/Analysis/BasicAliasAnalysis.cpp +++ lib/Analysis/BasicAliasAnalysis.cpp @@ -644,9 +644,9 @@ // 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::LF_memset_pattern16 && TLI.has(F)) if (ArgIdx == 0) return true; Index: lib/Analysis/ConstantFolding.cpp =================================================================== --- lib/Analysis/ConstantFolding.cpp +++ lib/Analysis/ConstantFolding.cpp @@ -1637,51 +1637,51 @@ switch (Name[0]) { case 'a': - if ((Name == "acos" && TLI->has(LibFunc::acos)) || - (Name == "acosf" && TLI->has(LibFunc::acosf))) + if ((Name == "acos" && TLI->has(LibFunc::LF_acos)) || + (Name == "acosf" && TLI->has(LibFunc::LF_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::LF_asin)) || + (Name == "asinf" && TLI->has(LibFunc::LF_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::LF_atan)) || + (Name == "atanf" && TLI->has(LibFunc::LF_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::LF_ceil)) || + (Name == "ceilf" && TLI->has(LibFunc::LF_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::LF_cos)) || + (Name == "cosf" && TLI->has(LibFunc::LF_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::LF_cosh)) || + (Name == "coshf" && TLI->has(LibFunc::LF_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::LF_exp)) || + (Name == "expf" && TLI->has(LibFunc::LF_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::LF_exp2)) || + (Name == "exp2f" && TLI->has(LibFunc::LF_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::LF_fabs)) || + (Name == "fabsf" && TLI->has(LibFunc::LF_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::LF_floor)) || + (Name == "floorf" && TLI->has(LibFunc::LF_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::LF_log)) || + (Name == "logf" && V > 0 && TLI->has(LibFunc::LF_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::LF_log10)) || + (Name == "log10f" && V > 0 && TLI->has(LibFunc::LF_log10f))) return ConstantFoldFP(log10, V, Ty); else if (IntrinsicID == Intrinsic::sqrt && (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())) { @@ -1698,26 +1698,26 @@ } break; case 'r': - if ((Name == "round" && TLI->has(LibFunc::round)) || - (Name == "roundf" && TLI->has(LibFunc::roundf))) + if ((Name == "round" && TLI->has(LibFunc::LF_round)) || + (Name == "roundf" && TLI->has(LibFunc::LF_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::LF_sin)) || + (Name == "sinf" && TLI->has(LibFunc::LF_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::LF_sinh)) || + (Name == "sinhf" && TLI->has(LibFunc::LF_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::LF_sqrt)) || + (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc::LF_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::LF_tan)) || + (Name == "tanf" && TLI->has(LibFunc::LF_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::LF_tanh)) || + (Name == "tanhf" && TLI->has(LibFunc::LF_tanhf))) return ConstantFoldFP(tanh, V, Ty); break; default: @@ -1822,14 +1822,14 @@ if (!TLI) return nullptr; - if ((Name == "pow" && TLI->has(LibFunc::pow)) || - (Name == "powf" && TLI->has(LibFunc::powf))) + if ((Name == "pow" && TLI->has(LibFunc::LF_pow)) || + (Name == "powf" && TLI->has(LibFunc::LF_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::LF_fmod)) || + (Name == "fmodf" && TLI->has(LibFunc::LF_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::LF_atan2)) || + (Name == "atan2f" && TLI->has(LibFunc::LF_atan2f))) return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty); } else if (auto *Op2C = dyn_cast(Operands[1])) { if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy()) @@ -2022,7 +2022,7 @@ if (!F) return false; - LibFunc::Func Func; + LibFunc Func; if (!TLI || !TLI->getLibFunc(*F, Func)) return false; @@ -2030,20 +2030,20 @@ if (ConstantFP *OpC = dyn_cast(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::LF_logl: + case LibFunc::LF_log: + case LibFunc::LF_logf: + case LibFunc::LF_log2l: + case LibFunc::LF_log2: + case LibFunc::LF_log2f: + case LibFunc::LF_log10l: + case LibFunc::LF_log10: + case LibFunc::LF_log10f: return Op.isNaN() || (!Op.isZero() && !Op.isNegative()); - case LibFunc::expl: - case LibFunc::exp: - case LibFunc::expf: + case LibFunc::LF_expl: + case LibFunc::LF_exp: + case LibFunc::LF_expf: // FIXME: These boundaries are slightly conservative. if (OpC->getType()->isDoubleTy()) return Op.compare(APFloat(-745.0)) != APFloat::cmpLessThan && @@ -2053,9 +2053,9 @@ Op.compare(APFloat(88.0f)) != APFloat::cmpGreaterThan; break; - case LibFunc::exp2l: - case LibFunc::exp2: - case LibFunc::exp2f: + case LibFunc::LF_exp2l: + case LibFunc::LF_exp2: + case LibFunc::LF_exp2f: // FIXME: These boundaries are slightly conservative. if (OpC->getType()->isDoubleTy()) return Op.compare(APFloat(-1074.0)) != APFloat::cmpLessThan && @@ -2065,17 +2065,17 @@ 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::LF_sinl: + case LibFunc::LF_sin: + case LibFunc::LF_sinf: + case LibFunc::LF_cosl: + case LibFunc::LF_cos: + case LibFunc::LF_cosf: return !Op.isInfinity(); - case LibFunc::tanl: - case LibFunc::tan: - case LibFunc::tanf: { + case LibFunc::LF_tanl: + case LibFunc::LF_tan: + case LibFunc::LF_tanf: { // FIXME: Stop using the host math library. // FIXME: The computation isn't done in the right precision. Type *Ty = OpC->getType(); @@ -2086,23 +2086,23 @@ break; } - case LibFunc::asinl: - case LibFunc::asin: - case LibFunc::asinf: - case LibFunc::acosl: - case LibFunc::acos: - case LibFunc::acosf: + case LibFunc::LF_asinl: + case LibFunc::LF_asin: + case LibFunc::LF_asinf: + case LibFunc::LF_acosl: + case LibFunc::LF_acos: + case LibFunc::LF_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::LF_sinh: + case LibFunc::LF_cosh: + case LibFunc::LF_sinhf: + case LibFunc::LF_coshf: + case LibFunc::LF_sinhl: + case LibFunc::LF_coshl: // FIXME: These boundaries are slightly conservative. if (OpC->getType()->isDoubleTy()) return Op.compare(APFloat(-710.0)) != APFloat::cmpLessThan && @@ -2112,9 +2112,9 @@ Op.compare(APFloat(89.0f)) != APFloat::cmpGreaterThan; break; - case LibFunc::sqrtl: - case LibFunc::sqrt: - case LibFunc::sqrtf: + case LibFunc::LF_sqrtl: + case LibFunc::LF_sqrt: + case LibFunc::LF_sqrtf: return Op.isNaN() || Op.isZero() || !Op.isNegative(); // FIXME: Add more functions: sqrt_finite, atanh, expm1, log1p, @@ -2133,9 +2133,9 @@ const APFloat &Op1 = Op1C->getValueAPF(); switch (Func) { - case LibFunc::powl: - case LibFunc::pow: - case LibFunc::powf: { + case LibFunc::LF_powl: + case LibFunc::LF_pow: + case LibFunc::LF_powf: { // FIXME: Stop using the host math library. // FIXME: The computation isn't done in the right precision. Type *Ty = Op0C->getType(); @@ -2149,9 +2149,9 @@ break; } - case LibFunc::fmodl: - case LibFunc::fmod: - case LibFunc::fmodf: + case LibFunc::LF_fmodl: + case LibFunc::LF_fmod: + case LibFunc::LF_fmodf: return Op0.isNaN() || Op1.isNaN() || (!Op0.isInfinity() && !Op1.isZero()); Index: lib/Analysis/MemoryBuiltins.cpp =================================================================== --- lib/Analysis/MemoryBuiltins.cpp +++ lib/Analysis/MemoryBuiltins.cpp @@ -50,30 +50,30 @@ // FIXME: certain users need more information. E.g., SimplifyLibCalls needs to // know which functions are nounwind, noalias, nocapture parameters, etc. -static const std::pair 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 AllocationFnData[] = { + {LF_malloc, {MallocLike, 1, 0, -1}}, + {LF_valloc, {MallocLike, 1, 0, -1}}, + {LF_Znwj, {OpNewLike, 1, 0, -1}}, // new(unsigned int) + {LF_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) + {LF_Znwm, {OpNewLike, 1, 0, -1}}, // new(unsigned long) + {LF_ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned long, nothrow) + {LF_Znaj, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) + {LF_ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) + {LF_Znam, {OpNewLike, 1, 0, -1}}, // new[](unsigned long) + {LF_ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned long, nothrow) + {LF_msvc_new_int, {OpNewLike, 1, 0, -1}}, // new(unsigned int) + {LF_msvc_new_int_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) + {LF_msvc_new_longlong, {OpNewLike, 1, 0, -1}}, // new(unsigned long long) + {LF_msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned long long, nothrow) + {LF_msvc_new_array_int, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) + {LF_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) + {LF_msvc_new_array_longlong, {OpNewLike, 1, 0, -1}}, // new[](unsigned long long) + {LF_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned long long, nothrow) + {LF_calloc, {CallocLike, 2, 0, 1}}, + {LF_realloc, {ReallocLike, 2, 1, -1}}, + {LF_reallocf, {ReallocLike, 2, 1, -1}}, + {LF_strdup, {StrDupLike, 1, -1, -1}}, + {LF_strndup, {StrDupLike, 2, 1, -1}} // TODO: Handle "int posix_memalign(void **, size_t, size_t)" }; @@ -106,12 +106,12 @@ 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 &P) { + AllocationFnData, [TLIFn](const std::pair &P) { return P.first == TLIFn; }); @@ -333,33 +333,33 @@ 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 == LF_free || + TLIFn == LF_ZdlPv || // operator delete(void*) + TLIFn == LF_ZdaPv || // operator delete[](void*) + TLIFn == LF_msvc_delete_ptr32 || // operator delete(void*) + TLIFn == LF_msvc_delete_ptr64 || // operator delete(void*) + TLIFn == LF_msvc_delete_array_ptr32 || // operator delete[](void*) + TLIFn == LF_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 == LF_ZdlPvj || // delete(void*, uint) + TLIFn == LF_ZdlPvm || // delete(void*, ulong) + TLIFn == LF_ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) + TLIFn == LF_ZdaPvj || // delete[](void*, uint) + TLIFn == LF_ZdaPvm || // delete[](void*, ulong) + TLIFn == LF_ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow) + TLIFn == LF_msvc_delete_ptr32_int || // delete(void*, uint) + TLIFn == LF_msvc_delete_ptr64_longlong || // delete(void*, ulonglong) + TLIFn == LF_msvc_delete_ptr32_nothrow || // delete(void*, nothrow) + TLIFn == LF_msvc_delete_ptr64_nothrow || // delete(void*, nothrow) + TLIFn == LF_msvc_delete_array_ptr32_int || // delete[](void*, uint) + TLIFn == LF_msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong) + TLIFn == LF_msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow) + TLIFn == LF_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow) ExpectedNumParams = 2; else return nullptr; Index: lib/Analysis/MemoryLocation.cpp =================================================================== --- lib/Analysis/MemoryLocation.cpp +++ lib/Analysis/MemoryLocation.cpp @@ -142,9 +142,9 @@ // 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::LF_memset_pattern16 && TLI.has(F)) { assert((ArgIdx == 0 || ArgIdx == 1) && "Invalid argument index for memset_pattern16"); if (ArgIdx == 1) Index: lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- lib/Analysis/TargetLibraryInfo.cpp +++ lib/Analysis/TargetLibraryInfo.cpp @@ -82,24 +82,24 @@ if (T.getArch() == Triple::r600 || T.getArch() == Triple::amdgcn) { - TLI.setUnavailable(LibFunc::ldexp); - TLI.setUnavailable(LibFunc::ldexpf); - TLI.setUnavailable(LibFunc::ldexpl); - TLI.setUnavailable(LibFunc::exp10); - TLI.setUnavailable(LibFunc::exp10f); - TLI.setUnavailable(LibFunc::exp10l); - TLI.setUnavailable(LibFunc::log10); - TLI.setUnavailable(LibFunc::log10f); - TLI.setUnavailable(LibFunc::log10l); + TLI.setUnavailable(LF_ldexp); + TLI.setUnavailable(LF_ldexpf); + TLI.setUnavailable(LF_ldexpl); + TLI.setUnavailable(LF_exp10); + TLI.setUnavailable(LF_exp10f); + TLI.setUnavailable(LF_exp10l); + TLI.setUnavailable(LF_log10); + TLI.setUnavailable(LF_log10f); + TLI.setUnavailable(LF_log10l); } // There are no library implementations of mempcy and memset for AMD gpus and // these can be difficult to lower in the backend. if (T.getArch() == Triple::r600 || T.getArch() == Triple::amdgcn) { - TLI.setUnavailable(LibFunc::memcpy); - TLI.setUnavailable(LibFunc::memset); - TLI.setUnavailable(LibFunc::memset_pattern16); + TLI.setUnavailable(LF_memcpy); + TLI.setUnavailable(LF_memset); + TLI.setUnavailable(LF_memset_pattern16); return; } @@ -107,21 +107,21 @@ // All versions of watchOS support it. if (T.isMacOSX()) { if (T.isMacOSXVersionLT(10, 5)) - TLI.setUnavailable(LibFunc::memset_pattern16); + TLI.setUnavailable(LF_memset_pattern16); } else if (T.isiOS()) { if (T.isOSVersionLT(3, 0)) - TLI.setUnavailable(LibFunc::memset_pattern16); + TLI.setUnavailable(LF_memset_pattern16); } else if (!T.isWatchOS()) { - TLI.setUnavailable(LibFunc::memset_pattern16); + TLI.setUnavailable(LF_memset_pattern16); } if (!hasSinCosPiStret(T)) { - TLI.setUnavailable(LibFunc::sinpi); - TLI.setUnavailable(LibFunc::sinpif); - TLI.setUnavailable(LibFunc::cospi); - TLI.setUnavailable(LibFunc::cospif); - TLI.setUnavailable(LibFunc::sincospi_stret); - TLI.setUnavailable(LibFunc::sincospif_stret); + TLI.setUnavailable(LF_sinpi); + TLI.setUnavailable(LF_sinpif); + TLI.setUnavailable(LF_cospi); + TLI.setUnavailable(LF_cospif); + TLI.setUnavailable(LF_sincospi_stret); + TLI.setUnavailable(LF_sincospif_stret); } if (T.isMacOSX() && T.getArch() == Triple::x86 && @@ -131,179 +131,179 @@ // has a $UNIX2003 suffix. The two implementations are identical except // for the return value in some edge cases. However, we don't want to // generate code that depends on the old symbols. - TLI.setAvailableWithName(LibFunc::fwrite, "fwrite$UNIX2003"); - TLI.setAvailableWithName(LibFunc::fputs, "fputs$UNIX2003"); + TLI.setAvailableWithName(LF_fwrite, "fwrite$UNIX2003"); + TLI.setAvailableWithName(LF_fputs, "fputs$UNIX2003"); } // iprintf and friends are only available on XCore and TCE. if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) { - TLI.setUnavailable(LibFunc::iprintf); - TLI.setUnavailable(LibFunc::siprintf); - TLI.setUnavailable(LibFunc::fiprintf); + TLI.setUnavailable(LF_iprintf); + TLI.setUnavailable(LF_siprintf); + TLI.setUnavailable(LF_fiprintf); } if (T.isOSWindows() && !T.isOSCygMing()) { // Win32 does not support long double - TLI.setUnavailable(LibFunc::acosl); - TLI.setUnavailable(LibFunc::asinl); - TLI.setUnavailable(LibFunc::atanl); - TLI.setUnavailable(LibFunc::atan2l); - TLI.setUnavailable(LibFunc::ceill); - TLI.setUnavailable(LibFunc::copysignl); - TLI.setUnavailable(LibFunc::cosl); - TLI.setUnavailable(LibFunc::coshl); - TLI.setUnavailable(LibFunc::expl); - TLI.setUnavailable(LibFunc::fabsf); // Win32 and Win64 both lack fabsf - TLI.setUnavailable(LibFunc::fabsl); - TLI.setUnavailable(LibFunc::floorl); - TLI.setUnavailable(LibFunc::fmaxl); - TLI.setUnavailable(LibFunc::fminl); - TLI.setUnavailable(LibFunc::fmodl); - TLI.setUnavailable(LibFunc::frexpl); - TLI.setUnavailable(LibFunc::ldexpf); - TLI.setUnavailable(LibFunc::ldexpl); - TLI.setUnavailable(LibFunc::logl); - TLI.setUnavailable(LibFunc::modfl); - TLI.setUnavailable(LibFunc::powl); - TLI.setUnavailable(LibFunc::sinl); - TLI.setUnavailable(LibFunc::sinhl); - TLI.setUnavailable(LibFunc::sqrtl); - TLI.setUnavailable(LibFunc::tanl); - TLI.setUnavailable(LibFunc::tanhl); + TLI.setUnavailable(LF_acosl); + TLI.setUnavailable(LF_asinl); + TLI.setUnavailable(LF_atanl); + TLI.setUnavailable(LF_atan2l); + TLI.setUnavailable(LF_ceill); + TLI.setUnavailable(LF_copysignl); + TLI.setUnavailable(LF_cosl); + TLI.setUnavailable(LF_coshl); + TLI.setUnavailable(LF_expl); + TLI.setUnavailable(LF_fabsf); // Win32 and Win64 both lack fabsf + TLI.setUnavailable(LF_fabsl); + TLI.setUnavailable(LF_floorl); + TLI.setUnavailable(LF_fmaxl); + TLI.setUnavailable(LF_fminl); + TLI.setUnavailable(LF_fmodl); + TLI.setUnavailable(LF_frexpl); + TLI.setUnavailable(LF_ldexpf); + TLI.setUnavailable(LF_ldexpl); + TLI.setUnavailable(LF_logl); + TLI.setUnavailable(LF_modfl); + TLI.setUnavailable(LF_powl); + TLI.setUnavailable(LF_sinl); + TLI.setUnavailable(LF_sinhl); + TLI.setUnavailable(LF_sqrtl); + TLI.setUnavailable(LF_tanl); + TLI.setUnavailable(LF_tanhl); // Win32 only has C89 math - TLI.setUnavailable(LibFunc::acosh); - TLI.setUnavailable(LibFunc::acoshf); - TLI.setUnavailable(LibFunc::acoshl); - TLI.setUnavailable(LibFunc::asinh); - TLI.setUnavailable(LibFunc::asinhf); - TLI.setUnavailable(LibFunc::asinhl); - TLI.setUnavailable(LibFunc::atanh); - TLI.setUnavailable(LibFunc::atanhf); - TLI.setUnavailable(LibFunc::atanhl); - TLI.setUnavailable(LibFunc::cbrt); - TLI.setUnavailable(LibFunc::cbrtf); - TLI.setUnavailable(LibFunc::cbrtl); - TLI.setUnavailable(LibFunc::exp2); - TLI.setUnavailable(LibFunc::exp2f); - TLI.setUnavailable(LibFunc::exp2l); - TLI.setUnavailable(LibFunc::expm1); - TLI.setUnavailable(LibFunc::expm1f); - TLI.setUnavailable(LibFunc::expm1l); - TLI.setUnavailable(LibFunc::log2); - TLI.setUnavailable(LibFunc::log2f); - TLI.setUnavailable(LibFunc::log2l); - TLI.setUnavailable(LibFunc::log1p); - TLI.setUnavailable(LibFunc::log1pf); - TLI.setUnavailable(LibFunc::log1pl); - TLI.setUnavailable(LibFunc::logb); - TLI.setUnavailable(LibFunc::logbf); - TLI.setUnavailable(LibFunc::logbl); - TLI.setUnavailable(LibFunc::nearbyint); - TLI.setUnavailable(LibFunc::nearbyintf); - TLI.setUnavailable(LibFunc::nearbyintl); - TLI.setUnavailable(LibFunc::rint); - TLI.setUnavailable(LibFunc::rintf); - TLI.setUnavailable(LibFunc::rintl); - TLI.setUnavailable(LibFunc::round); - TLI.setUnavailable(LibFunc::roundf); - TLI.setUnavailable(LibFunc::roundl); - TLI.setUnavailable(LibFunc::trunc); - TLI.setUnavailable(LibFunc::truncf); - TLI.setUnavailable(LibFunc::truncl); + TLI.setUnavailable(LF_acosh); + TLI.setUnavailable(LF_acoshf); + TLI.setUnavailable(LF_acoshl); + TLI.setUnavailable(LF_asinh); + TLI.setUnavailable(LF_asinhf); + TLI.setUnavailable(LF_asinhl); + TLI.setUnavailable(LF_atanh); + TLI.setUnavailable(LF_atanhf); + TLI.setUnavailable(LF_atanhl); + TLI.setUnavailable(LF_cbrt); + TLI.setUnavailable(LF_cbrtf); + TLI.setUnavailable(LF_cbrtl); + TLI.setUnavailable(LF_exp2); + TLI.setUnavailable(LF_exp2f); + TLI.setUnavailable(LF_exp2l); + TLI.setUnavailable(LF_expm1); + TLI.setUnavailable(LF_expm1f); + TLI.setUnavailable(LF_expm1l); + TLI.setUnavailable(LF_log2); + TLI.setUnavailable(LF_log2f); + TLI.setUnavailable(LF_log2l); + TLI.setUnavailable(LF_log1p); + TLI.setUnavailable(LF_log1pf); + TLI.setUnavailable(LF_log1pl); + TLI.setUnavailable(LF_logb); + TLI.setUnavailable(LF_logbf); + TLI.setUnavailable(LF_logbl); + TLI.setUnavailable(LF_nearbyint); + TLI.setUnavailable(LF_nearbyintf); + TLI.setUnavailable(LF_nearbyintl); + TLI.setUnavailable(LF_rint); + TLI.setUnavailable(LF_rintf); + TLI.setUnavailable(LF_rintl); + TLI.setUnavailable(LF_round); + TLI.setUnavailable(LF_roundf); + TLI.setUnavailable(LF_roundl); + TLI.setUnavailable(LF_trunc); + TLI.setUnavailable(LF_truncf); + TLI.setUnavailable(LF_truncl); // Win32 provides some C99 math with mangled names - TLI.setAvailableWithName(LibFunc::copysign, "_copysign"); + TLI.setAvailableWithName(LF_copysign, "_copysign"); if (T.getArch() == Triple::x86) { // Win32 on x86 implements single-precision math functions as macros - TLI.setUnavailable(LibFunc::acosf); - TLI.setUnavailable(LibFunc::asinf); - TLI.setUnavailable(LibFunc::atanf); - TLI.setUnavailable(LibFunc::atan2f); - TLI.setUnavailable(LibFunc::ceilf); - TLI.setUnavailable(LibFunc::copysignf); - TLI.setUnavailable(LibFunc::cosf); - TLI.setUnavailable(LibFunc::coshf); - TLI.setUnavailable(LibFunc::expf); - TLI.setUnavailable(LibFunc::floorf); - TLI.setUnavailable(LibFunc::fminf); - TLI.setUnavailable(LibFunc::fmaxf); - TLI.setUnavailable(LibFunc::fmodf); - TLI.setUnavailable(LibFunc::logf); - TLI.setUnavailable(LibFunc::log10f); - TLI.setUnavailable(LibFunc::modff); - TLI.setUnavailable(LibFunc::powf); - TLI.setUnavailable(LibFunc::sinf); - TLI.setUnavailable(LibFunc::sinhf); - TLI.setUnavailable(LibFunc::sqrtf); - TLI.setUnavailable(LibFunc::tanf); - TLI.setUnavailable(LibFunc::tanhf); + TLI.setUnavailable(LF_acosf); + TLI.setUnavailable(LF_asinf); + TLI.setUnavailable(LF_atanf); + TLI.setUnavailable(LF_atan2f); + TLI.setUnavailable(LF_ceilf); + TLI.setUnavailable(LF_copysignf); + TLI.setUnavailable(LF_cosf); + TLI.setUnavailable(LF_coshf); + TLI.setUnavailable(LF_expf); + TLI.setUnavailable(LF_floorf); + TLI.setUnavailable(LF_fminf); + TLI.setUnavailable(LF_fmaxf); + TLI.setUnavailable(LF_fmodf); + TLI.setUnavailable(LF_logf); + TLI.setUnavailable(LF_log10f); + TLI.setUnavailable(LF_modff); + TLI.setUnavailable(LF_powf); + TLI.setUnavailable(LF_sinf); + TLI.setUnavailable(LF_sinhf); + TLI.setUnavailable(LF_sqrtf); + TLI.setUnavailable(LF_tanf); + TLI.setUnavailable(LF_tanhf); } // Win32 does *not* provide provide these functions, but they are // generally available on POSIX-compliant systems: - TLI.setUnavailable(LibFunc::access); - TLI.setUnavailable(LibFunc::bcmp); - TLI.setUnavailable(LibFunc::bcopy); - TLI.setUnavailable(LibFunc::bzero); - TLI.setUnavailable(LibFunc::chmod); - TLI.setUnavailable(LibFunc::chown); - TLI.setUnavailable(LibFunc::closedir); - TLI.setUnavailable(LibFunc::ctermid); - TLI.setUnavailable(LibFunc::fdopen); - TLI.setUnavailable(LibFunc::ffs); - TLI.setUnavailable(LibFunc::fileno); - TLI.setUnavailable(LibFunc::flockfile); - TLI.setUnavailable(LibFunc::fseeko); - TLI.setUnavailable(LibFunc::fstat); - TLI.setUnavailable(LibFunc::fstatvfs); - TLI.setUnavailable(LibFunc::ftello); - TLI.setUnavailable(LibFunc::ftrylockfile); - TLI.setUnavailable(LibFunc::funlockfile); - TLI.setUnavailable(LibFunc::getc_unlocked); - TLI.setUnavailable(LibFunc::getitimer); - TLI.setUnavailable(LibFunc::getlogin_r); - TLI.setUnavailable(LibFunc::getpwnam); - TLI.setUnavailable(LibFunc::gettimeofday); - TLI.setUnavailable(LibFunc::htonl); - TLI.setUnavailable(LibFunc::htons); - TLI.setUnavailable(LibFunc::lchown); - TLI.setUnavailable(LibFunc::lstat); - TLI.setUnavailable(LibFunc::memccpy); - TLI.setUnavailable(LibFunc::mkdir); - TLI.setUnavailable(LibFunc::ntohl); - TLI.setUnavailable(LibFunc::ntohs); - TLI.setUnavailable(LibFunc::open); - TLI.setUnavailable(LibFunc::opendir); - TLI.setUnavailable(LibFunc::pclose); - TLI.setUnavailable(LibFunc::popen); - TLI.setUnavailable(LibFunc::pread); - TLI.setUnavailable(LibFunc::pwrite); - TLI.setUnavailable(LibFunc::read); - TLI.setUnavailable(LibFunc::readlink); - TLI.setUnavailable(LibFunc::realpath); - TLI.setUnavailable(LibFunc::rmdir); - TLI.setUnavailable(LibFunc::setitimer); - TLI.setUnavailable(LibFunc::stat); - TLI.setUnavailable(LibFunc::statvfs); - TLI.setUnavailable(LibFunc::stpcpy); - TLI.setUnavailable(LibFunc::stpncpy); - TLI.setUnavailable(LibFunc::strcasecmp); - TLI.setUnavailable(LibFunc::strncasecmp); - TLI.setUnavailable(LibFunc::times); - TLI.setUnavailable(LibFunc::uname); - TLI.setUnavailable(LibFunc::unlink); - TLI.setUnavailable(LibFunc::unsetenv); - TLI.setUnavailable(LibFunc::utime); - TLI.setUnavailable(LibFunc::utimes); - TLI.setUnavailable(LibFunc::write); + TLI.setUnavailable(LF_access); + TLI.setUnavailable(LF_bcmp); + TLI.setUnavailable(LF_bcopy); + TLI.setUnavailable(LF_bzero); + TLI.setUnavailable(LF_chmod); + TLI.setUnavailable(LF_chown); + TLI.setUnavailable(LF_closedir); + TLI.setUnavailable(LF_ctermid); + TLI.setUnavailable(LF_fdopen); + TLI.setUnavailable(LF_ffs); + TLI.setUnavailable(LF_fileno); + TLI.setUnavailable(LF_flockfile); + TLI.setUnavailable(LF_fseeko); + TLI.setUnavailable(LF_fstat); + TLI.setUnavailable(LF_fstatvfs); + TLI.setUnavailable(LF_ftello); + TLI.setUnavailable(LF_ftrylockfile); + TLI.setUnavailable(LF_funlockfile); + TLI.setUnavailable(LF_getc_unlocked); + TLI.setUnavailable(LF_getitimer); + TLI.setUnavailable(LF_getlogin_r); + TLI.setUnavailable(LF_getpwnam); + TLI.setUnavailable(LF_gettimeofday); + TLI.setUnavailable(LF_htonl); + TLI.setUnavailable(LF_htons); + TLI.setUnavailable(LF_lchown); + TLI.setUnavailable(LF_lstat); + TLI.setUnavailable(LF_memccpy); + TLI.setUnavailable(LF_mkdir); + TLI.setUnavailable(LF_ntohl); + TLI.setUnavailable(LF_ntohs); + TLI.setUnavailable(LF_open); + TLI.setUnavailable(LF_opendir); + TLI.setUnavailable(LF_pclose); + TLI.setUnavailable(LF_popen); + TLI.setUnavailable(LF_pread); + TLI.setUnavailable(LF_pwrite); + TLI.setUnavailable(LF_read); + TLI.setUnavailable(LF_readlink); + TLI.setUnavailable(LF_realpath); + TLI.setUnavailable(LF_rmdir); + TLI.setUnavailable(LF_setitimer); + TLI.setUnavailable(LF_stat); + TLI.setUnavailable(LF_statvfs); + TLI.setUnavailable(LF_stpcpy); + TLI.setUnavailable(LF_stpncpy); + TLI.setUnavailable(LF_strcasecmp); + TLI.setUnavailable(LF_strncasecmp); + TLI.setUnavailable(LF_times); + TLI.setUnavailable(LF_uname); + TLI.setUnavailable(LF_unlink); + TLI.setUnavailable(LF_unsetenv); + TLI.setUnavailable(LF_utime); + TLI.setUnavailable(LF_utimes); + TLI.setUnavailable(LF_write); // Win32 does *not* provide provide these functions, but they are // specified by C99: - TLI.setUnavailable(LibFunc::atoll); - TLI.setUnavailable(LibFunc::frexpf); - TLI.setUnavailable(LibFunc::llabs); + TLI.setUnavailable(LF_atoll); + TLI.setUnavailable(LF_frexpf); + TLI.setUnavailable(LF_llabs); } switch (T.getOS()) { @@ -311,28 +311,28 @@ // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0 // and their names are __exp10 and __exp10f. exp10l is not available on // OS X or iOS. - TLI.setUnavailable(LibFunc::exp10l); + TLI.setUnavailable(LF_exp10l); if (T.isMacOSXVersionLT(10, 9)) { - TLI.setUnavailable(LibFunc::exp10); - TLI.setUnavailable(LibFunc::exp10f); + TLI.setUnavailable(LF_exp10); + TLI.setUnavailable(LF_exp10f); } else { - TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); - TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); + TLI.setAvailableWithName(LF_exp10, "__exp10"); + TLI.setAvailableWithName(LF_exp10f, "__exp10f"); } break; case Triple::IOS: case Triple::TvOS: case Triple::WatchOS: - TLI.setUnavailable(LibFunc::exp10l); + TLI.setUnavailable(LF_exp10l); if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) || (T.isOSVersionLT(9, 0) && (T.getArch() == Triple::x86 || T.getArch() == Triple::x86_64)))) { - TLI.setUnavailable(LibFunc::exp10); - TLI.setUnavailable(LibFunc::exp10f); + TLI.setUnavailable(LF_exp10); + TLI.setUnavailable(LF_exp10f); } else { - TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); - TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); + TLI.setAvailableWithName(LF_exp10, "__exp10"); + TLI.setAvailableWithName(LF_exp10f, "__exp10f"); } break; case Triple::Linux: @@ -344,9 +344,9 @@ // Fall through to disable all of them. LLVM_FALLTHROUGH; default: - TLI.setUnavailable(LibFunc::exp10); - TLI.setUnavailable(LibFunc::exp10f); - TLI.setUnavailable(LibFunc::exp10l); + TLI.setUnavailable(LF_exp10); + TLI.setUnavailable(LF_exp10f); + TLI.setUnavailable(LF_exp10l); } // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and @@ -364,7 +364,7 @@ case Triple::Linux: break; default: - TLI.setUnavailable(LibFunc::ffsl); + TLI.setUnavailable(LF_ffsl); } // ffsll is available on at least FreeBSD and Linux (GLIBC): @@ -380,7 +380,7 @@ case Triple::Linux: break; default: - TLI.setUnavailable(LibFunc::ffsll); + TLI.setUnavailable(LF_ffsll); } // The following functions are available on at least FreeBSD: @@ -388,30 +388,30 @@ // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c if (!T.isOSFreeBSD()) { - TLI.setUnavailable(LibFunc::fls); - TLI.setUnavailable(LibFunc::flsl); - TLI.setUnavailable(LibFunc::flsll); + TLI.setUnavailable(LF_fls); + TLI.setUnavailable(LF_flsl); + TLI.setUnavailable(LF_flsll); } // The following functions are available on at least Linux: if (!T.isOSLinux()) { - TLI.setUnavailable(LibFunc::dunder_strdup); - TLI.setUnavailable(LibFunc::dunder_strtok_r); - TLI.setUnavailable(LibFunc::dunder_isoc99_scanf); - TLI.setUnavailable(LibFunc::dunder_isoc99_sscanf); - TLI.setUnavailable(LibFunc::under_IO_getc); - TLI.setUnavailable(LibFunc::under_IO_putc); - TLI.setUnavailable(LibFunc::memalign); - TLI.setUnavailable(LibFunc::fopen64); - TLI.setUnavailable(LibFunc::fseeko64); - TLI.setUnavailable(LibFunc::fstat64); - TLI.setUnavailable(LibFunc::fstatvfs64); - TLI.setUnavailable(LibFunc::ftello64); - TLI.setUnavailable(LibFunc::lstat64); - TLI.setUnavailable(LibFunc::open64); - TLI.setUnavailable(LibFunc::stat64); - TLI.setUnavailable(LibFunc::statvfs64); - TLI.setUnavailable(LibFunc::tmpfile64); + TLI.setUnavailable(LF_dunder_strdup); + TLI.setUnavailable(LF_dunder_strtok_r); + TLI.setUnavailable(LF_dunder_isoc99_scanf); + TLI.setUnavailable(LF_dunder_isoc99_sscanf); + TLI.setUnavailable(LF_under_IO_getc); + TLI.setUnavailable(LF_under_IO_putc); + TLI.setUnavailable(LF_memalign); + TLI.setUnavailable(LF_fopen64); + TLI.setUnavailable(LF_fseeko64); + TLI.setUnavailable(LF_fstat64); + TLI.setUnavailable(LF_fstatvfs64); + TLI.setUnavailable(LF_ftello64); + TLI.setUnavailable(LF_lstat64); + TLI.setUnavailable(LF_open64); + TLI.setUnavailable(LF_stat64); + TLI.setUnavailable(LF_statvfs64); + TLI.setUnavailable(LF_tmpfile64); } // As currently implemented in clang, NVPTX code has no standard library to @@ -427,9 +427,9 @@ // optimizations, so this situation should be fixed. if (T.isNVPTX()) { TLI.disableAllFunctions(); - TLI.setAvailable(LibFunc::nvvm_reflect); + TLI.setAvailable(LF_nvvm_reflect); } else { - TLI.setUnavailable(LibFunc::nvvm_reflect); + TLI.setUnavailable(LF_nvvm_reflect); } TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary); @@ -500,9 +500,9 @@ } bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName, - LibFunc::Func &F) const { + LibFunc &F) const { StringRef const *Start = &StandardNames[0]; - StringRef const *End = &StandardNames[LibFunc::NumLibFuncs]; + StringRef const *End = &StandardNames[NumLibFuncs]; funcName = sanitizeFunctionName(funcName); if (funcName.empty()) @@ -513,14 +513,14 @@ return LHS < RHS; }); if (I != End && *I == funcName) { - F = (LibFunc::Func)(I - Start); + F = (LibFunc)(I - Start); return true; } return false; } bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, - LibFunc::Func F, + LibFunc F, const DataLayout *DL) const { LLVMContext &Ctx = FTy.getContext(); Type *PCharTy = Type::getInt8PtrTy(Ctx); @@ -531,492 +531,492 @@ unsigned NumParams = FTy.getNumParams(); switch (F) { - case LibFunc::strlen: + case LF_strlen: return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && FTy.getReturnType()->isIntegerTy()); - case LibFunc::strchr: - case LibFunc::strrchr: + case LF_strchr: + case LF_strrchr: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0) == FTy.getReturnType() && FTy.getParamType(1)->isIntegerTy()); - case LibFunc::strtol: - case LibFunc::strtod: - case LibFunc::strtof: - case LibFunc::strtoul: - case LibFunc::strtoll: - case LibFunc::strtold: - case LibFunc::strtoull: + case LF_strtol: + case LF_strtod: + case LF_strtof: + case LF_strtoul: + case LF_strtoll: + case LF_strtold: + case LF_strtoull: return ((NumParams == 2 || NumParams == 3) && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::strcat: + case LF_strcat: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0) == FTy.getReturnType() && FTy.getParamType(1) == FTy.getReturnType()); - case LibFunc::strncat: + case LF_strncat: return (NumParams == 3 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0) == FTy.getReturnType() && FTy.getParamType(1) == FTy.getReturnType() && FTy.getParamType(2)->isIntegerTy()); - case LibFunc::strcpy_chk: - case LibFunc::stpcpy_chk: + case LF_strcpy_chk: + case LF_stpcpy_chk: --NumParams; if (!IsSizeTTy(FTy.getParamType(NumParams))) return false; LLVM_FALLTHROUGH; - case LibFunc::strcpy: - case LibFunc::stpcpy: + case LF_strcpy: + case LF_stpcpy: return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(0) && FTy.getParamType(0) == FTy.getParamType(1) && FTy.getParamType(0) == PCharTy); - case LibFunc::strncpy_chk: - case LibFunc::stpncpy_chk: + case LF_strncpy_chk: + case LF_stpncpy_chk: --NumParams; if (!IsSizeTTy(FTy.getParamType(NumParams))) return false; LLVM_FALLTHROUGH; - case LibFunc::strncpy: - case LibFunc::stpncpy: + case LF_strncpy: + case LF_stpncpy: return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && FTy.getParamType(0) == FTy.getParamType(1) && FTy.getParamType(0) == PCharTy && FTy.getParamType(2)->isIntegerTy()); - case LibFunc::strxfrm: + case LF_strxfrm: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::strcmp: + case LF_strcmp: return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(0) == FTy.getParamType(1)); - case LibFunc::strncmp: + case LF_strncmp: return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(0) == FTy.getParamType(1) && FTy.getParamType(2)->isIntegerTy()); - case LibFunc::strspn: - case LibFunc::strcspn: + case LF_strspn: + case LF_strcspn: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(0) == FTy.getParamType(1) && FTy.getReturnType()->isIntegerTy()); - case LibFunc::strcoll: - case LibFunc::strcasecmp: - case LibFunc::strncasecmp: + case LF_strcoll: + case LF_strcasecmp: + case LF_strncasecmp: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::strstr: + case LF_strstr: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::strpbrk: + case LF_strpbrk: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getReturnType() == FTy.getParamType(0) && FTy.getParamType(0) == FTy.getParamType(1)); - case LibFunc::strtok: - case LibFunc::strtok_r: + case LF_strtok: + case LF_strtok_r: return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::scanf: - case LibFunc::setbuf: - case LibFunc::setvbuf: + case LF_scanf: + case LF_setbuf: + case LF_setvbuf: return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::strdup: - case LibFunc::strndup: + case LF_strdup: + case LF_strndup: return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy()); - case LibFunc::sscanf: - case LibFunc::stat: - case LibFunc::statvfs: - case LibFunc::sprintf: + case LF_sscanf: + case LF_stat: + case LF_statvfs: + case LF_sprintf: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::snprintf: + case LF_snprintf: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::setitimer: + case LF_setitimer: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::system: + case LF_system: return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::malloc: + case LF_malloc: return (NumParams == 1 && FTy.getReturnType()->isPointerTy()); - case LibFunc::memcmp: + case LF_memcmp: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy() && FTy.getReturnType()->isIntegerTy(32)); - case LibFunc::memchr: - case LibFunc::memrchr: + case LF_memchr: + case LF_memrchr: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isIntegerTy(32) && FTy.getParamType(2)->isIntegerTy() && FTy.getReturnType()->isPointerTy()); - case LibFunc::modf: - case LibFunc::modff: - case LibFunc::modfl: + case LF_modf: + case LF_modff: + case LF_modfl: return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::memcpy_chk: - case LibFunc::memmove_chk: + case LF_memcpy_chk: + case LF_memmove_chk: --NumParams; if (!IsSizeTTy(FTy.getParamType(NumParams))) return false; LLVM_FALLTHROUGH; - case LibFunc::memcpy: - case LibFunc::mempcpy: - case LibFunc::memmove: + case LF_memcpy: + case LF_mempcpy: + case LF_memmove: return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy() && IsSizeTTy(FTy.getParamType(2))); - case LibFunc::memset_chk: + case LF_memset_chk: --NumParams; if (!IsSizeTTy(FTy.getParamType(NumParams))) return false; LLVM_FALLTHROUGH; - case LibFunc::memset: + case LF_memset: return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isIntegerTy() && IsSizeTTy(FTy.getParamType(2))); - case LibFunc::memccpy: + case LF_memccpy: return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::memalign: + case LF_memalign: return (FTy.getReturnType()->isPointerTy()); - case LibFunc::realloc: + case LF_realloc: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getReturnType()->isPointerTy()); - case LibFunc::read: + case LF_read: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::rewind: - case LibFunc::rmdir: - case LibFunc::remove: - case LibFunc::realpath: + case LF_rewind: + case LF_rmdir: + case LF_remove: + case LF_realpath: return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::rename: + case LF_rename: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::readlink: + case LF_readlink: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::write: + case LF_write: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::bcopy: - case LibFunc::bcmp: + case LF_bcopy: + case LF_bcmp: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::bzero: + case LF_bzero: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::calloc: + case LF_calloc: return (NumParams == 2 && FTy.getReturnType()->isPointerTy()); - case LibFunc::atof: - case LibFunc::atoi: - case LibFunc::atol: - case LibFunc::atoll: - case LibFunc::ferror: - case LibFunc::getenv: - case LibFunc::getpwnam: - case LibFunc::pclose: - case LibFunc::perror: - case LibFunc::printf: - case LibFunc::puts: - case LibFunc::uname: - case LibFunc::under_IO_getc: - case LibFunc::unlink: - case LibFunc::unsetenv: + case LF_atof: + case LF_atoi: + case LF_atol: + case LF_atoll: + case LF_ferror: + case LF_getenv: + case LF_getpwnam: + case LF_pclose: + case LF_perror: + case LF_printf: + case LF_puts: + case LF_uname: + case LF_under_IO_getc: + case LF_unlink: + case LF_unsetenv: return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::chmod: - case LibFunc::chown: - case LibFunc::clearerr: - case LibFunc::closedir: - case LibFunc::ctermid: - case LibFunc::fclose: - case LibFunc::feof: - case LibFunc::fflush: - case LibFunc::fgetc: - case LibFunc::fileno: - case LibFunc::flockfile: - case LibFunc::free: - case LibFunc::fseek: - case LibFunc::fseeko64: - case LibFunc::fseeko: - case LibFunc::fsetpos: - case LibFunc::ftell: - case LibFunc::ftello64: - case LibFunc::ftello: - case LibFunc::ftrylockfile: - case LibFunc::funlockfile: - case LibFunc::getc: - case LibFunc::getc_unlocked: - case LibFunc::getlogin_r: - case LibFunc::mkdir: - case LibFunc::mktime: - case LibFunc::times: + case LF_chmod: + case LF_chown: + case LF_clearerr: + case LF_closedir: + case LF_ctermid: + case LF_fclose: + case LF_feof: + case LF_fflush: + case LF_fgetc: + case LF_fileno: + case LF_flockfile: + case LF_free: + case LF_fseek: + case LF_fseeko64: + case LF_fseeko: + case LF_fsetpos: + case LF_ftell: + case LF_ftello64: + case LF_ftello: + case LF_ftrylockfile: + case LF_funlockfile: + case LF_getc: + case LF_getc_unlocked: + case LF_getlogin_r: + case LF_mkdir: + case LF_mktime: + case LF_times: return (NumParams != 0 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::access: + case LF_access: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::fopen: + case LF_fopen: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fdopen: + case LF_fdopen: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fputc: - case LibFunc::fstat: - case LibFunc::frexp: - case LibFunc::frexpf: - case LibFunc::frexpl: - case LibFunc::fstatvfs: + case LF_fputc: + case LF_fstat: + case LF_frexp: + case LF_frexpf: + case LF_frexpl: + case LF_fstatvfs: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fgets: + case LF_fgets: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::fread: + case LF_fread: return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(3)->isPointerTy()); - case LibFunc::fwrite: + case LF_fwrite: return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isIntegerTy() && FTy.getParamType(2)->isIntegerTy() && FTy.getParamType(3)->isPointerTy()); - case LibFunc::fputs: + case LF_fputs: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fscanf: - case LibFunc::fprintf: + case LF_fscanf: + case LF_fprintf: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fgetpos: + case LF_fgetpos: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::gets: - case LibFunc::getchar: - case LibFunc::getitimer: + case LF_gets: + case LF_getchar: + case LF_getitimer: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::ungetc: + case LF_ungetc: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::utime: - case LibFunc::utimes: + case LF_utime: + case LF_utimes: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::putc: + case LF_putc: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::pread: - case LibFunc::pwrite: + case LF_pread: + case LF_pwrite: return (NumParams == 4 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::popen: + case LF_popen: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::vscanf: + case LF_vscanf: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::vsscanf: + case LF_vsscanf: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::vfscanf: + case LF_vfscanf: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::valloc: + case LF_valloc: return (FTy.getReturnType()->isPointerTy()); - case LibFunc::vprintf: + case LF_vprintf: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::vfprintf: - case LibFunc::vsprintf: + case LF_vfprintf: + case LF_vsprintf: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::vsnprintf: + case LF_vsnprintf: return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::open: + case LF_open: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::opendir: + case LF_opendir: return (NumParams == 1 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy()); - case LibFunc::tmpfile: + case LF_tmpfile: return (FTy.getReturnType()->isPointerTy()); - case LibFunc::htonl: - case LibFunc::htons: - case LibFunc::ntohl: - case LibFunc::ntohs: - case LibFunc::lstat: + case LF_htonl: + case LF_htons: + case LF_ntohl: + case LF_ntohs: + case LF_lstat: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::lchown: + case LF_lchown: return (NumParams == 3 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::qsort: + case LF_qsort: return (NumParams == 4 && FTy.getParamType(3)->isPointerTy()); - case LibFunc::dunder_strdup: - case LibFunc::dunder_strndup: + case LF_dunder_strdup: + case LF_dunder_strndup: return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy()); - case LibFunc::dunder_strtok_r: + case LF_dunder_strtok_r: return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::under_IO_putc: + case LF_under_IO_putc: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::dunder_isoc99_scanf: + case LF_dunder_isoc99_scanf: return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::stat64: - case LibFunc::lstat64: - case LibFunc::statvfs64: + case LF_stat64: + case LF_lstat64: + case LF_statvfs64: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::dunder_isoc99_sscanf: + case LF_dunder_isoc99_sscanf: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::fopen64: + case LF_fopen64: return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - case LibFunc::tmpfile64: + case LF_tmpfile64: return (FTy.getReturnType()->isPointerTy()); - case LibFunc::fstat64: - case LibFunc::fstatvfs64: + case LF_fstat64: + case LF_fstatvfs64: return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); - case LibFunc::open64: + case LF_open64: return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); - case LibFunc::gettimeofday: + case LF_gettimeofday: return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy()); - 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 LF_Znwj: // new(unsigned int); + case LF_Znwm: // new(unsigned long); + case LF_Znaj: // new[](unsigned int); + case LF_Znam: // new[](unsigned long); + case LF_msvc_new_int: // new(unsigned int); + case LF_msvc_new_longlong: // new(unsigned long long); + case LF_msvc_new_array_int: // new[](unsigned int); + case LF_msvc_new_array_longlong: // new[](unsigned long long); return (NumParams == 1); - case LibFunc::memset_pattern16: + case LF_memset_pattern16: return (!FTy.isVarArg() && NumParams == 3 && isa(FTy.getParamType(0)) && isa(FTy.getParamType(1)) && isa(FTy.getParamType(2))); // int __nvvm_reflect(const char *); - case LibFunc::nvvm_reflect: + case LF_nvvm_reflect: return (NumParams == 1 && isa(FTy.getParamType(0))); - case LibFunc::sin: - case LibFunc::sinf: - case LibFunc::sinl: - case LibFunc::cos: - case LibFunc::cosf: - case LibFunc::cosl: - case LibFunc::tan: - case LibFunc::tanf: - case LibFunc::tanl: - case LibFunc::exp: - case LibFunc::expf: - case LibFunc::expl: - case LibFunc::exp2: - case LibFunc::exp2f: - case LibFunc::exp2l: - case LibFunc::log: - case LibFunc::logf: - case LibFunc::logl: - case LibFunc::log10: - case LibFunc::log10f: - case LibFunc::log10l: - case LibFunc::log2: - case LibFunc::log2f: - case LibFunc::log2l: - case LibFunc::fabs: - case LibFunc::fabsf: - case LibFunc::fabsl: - case LibFunc::floor: - case LibFunc::floorf: - case LibFunc::floorl: - case LibFunc::ceil: - case LibFunc::ceilf: - case LibFunc::ceill: - case LibFunc::trunc: - case LibFunc::truncf: - case LibFunc::truncl: - case LibFunc::rint: - case LibFunc::rintf: - case LibFunc::rintl: - case LibFunc::nearbyint: - case LibFunc::nearbyintf: - case LibFunc::nearbyintl: - case LibFunc::round: - case LibFunc::roundf: - case LibFunc::roundl: - case LibFunc::sqrt: - case LibFunc::sqrtf: - case LibFunc::sqrtl: + case LF_sin: + case LF_sinf: + case LF_sinl: + case LF_cos: + case LF_cosf: + case LF_cosl: + case LF_tan: + case LF_tanf: + case LF_tanl: + case LF_exp: + case LF_expf: + case LF_expl: + case LF_exp2: + case LF_exp2f: + case LF_exp2l: + case LF_log: + case LF_logf: + case LF_logl: + case LF_log10: + case LF_log10f: + case LF_log10l: + case LF_log2: + case LF_log2f: + case LF_log2l: + case LF_fabs: + case LF_fabsf: + case LF_fabsl: + case LF_floor: + case LF_floorf: + case LF_floorl: + case LF_ceil: + case LF_ceilf: + case LF_ceill: + case LF_trunc: + case LF_truncf: + case LF_truncl: + case LF_rint: + case LF_rintf: + case LF_rintl: + case LF_nearbyint: + case LF_nearbyintf: + case LF_nearbyintl: + case LF_round: + case LF_roundf: + case LF_roundl: + case LF_sqrt: + case LF_sqrtf: + case LF_sqrtl: return (NumParams == 1 && FTy.getReturnType()->isFloatingPointTy() && FTy.getReturnType() == FTy.getParamType(0)); - case LibFunc::fmin: - case LibFunc::fminf: - case LibFunc::fminl: - case LibFunc::fmax: - case LibFunc::fmaxf: - case LibFunc::fmaxl: - case LibFunc::copysign: - case LibFunc::copysignf: - case LibFunc::copysignl: - case LibFunc::pow: - case LibFunc::powf: - case LibFunc::powl: + case LF_fmin: + case LF_fminf: + case LF_fminl: + case LF_fmax: + case LF_fmaxf: + case LF_fmaxl: + case LF_copysign: + case LF_copysignf: + case LF_copysignl: + case LF_pow: + case LF_powf: + case LF_powl: return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() && FTy.getReturnType() == FTy.getParamType(0) && FTy.getReturnType() == FTy.getParamType(1)); - case LibFunc::ffs: - case LibFunc::ffsl: - case LibFunc::ffsll: - case LibFunc::fls: - case LibFunc::flsl: - case LibFunc::flsll: + case LF_ffs: + case LF_ffsl: + case LF_ffsll: + case LF_fls: + case LF_flsl: + case LF_flsll: return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && FTy.getParamType(0)->isIntegerTy()); - case LibFunc::isdigit: - case LibFunc::isascii: - case LibFunc::toascii: + case LF_isdigit: + case LF_isascii: + case LF_toascii: return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && FTy.getReturnType() == FTy.getParamType(0)); - case LibFunc::abs: - case LibFunc::labs: - case LibFunc::llabs: + case LF_abs: + case LF_labs: + case LF_llabs: return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() && FTy.getReturnType() == FTy.getParamType(0)); - case LibFunc::cxa_atexit: + case LF_cxa_atexit: return (NumParams == 3 && FTy.getReturnType()->isIntegerTy() && FTy.getParamType(0)->isPointerTy() && FTy.getParamType(1)->isPointerTy() && FTy.getParamType(2)->isPointerTy()); - case LibFunc::sinpi: - case LibFunc::cospi: + case LF_sinpi: + case LF_cospi: return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() && FTy.getReturnType() == FTy.getParamType(0)); - case LibFunc::sinpif: - case LibFunc::cospif: + case LF_sinpif: + case LF_cospif: return (NumParams == 1 && FTy.getReturnType()->isFloatTy() && FTy.getReturnType() == FTy.getParamType(0)); @@ -1028,7 +1028,7 @@ } bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl, - LibFunc::Func &F) const { + LibFunc &F) const { const DataLayout *DL = FDecl.getParent() ? &FDecl.getParent()->getDataLayout() : nullptr; return getLibFunc(FDecl.getName(), F) && Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -2433,7 +2433,7 @@ 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. @@ -2448,81 +2448,81 @@ switch (Func) { default: break; - case LibFunc::sin: - case LibFunc::sinf: - case LibFunc::sinl: + case LF_sin: + case LF_sinf: + case LF_sinl: return Intrinsic::sin; - case LibFunc::cos: - case LibFunc::cosf: - case LibFunc::cosl: + case LF_cos: + case LF_cosf: + case LF_cosl: return Intrinsic::cos; - case LibFunc::exp: - case LibFunc::expf: - case LibFunc::expl: + case LF_exp: + case LF_expf: + case LF_expl: return Intrinsic::exp; - case LibFunc::exp2: - case LibFunc::exp2f: - case LibFunc::exp2l: + case LF_exp2: + case LF_exp2f: + case LF_exp2l: return Intrinsic::exp2; - case LibFunc::log: - case LibFunc::logf: - case LibFunc::logl: + case LF_log: + case LF_logf: + case LF_logl: return Intrinsic::log; - case LibFunc::log10: - case LibFunc::log10f: - case LibFunc::log10l: + case LF_log10: + case LF_log10f: + case LF_log10l: return Intrinsic::log10; - case LibFunc::log2: - case LibFunc::log2f: - case LibFunc::log2l: + case LF_log2: + case LF_log2f: + case LF_log2l: return Intrinsic::log2; - case LibFunc::fabs: - case LibFunc::fabsf: - case LibFunc::fabsl: + case LF_fabs: + case LF_fabsf: + case LF_fabsl: return Intrinsic::fabs; - case LibFunc::fmin: - case LibFunc::fminf: - case LibFunc::fminl: + case LF_fmin: + case LF_fminf: + case LF_fminl: return Intrinsic::minnum; - case LibFunc::fmax: - case LibFunc::fmaxf: - case LibFunc::fmaxl: + case LF_fmax: + case LF_fmaxf: + case LF_fmaxl: return Intrinsic::maxnum; - case LibFunc::copysign: - case LibFunc::copysignf: - case LibFunc::copysignl: + case LF_copysign: + case LF_copysignf: + case LF_copysignl: return Intrinsic::copysign; - case LibFunc::floor: - case LibFunc::floorf: - case LibFunc::floorl: + case LF_floor: + case LF_floorf: + case LF_floorl: return Intrinsic::floor; - case LibFunc::ceil: - case LibFunc::ceilf: - case LibFunc::ceill: + case LF_ceil: + case LF_ceilf: + case LF_ceill: return Intrinsic::ceil; - case LibFunc::trunc: - case LibFunc::truncf: - case LibFunc::truncl: + case LF_trunc: + case LF_truncf: + case LF_truncl: return Intrinsic::trunc; - case LibFunc::rint: - case LibFunc::rintf: - case LibFunc::rintl: + case LF_rint: + case LF_rintf: + case LF_rintl: return Intrinsic::rint; - case LibFunc::nearbyint: - case LibFunc::nearbyintf: - case LibFunc::nearbyintl: + case LF_nearbyint: + case LF_nearbyintf: + case LF_nearbyintl: return Intrinsic::nearbyint; - case LibFunc::round: - case LibFunc::roundf: - case LibFunc::roundl: + case LF_round: + case LF_roundf: + case LF_roundl: return Intrinsic::round; - case LibFunc::pow: - case LibFunc::powf: - case LibFunc::powl: + case LF_pow: + case LF_powf: + case LF_powl: return Intrinsic::pow; - case LibFunc::sqrt: - case LibFunc::sqrtf: - case LibFunc::sqrtl: + case LF_sqrt: + case LF_sqrtf: + case LF_sqrtl: if (ICS->hasNoNaNs()) return Intrinsic::sqrt; return Intrinsic::not_intrinsic; Index: lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FastISel.cpp +++ lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1362,7 +1362,7 @@ if (const auto *Call = dyn_cast(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. Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6360,15 +6360,15 @@ // 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 LF_copysign: + case LF_copysignf: + case LF_copysignl: if (I.getNumArgOperands() == 2 && // Basic sanity checks. I.getArgOperand(0)->getType()->isFloatingPointTy() && I.getType() == I.getArgOperand(0)->getType() && @@ -6381,122 +6381,122 @@ return; } break; - case LibFunc::fabs: - case LibFunc::fabsf: - case LibFunc::fabsl: + case LF_fabs: + case LF_fabsf: + case LF_fabsl: if (visitUnaryFloatCall(I, ISD::FABS)) return; break; - case LibFunc::fmin: - case LibFunc::fminf: - case LibFunc::fminl: + case LF_fmin: + case LF_fminf: + case LF_fminl: if (visitBinaryFloatCall(I, ISD::FMINNUM)) return; break; - case LibFunc::fmax: - case LibFunc::fmaxf: - case LibFunc::fmaxl: + case LF_fmax: + case LF_fmaxf: + case LF_fmaxl: if (visitBinaryFloatCall(I, ISD::FMAXNUM)) return; break; - case LibFunc::sin: - case LibFunc::sinf: - case LibFunc::sinl: + case LF_sin: + case LF_sinf: + case LF_sinl: if (visitUnaryFloatCall(I, ISD::FSIN)) return; break; - case LibFunc::cos: - case LibFunc::cosf: - case LibFunc::cosl: + case LF_cos: + case LF_cosf: + case LF_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 LF_sqrt: + case LF_sqrtf: + case LF_sqrtl: + case LF_sqrt_finite: + case LF_sqrtf_finite: + case LF_sqrtl_finite: if (visitUnaryFloatCall(I, ISD::FSQRT)) return; break; - case LibFunc::floor: - case LibFunc::floorf: - case LibFunc::floorl: + case LF_floor: + case LF_floorf: + case LF_floorl: if (visitUnaryFloatCall(I, ISD::FFLOOR)) return; break; - case LibFunc::nearbyint: - case LibFunc::nearbyintf: - case LibFunc::nearbyintl: + case LF_nearbyint: + case LF_nearbyintf: + case LF_nearbyintl: if (visitUnaryFloatCall(I, ISD::FNEARBYINT)) return; break; - case LibFunc::ceil: - case LibFunc::ceilf: - case LibFunc::ceill: + case LF_ceil: + case LF_ceilf: + case LF_ceill: if (visitUnaryFloatCall(I, ISD::FCEIL)) return; break; - case LibFunc::rint: - case LibFunc::rintf: - case LibFunc::rintl: + case LF_rint: + case LF_rintf: + case LF_rintl: if (visitUnaryFloatCall(I, ISD::FRINT)) return; break; - case LibFunc::round: - case LibFunc::roundf: - case LibFunc::roundl: + case LF_round: + case LF_roundf: + case LF_roundl: if (visitUnaryFloatCall(I, ISD::FROUND)) return; break; - case LibFunc::trunc: - case LibFunc::truncf: - case LibFunc::truncl: + case LF_trunc: + case LF_truncf: + case LF_truncl: if (visitUnaryFloatCall(I, ISD::FTRUNC)) return; break; - case LibFunc::log2: - case LibFunc::log2f: - case LibFunc::log2l: + case LF_log2: + case LF_log2f: + case LF_log2l: if (visitUnaryFloatCall(I, ISD::FLOG2)) return; break; - case LibFunc::exp2: - case LibFunc::exp2f: - case LibFunc::exp2l: + case LF_exp2: + case LF_exp2f: + case LF_exp2l: if (visitUnaryFloatCall(I, ISD::FEXP2)) return; break; - case LibFunc::memcmp: + case LF_memcmp: if (visitMemCmpCall(I)) return; break; - case LibFunc::mempcpy: + case LF_mempcpy: if (visitMemPCpyCall(I)) return; break; - case LibFunc::memchr: + case LF_memchr: if (visitMemChrCall(I)) return; break; - case LibFunc::strcpy: + case LF_strcpy: if (visitStrCpyCall(I, false)) return; break; - case LibFunc::stpcpy: + case LF_stpcpy: if (visitStrCpyCall(I, true)) return; break; - case LibFunc::strcmp: + case LF_strcmp: if (visitStrCmpCall(I)) return; break; - case LibFunc::strlen: + case LF_strlen: if (visitStrLenCall(I)) return; break; - case LibFunc::strnlen: + case LF_strnlen: if (visitStrNLenCall(I)) return; break; Index: lib/LTO/UpdateCompilerUsed.cpp =================================================================== --- lib/LTO/UpdateCompilerUsed.cpp +++ lib/LTO/UpdateCompilerUsed.cpp @@ -65,7 +65,7 @@ // target. for (unsigned I = 0, E = static_cast(LibFunc::NumLibFuncs); I != E; ++I) { - LibFunc::Func F = static_cast(I); + LibFunc F = static_cast(I); if (TLI.has(F)) Libcalls.insert(TLI.getName(F)); } Index: lib/Target/PowerPC/PPCCTRLoops.cpp =================================================================== --- lib/Target/PowerPC/PPCCTRLoops.cpp +++ lib/Target/PowerPC/PPCCTRLoops.cpp @@ -315,7 +315,7 @@ // (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 @@ switch (Func) { default: return true; - case LibFunc::copysign: - case LibFunc::copysignf: + case LF_copysign: + case LF_copysignf: continue; // ISD::FCOPYSIGN is never a library call. - case LibFunc::copysignl: + case LF_copysignl: return true; - case LibFunc::fabs: - case LibFunc::fabsf: - case LibFunc::fabsl: + case LF_fabs: + case LF_fabsf: + case LF_fabsl: continue; // ISD::FABS is never a library call. - case LibFunc::sqrt: - case LibFunc::sqrtf: - case LibFunc::sqrtl: + case LF_sqrt: + case LF_sqrtf: + case LF_sqrtl: Opcode = ISD::FSQRT; break; - case LibFunc::floor: - case LibFunc::floorf: - case LibFunc::floorl: + case LF_floor: + case LF_floorf: + case LF_floorl: Opcode = ISD::FFLOOR; break; - case LibFunc::nearbyint: - case LibFunc::nearbyintf: - case LibFunc::nearbyintl: + case LF_nearbyint: + case LF_nearbyintf: + case LF_nearbyintl: Opcode = ISD::FNEARBYINT; break; - case LibFunc::ceil: - case LibFunc::ceilf: - case LibFunc::ceill: + case LF_ceil: + case LF_ceilf: + case LF_ceill: Opcode = ISD::FCEIL; break; - case LibFunc::rint: - case LibFunc::rintf: - case LibFunc::rintl: + case LF_rint: + case LF_rintf: + case LF_rintl: Opcode = ISD::FRINT; break; - case LibFunc::round: - case LibFunc::roundf: - case LibFunc::roundl: + case LF_round: + case LF_roundf: + case LF_roundl: Opcode = ISD::FROUND; break; - case LibFunc::trunc: - case LibFunc::truncf: - case LibFunc::truncl: + case LF_trunc: + case LF_truncf: + case LF_truncl: Opcode = ISD::FTRUNC; break; - case LibFunc::fmin: - case LibFunc::fminf: - case LibFunc::fminl: + case LF_fmin: + case LF_fminf: + case LF_fminl: Opcode = ISD::FMINNUM; break; - case LibFunc::fmax: - case LibFunc::fmaxf: - case LibFunc::fmaxl: + case LF_fmax: + case LF_fmaxf: + case LF_fmaxl: Opcode = ISD::FMAXNUM; break; } } Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -2387,7 +2387,7 @@ } static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) { - LibFunc::Func F = LibFunc::cxa_atexit; + LibFunc F = LibFunc::LF_cxa_atexit; if (!TLI->has(F)) return nullptr; @@ -2396,7 +2396,7 @@ 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::LF_cxa_atexit) return nullptr; return Fn; Index: lib/Transforms/Scalar/DeadStoreElimination.cpp =================================================================== --- lib/Transforms/Scalar/DeadStoreElimination.cpp +++ lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -135,14 +135,22 @@ 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::LF_strcpy) && + FnName == TLI.getName(LibFunc::LF_strcpy)) { return true; - if (TLI.has(LibFunc::strncpy) && FnName == TLI.getName(LibFunc::strncpy)) + } + if (TLI.has(LibFunc::LF_strncpy) && + FnName == TLI.getName(LibFunc::LF_strncpy)) { return true; - if (TLI.has(LibFunc::strcat) && FnName == TLI.getName(LibFunc::strcat)) + } + if (TLI.has(LibFunc::LF_strcat) && + FnName == TLI.getName(LibFunc::LF_strcat)) { return true; - if (TLI.has(LibFunc::strncat) && FnName == TLI.getName(LibFunc::strncat)) + } + if (TLI.has(LibFunc::LF_strncat) && + FnName == TLI.getName(LibFunc::LF_strncat)) { return true; + } } } return false; Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp =================================================================== --- lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -248,9 +248,9 @@ 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::LF_memset); + HasMemsetPattern = TLI->has(LibFunc::LF_memset_pattern16); + HasMemcpy = TLI->has(LibFunc::LF_memcpy); if (HasMemset || HasMemsetPattern || HasMemcpy) if (SE->hasLoopInvariantBackedgeTakenCount(L)) Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp =================================================================== --- lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -1240,7 +1240,7 @@ bool MemCpyOptPass::processMemMove(MemMoveInst *M) { AliasAnalysis &AA = LookupAliasAnalysis(); - if (!TLI->has(LibFunc::memmove)) + if (!TLI->has(LibFunc::LF_memmove)) return false; // See if the pointers alias. @@ -1414,7 +1414,7 @@ // 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::LF_memset) || !TLI->has(LibFunc::LF_memcpy)) return false; while (1) { Index: lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp =================================================================== --- lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +++ lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp @@ -98,14 +98,14 @@ // 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 LF_sqrtf: + case LF_sqrt: if (TTI->haveFastSqrt(Call->getType()) && optimizeSQRT(Call, CalledFunc, *CurrBB, BB)) break; Index: lib/Transforms/Utils/BuildLibCalls.cpp =================================================================== --- lib/Transforms/Utils/BuildLibCalls.cpp +++ lib/Transforms/Utils/BuildLibCalls.cpp @@ -107,255 +107,255 @@ } 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 LF_strlen: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::strchr: - case LibFunc::strrchr: + case LF_strchr: + case LF_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 LF_strtol: + case LF_strtod: + case LF_strtof: + case LF_strtoul: + case LF_strtoll: + case LF_strtold: + case LF_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 LF_strcpy: + case LF_stpcpy: + case LF_strcat: + case LF_strncat: + case LF_strncpy: + case LF_stpncpy: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::strxfrm: + case LF_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 LF_strcmp: // 0,1 + case LF_strspn: // 0,1 + case LF_strncmp: // 0,1 + case LF_strcspn: // 0,1 + case LF_strcoll: // 0,1 + case LF_strcasecmp: // 0,1 + case LF_strncasecmp: // Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::strstr: - case LibFunc::strpbrk: + case LF_strstr: + case LF_strpbrk: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::strtok: - case LibFunc::strtok_r: + case LF_strtok: + case LF_strtok_r: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::scanf: + case LF_scanf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::setbuf: - case LibFunc::setvbuf: + case LF_setbuf: + case LF_setvbuf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::strdup: - case LibFunc::strndup: + case LF_strdup: + case LF_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 LF_stat: + case LF_statvfs: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::sscanf: + case LF_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 LF_sprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::snprintf: + case LF_snprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 3); Changed |= setOnlyReadsMemory(F, 3); return Changed; - case LibFunc::setitimer: + case LF_setitimer: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); Changed |= setDoesNotCapture(F, 3); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::system: + case LF_system: // May throw; "system" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::malloc: + case LF_malloc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::memcmp: + case LF_memcmp: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::memchr: - case LibFunc::memrchr: + case LF_memchr: + case LF_memrchr: Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotThrow(F); return Changed; - case LibFunc::modf: - case LibFunc::modff: - case LibFunc::modfl: + case LF_modf: + case LF_modff: + case LF_modfl: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::memcpy: - case LibFunc::mempcpy: - case LibFunc::memccpy: - case LibFunc::memmove: + case LF_memcpy: + case LF_mempcpy: + case LF_memccpy: + case LF_memmove: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::memcpy_chk: + case LF_memcpy_chk: Changed |= setDoesNotThrow(F); return Changed; - case LibFunc::memalign: + case LF_memalign: Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::mkdir: + case LF_mkdir: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::mktime: + case LF_mktime: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::realloc: + case LF_realloc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::read: + case LF_read: // May throw; "read" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::rewind: + case LF_rewind: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::rmdir: - case LibFunc::remove: - case LibFunc::realpath: + case LF_rmdir: + case LF_remove: + case LF_realpath: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::rename: + case LF_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 LF_readlink: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::write: + case LF_write: // May throw; "write" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::bcopy: + case LF_bcopy: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::bcmp: + case LF_bcmp: Changed |= setDoesNotThrow(F); Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::bzero: + case LF_bzero: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::calloc: + case LF_calloc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::chmod: - case LibFunc::chown: + case LF_chmod: + case LF_chown: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::ctermid: - case LibFunc::clearerr: - case LibFunc::closedir: + case LF_ctermid: + case LF_clearerr: + case LF_closedir: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::atoi: - case LibFunc::atol: - case LibFunc::atof: - case LibFunc::atoll: + case LF_atoi: + case LF_atol: + case LF_atof: + case LF_atoll: Changed |= setDoesNotThrow(F); Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::access: + case LF_access: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::fopen: + case LF_fopen: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); @@ -363,150 +363,150 @@ Changed |= setOnlyReadsMemory(F, 1); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::fdopen: + case LF_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 LF_feof: + case LF_free: + case LF_fseek: + case LF_ftell: + case LF_fgetc: + case LF_fseeko: + case LF_ftello: + case LF_fileno: + case LF_fflush: + case LF_fclose: + case LF_fsetpos: + case LF_flockfile: + case LF_funlockfile: + case LF_ftrylockfile: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::ferror: + case LF_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 LF_fputc: + case LF_fstat: + case LF_frexp: + case LF_frexpf: + case LF_frexpl: + case LF_fstatvfs: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::fgets: + case LF_fgets: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 3); return Changed; - case LibFunc::fread: + case LF_fread: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 4); return Changed; - case LibFunc::fwrite: + case LF_fwrite: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 4); // FIXME: readonly #1? return Changed; - case LibFunc::fputs: + case LF_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 LF_fscanf: + case LF_fprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::fgetpos: + case LF_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 LF_getc: + case LF_getlogin_r: + case LF_getc_unlocked: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::getenv: + case LF_getenv: Changed |= setDoesNotThrow(F); Changed |= setOnlyReadsMemory(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::gets: - case LibFunc::getchar: + case LF_gets: + case LF_getchar: Changed |= setDoesNotThrow(F); return Changed; - case LibFunc::getitimer: + case LF_getitimer: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::getpwnam: + case LF_getpwnam: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::ungetc: + case LF_ungetc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::uname: + case LF_uname: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::unlink: + case LF_unlink: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::unsetenv: + case LF_unsetenv: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::utime: - case LibFunc::utimes: + case LF_utime: + case LF_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 LF_putc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::puts: - case LibFunc::printf: - case LibFunc::perror: + case LF_puts: + case LF_printf: + case LF_perror: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::pread: + case LF_pread: // May throw; "pread" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::pwrite: + case LF_pwrite: // May throw; "pwrite" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::putchar: + case LF_putchar: Changed |= setDoesNotThrow(F); return Changed; - case LibFunc::popen: + case LF_popen: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); @@ -514,132 +514,132 @@ Changed |= setOnlyReadsMemory(F, 1); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::pclose: + case LF_pclose: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::vscanf: + case LF_vscanf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::vsscanf: + case LF_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 LF_vfscanf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::valloc: + case LF_valloc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::vprintf: + case LF_vprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::vfprintf: - case LibFunc::vsprintf: + case LF_vfprintf: + case LF_vsprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::vsnprintf: + case LF_vsnprintf: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 3); Changed |= setOnlyReadsMemory(F, 3); return Changed; - case LibFunc::open: + case LF_open: // May throw; "open" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::opendir: + case LF_opendir: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::tmpfile: + case LF_tmpfile: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::times: + case LF_times: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::htonl: - case LibFunc::htons: - case LibFunc::ntohl: - case LibFunc::ntohs: + case LF_htonl: + case LF_htons: + case LF_ntohl: + case LF_ntohs: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAccessMemory(F); return Changed; - case LibFunc::lstat: + case LF_lstat: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::lchown: + case LF_lchown: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::qsort: + case LF_qsort: // May throw; places call through function pointer. Changed |= setDoesNotCapture(F, 4); return Changed; - case LibFunc::dunder_strdup: - case LibFunc::dunder_strndup: + case LF_dunder_strdup: + case LF_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 LF_dunder_strtok_r: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::under_IO_getc: + case LF_under_IO_getc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::under_IO_putc: + case LF_under_IO_putc: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::dunder_isoc99_scanf: + case LF_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 LF_stat64: + case LF_lstat64: + case LF_statvfs64: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); Changed |= setDoesNotCapture(F, 2); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::dunder_isoc99_sscanf: + case LF_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 LF_fopen64: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); Changed |= setDoesNotCapture(F, 1); @@ -647,26 +647,26 @@ Changed |= setOnlyReadsMemory(F, 1); Changed |= setOnlyReadsMemory(F, 2); return Changed; - case LibFunc::fseeko64: - case LibFunc::ftello64: + case LF_fseeko64: + case LF_ftello64: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 1); return Changed; - case LibFunc::tmpfile64: + case LF_tmpfile64: Changed |= setDoesNotThrow(F); Changed |= setDoesNotAlias(F, 0); return Changed; - case LibFunc::fstat64: - case LibFunc::fstatvfs64: + case LF_fstat64: + case LF_fstatvfs64: Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 2); return Changed; - case LibFunc::open64: + case LF_open64: // May throw; "open" is a valid pthread cancellation point. Changed |= setDoesNotCapture(F, 1); Changed |= setOnlyReadsMemory(F, 1); return Changed; - case LibFunc::gettimeofday: + case LF_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 @@ 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 LF_Znwj: // new(unsigned int) + case LF_Znwm: // new(unsigned long) + case LF_Znaj: // new[](unsigned int) + case LF_Znam: // new[](unsigned long) + case LF_msvc_new_int: // new(unsigned int) + case LF_msvc_new_longlong: // new(unsigned long long) + case LF_msvc_new_array_int: // new[](unsigned int) + case LF_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 LF_memset_pattern4: + //case LF_memset_pattern8: + case LF_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 LF_nvvm_reflect: Changed |= setDoesNotAccessMemory(F); Changed |= setDoesNotThrow(F); return Changed; @@ -717,7 +717,7 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::strlen)) + if (!TLI->has(LibFunc::LF_strlen)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -734,7 +734,7 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::strchr)) + if (!TLI->has(LibFunc::LF_strchr)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -752,7 +752,7 @@ 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::LF_strncmp)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -772,7 +772,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, const TargetLibraryInfo *TLI, StringRef Name) { - if (!TLI->has(LibFunc::strcpy)) + if (!TLI->has(LibFunc::LF_strcpy)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -788,7 +788,7 @@ 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::LF_strncpy)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -806,7 +806,7 @@ 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::LF_memcpy_chk)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -828,7 +828,7 @@ 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::LF_memchr)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -847,7 +847,7 @@ 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::LF_memcmp)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -914,7 +914,7 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::putchar)) + if (!TLI->has(LibFunc::LF_putchar)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -934,7 +934,7 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::puts)) + if (!TLI->has(LibFunc::LF_puts)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -949,7 +949,7 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::fputc)) + if (!TLI->has(LibFunc::LF_fputc)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); @@ -968,11 +968,11 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI) { - if (!TLI->has(LibFunc::fputs)) + if (!TLI->has(LibFunc::LF_fputs)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); - StringRef FPutsName = TLI->getName(LibFunc::fputs); + StringRef FPutsName = TLI->getName(LibFunc::LF_fputs); Constant *F = M->getOrInsertFunction( FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType(), nullptr); if (File->getType()->isPointerTy()) @@ -986,12 +986,12 @@ 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::LF_fwrite)) return nullptr; Module *M = B.GetInsertBlock()->getModule(); LLVMContext &Context = B.GetInsertBlock()->getContext(); - StringRef FWriteName = TLI->getName(LibFunc::fwrite); + StringRef FWriteName = TLI->getName(LibFunc::LF_fwrite); Constant *F = M->getOrInsertFunction( FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(), DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType(), Index: lib/Transforms/Utils/LibCallsShrinkWrap.cpp =================================================================== --- lib/Transforms/Utils/LibCallsShrinkWrap.cpp +++ lib/Transforms/Utils/LibCallsShrinkWrap.cpp @@ -100,12 +100,12 @@ 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 @@ // 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 LF_acos: // DomainError: (x < -1 || x > 1) + case LF_acosf: // Same as acos + case LF_acosl: // Same as acos + case LF_asin: // DomainError: (x < -1 || x > 1) + case LF_asinf: // Same as asin + case LF_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 LF_cos: // DomainError: (x == +inf || x == -inf) + case LF_cosf: // Same as cos + case LF_cosl: // Same as cos + case LF_sin: // DomainError: (x == +inf || x == -inf) + case LF_sinf: // Same as sin + case LF_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 LF_acosh: // DomainError: (x < 1) + case LF_acoshf: // Same as acosh + case LF_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 LF_sqrt: // DomainError: (x < 0) + case LF_sqrtf: // Same as sqrt + case LF_sqrtl: // Same as sqrt { ++NumWrappedOneCond; Cond = createCond(CI, CmpInst::FCMP_OLT, 0.0f); @@ -193,31 +193,31 @@ // 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 LF_cosh: + case LF_coshf: + case LF_coshl: + case LF_exp: + case LF_expf: + case LF_expl: + case LF_exp10: + case LF_exp10f: + case LF_exp10l: + case LF_exp2: + case LF_exp2f: + case LF_exp2l: + case LF_sinh: + case LF_sinhf: + case LF_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 LF_expm1: // RangeError: (709, inf) + case LF_expm1f: // RangeError: (88, inf) + case LF_expm1l: // RangeError: (11356, inf) { Cond = generateOneRangeCond(CI, Func); break; @@ -231,15 +231,15 @@ // 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 LF_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 LF_atanhf: // Same as atanh + case LF_atanhl: // Same as atanh { if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) return false; @@ -247,20 +247,20 @@ Cond = createOrCond(CI, CmpInst::FCMP_OLE, -1.0f, CmpInst::FCMP_OGE, 1.0f); break; } - case LibFunc::log: // DomainError: (x < 0) + case LF_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 LF_logf: // Same as log + case LF_logl: // Same as log + case LF_log10: // Same as log + case LF_log10f: // Same as log + case LF_log10l: // Same as log + case LF_log2: // Same as log + case LF_log2f: // Same as log + case LF_log2l: // Same as log + case LF_logb: // Same as log + case LF_logbf: // Same as log + case LF_logbl: // Same as log { if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) return false; @@ -268,11 +268,11 @@ Cond = createCond(CI, CmpInst::FCMP_OLE, 0.0f); break; } - case LibFunc::log1p: // DomainError: (x < -1) + case LF_log1p: // DomainError: (x < -1) // PoleError: (x == -1) // Overall Cond: (x <= -1) - case LibFunc::log1pf: // Same as log1p - case LibFunc::log1pl: // Same as log1p + case LF_log1pf: // Same as log1p + case LF_log1pl: // Same as log1p { if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) return false; @@ -280,11 +280,11 @@ Cond = createCond(CI, CmpInst::FCMP_OLE, -1.0f); break; } - case LibFunc::pow: // DomainError: x < 0 and y is noninteger + case LF_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 LF_powf: + case LF_powl: { if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError || !LibCallsShrinkWrapDoRangeError) return false; @@ -313,7 +313,7 @@ if (!CI.use_empty()) return; - LibFunc::Func Func; + LibFunc Func; Function *Callee = CI.getCalledFunction(); if (!Callee) return; @@ -333,16 +333,16 @@ // 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 LF_expm1: // RangeError: (709, inf) UpperBound = 709.0f; break; - case LibFunc::expm1f: // RangeError: (88, inf) + case LF_expm1f: // RangeError: (88, inf) UpperBound = 88.0f; break; - case LibFunc::expm1l: // RangeError: (11356, inf) + case LF_expm1l: // RangeError: (11356, inf) UpperBound = 11356.0f; break; default: @@ -355,57 +355,57 @@ // 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 LF_cosh: // RangeError: (x < -710 || x > 710) + case LF_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 LF_coshf: // RangeError: (x < -89 || x > 89) + case LF_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 LF_coshl: // RangeError: (x < -11357 || x > 11357) + case LF_sinhl: // Same as coshl LowerBound = -11357.0f; UpperBound = 11357.0f; break; - case LibFunc::exp: // RangeError: (x < -745 || x > 709) + case LF_exp: // RangeError: (x < -745 || x > 709) LowerBound = -745.0f; UpperBound = 709.0f; break; - case LibFunc::expf: // RangeError: (x < -103 || x > 88) + case LF_expf: // RangeError: (x < -103 || x > 88) LowerBound = -103.0f; UpperBound = 88.0f; break; - case LibFunc::expl: // RangeError: (x < -11399 || x > 11356) + case LF_expl: // RangeError: (x < -11399 || x > 11356) LowerBound = -11399.0f; UpperBound = 11356.0f; break; - case LibFunc::exp10: // RangeError: (x < -323 || x > 308) + case LF_exp10: // RangeError: (x < -323 || x > 308) LowerBound = -323.0f; UpperBound = 308.0f; break; - case LibFunc::exp10f: // RangeError: (x < -45 || x > 38) + case LF_exp10f: // RangeError: (x < -45 || x > 38) LowerBound = -45.0f; UpperBound = 38.0f; break; - case LibFunc::exp10l: // RangeError: (x < -4950 || x > 4932) + case LF_exp10l: // RangeError: (x < -4950 || x > 4932) LowerBound = -4950.0f; UpperBound = 4932.0f; break; - case LibFunc::exp2: // RangeError: (x < -1074 || x > 1023) + case LF_exp2: // RangeError: (x < -1074 || x > 1023) LowerBound = -1074.0f; UpperBound = 1023.0f; break; - case LibFunc::exp2f: // RangeError: (x < -149 || x > 127) + case LF_exp2f: // RangeError: (x < -149 || x > 127) LowerBound = -149.0f; UpperBound = 127.0f; break; - case LibFunc::exp2l: // RangeError: (x < -16445 || x > 11383) + case LF_exp2l: // RangeError: (x < -16445 || x > 11383) LowerBound = -16445.0f; UpperBound = 11383.0f; break; @@ -434,9 +434,9 @@ // (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: LF_powf and powl TBD. + if (Func != LF_pow) { DEBUG(dbgs() << "Not handled powf() and powl()\n"); return nullptr; } @@ -516,7 +516,7 @@ // 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); Index: lib/Transforms/Utils/Local.cpp =================================================================== --- lib/Transforms/Utils/Local.cpp +++ lib/Transforms/Utils/Local.cpp @@ -2068,7 +2068,7 @@ 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()) Index: lib/Transforms/Utils/SimplifyLibCalls.cpp =================================================================== --- lib/Transforms/Utils/SimplifyLibCalls.cpp +++ lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -51,9 +51,9 @@ // 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 == LF_abs || Func == LF_labs || + Func == LF_llabs || Func == LF_strlen; } static bool isCallingConvCCompatible(CallInst *CI) { @@ -123,8 +123,8 @@ /// \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 @@ // 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 @@ // 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 != LF_malloc) return nullptr; // The memset must cover the same number of bytes that are malloc'd. @@ -1041,9 +1041,8 @@ if (ConstantFP *Op1C = dyn_cast(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(), LF_exp10, LF_exp10f, LF_exp10l)) + return emitUnaryFloatFnCall(Op2, TLI->getName(LF_exp10), B, Callee->getAttributes()); } @@ -1055,10 +1054,10 @@ // pow(exp(x), y) = pow(inf, 0.001) = inf, whereas exp(x*y) = exp(1). auto *OpC = dyn_cast(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 == LF_exp || Func == LF_exp2)) { IRBuilder<>::FastMathFlagGuard Guard(B); B.setFastMathFlags(CI->getFastMathFlags()); Value *FMul = B.CreateFMul(OpC->getArgOperand(0), Op2, "mul"); @@ -1075,10 +1074,8 @@ 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::fabs, LibFunc::fabsf, - LibFunc::fabsl)) { + hasUnaryFloatFn(TLI, Op2->getType(), LF_sqrt, LF_sqrtf, LF_sqrtl) && + hasUnaryFloatFn(TLI, Op2->getType(), LF_fabs, LF_fabsf, LF_fabsl)) { // In -ffast-math, pow(x, 0.5) -> sqrt(x). if (CI->hasUnsafeAlgebra()) { @@ -1087,7 +1084,7 @@ // 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(LF_sqrt), B, Callee->getAttributes()); } @@ -1152,11 +1149,11 @@ 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 = LF_ldexpl; if (Op->getType()->isFloatTy()) - LdExp = LibFunc::ldexpf; + LdExp = LF_ldexpf; else if (Op->getType()->isDoubleTy()) - LdExp = LibFunc::ldexp; + LdExp = LF_ldexp; if (TLI->has(LdExp)) { Value *LdExpArg = nullptr; @@ -1259,17 +1256,17 @@ 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 == LF_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 == LF_exp2) return B.CreateFMul( OpC->getArgOperand(0), emitUnaryFloatFnCall(ConstantFP::get(CI->getType(), 2.0), @@ -1281,8 +1278,8 @@ 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(LF_sqrtf) && (Callee->getName() == "sqrt" || + Callee->getIntrinsicID() == Intrinsic::sqrt)) Ret = optimizeUnaryDoubleFP(CI, B, true); if (!CI->hasUnsafeAlgebra()) @@ -1364,12 +1361,12 @@ // 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 == LF_atan && Callee->getName() == "tan") || + (Func == LF_atanf && Callee->getName() == "tanf") || + (Func == LF_atanl && Callee->getName() == "tanl"))) Ret = OpC->getArgOperand(0); return Ret; } @@ -1487,24 +1484,24 @@ 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 == LF_sinpif) SinCalls.push_back(CI); - else if (Func == LibFunc::cospif) + else if (Func == LF_cospif) CosCalls.push_back(CI); - else if (Func == LibFunc::sincospif_stret) + else if (Func == LF_sincospif_stret) SinCosCalls.push_back(CI); } else { - if (Func == LibFunc::sinpi) + if (Func == LF_sinpi) SinCalls.push_back(CI); - else if (Func == LibFunc::cospi) + else if (Func == LF_cospi) CosCalls.push_back(CI); - else if (Func == LibFunc::sincospi_stret) + else if (Func == LF_sincospi_stret) SinCosCalls.push_back(CI); } } @@ -1678,7 +1675,7 @@ // printf(format, ...) -> iprintf(format, ...) if no floating point // arguments. - if (TLI->has(LibFunc::iprintf) && !callHasFloatingPointArgument(CI)) { + if (TLI->has(LF_iprintf) && !callHasFloatingPointArgument(CI)) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Constant *IPrintFFn = M->getOrInsertFunction("iprintf", FT, Callee->getAttributes()); @@ -1759,7 +1756,7 @@ // sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating // point arguments. - if (TLI->has(LibFunc::siprintf) && !callHasFloatingPointArgument(CI)) { + if (TLI->has(LF_siprintf) && !callHasFloatingPointArgument(CI)) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Constant *SIPrintFFn = M->getOrInsertFunction("siprintf", FT, Callee->getAttributes()); @@ -1829,7 +1826,7 @@ // fprintf(stream, format, ...) -> fiprintf(stream, format, ...) if no // floating point arguments. - if (TLI->has(LibFunc::fiprintf) && !callHasFloatingPointArgument(CI)) { + if (TLI->has(LF_fiprintf) && !callHasFloatingPointArgument(CI)) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Constant *FIPrintFFn = M->getOrInsertFunction("fiprintf", FT, Callee->getAttributes()); @@ -1908,7 +1905,7 @@ } bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { - LibFunc::Func Func; + LibFunc Func; SmallString<20> FloatFuncName = FuncName; FloatFuncName += 'f'; if (TLI->getLibFunc(FloatFuncName, Func)) @@ -1918,7 +1915,7 @@ 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)) { @@ -1927,51 +1924,51 @@ isCallingConvCCompatible(CI)) && "Optimizing string/memory libcall would change the calling convention"); switch (Func) { - case LibFunc::strcat: + case LF_strcat: return optimizeStrCat(CI, Builder); - case LibFunc::strncat: + case LF_strncat: return optimizeStrNCat(CI, Builder); - case LibFunc::strchr: + case LF_strchr: return optimizeStrChr(CI, Builder); - case LibFunc::strrchr: + case LF_strrchr: return optimizeStrRChr(CI, Builder); - case LibFunc::strcmp: + case LF_strcmp: return optimizeStrCmp(CI, Builder); - case LibFunc::strncmp: + case LF_strncmp: return optimizeStrNCmp(CI, Builder); - case LibFunc::strcpy: + case LF_strcpy: return optimizeStrCpy(CI, Builder); - case LibFunc::stpcpy: + case LF_stpcpy: return optimizeStpCpy(CI, Builder); - case LibFunc::strncpy: + case LF_strncpy: return optimizeStrNCpy(CI, Builder); - case LibFunc::strlen: + case LF_strlen: return optimizeStrLen(CI, Builder); - case LibFunc::strpbrk: + case LF_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 LF_strtol: + case LF_strtod: + case LF_strtof: + case LF_strtoul: + case LF_strtoll: + case LF_strtold: + case LF_strtoull: return optimizeStrTo(CI, Builder); - case LibFunc::strspn: + case LF_strspn: return optimizeStrSpn(CI, Builder); - case LibFunc::strcspn: + case LF_strcspn: return optimizeStrCSpn(CI, Builder); - case LibFunc::strstr: + case LF_strstr: return optimizeStrStr(CI, Builder); - case LibFunc::memchr: + case LF_memchr: return optimizeMemChr(CI, Builder); - case LibFunc::memcmp: + case LF_memcmp: return optimizeMemCmp(CI, Builder); - case LibFunc::memcpy: + case LF_memcpy: return optimizeMemCpy(CI, Builder); - case LibFunc::memmove: + case LF_memmove: return optimizeMemMove(CI, Builder); - case LibFunc::memset: + case LF_memset: return optimizeMemSet(CI, Builder); default: break; @@ -1984,7 +1981,7 @@ if (CI->isNoBuiltin()) return nullptr; - LibFunc::Func Func; + LibFunc Func; Function *Callee = CI->getCalledFunction(); StringRef FuncName = Callee->getName(); @@ -2046,114 +2043,114 @@ if (Value *V = optimizeStringMemoryLibCall(CI, Builder)) return V; switch (Func) { - case LibFunc::cosf: - case LibFunc::cos: - case LibFunc::cosl: + case LF_cosf: + case LF_cos: + case LF_cosl: return optimizeCos(CI, Builder); - case LibFunc::sinpif: - case LibFunc::sinpi: - case LibFunc::cospif: - case LibFunc::cospi: + case LF_sinpif: + case LF_sinpi: + case LF_cospif: + case LF_cospi: return optimizeSinCosPi(CI, Builder); - case LibFunc::powf: - case LibFunc::pow: - case LibFunc::powl: + case LF_powf: + case LF_pow: + case LF_powl: return optimizePow(CI, Builder); - case LibFunc::exp2l: - case LibFunc::exp2: - case LibFunc::exp2f: + case LF_exp2l: + case LF_exp2: + case LF_exp2f: return optimizeExp2(CI, Builder); - case LibFunc::fabsf: - case LibFunc::fabs: - case LibFunc::fabsl: + case LF_fabsf: + case LF_fabs: + case LF_fabsl: return optimizeFabs(CI, Builder); - case LibFunc::sqrtf: - case LibFunc::sqrt: - case LibFunc::sqrtl: + case LF_sqrtf: + case LF_sqrt: + case LF_sqrtl: return optimizeSqrt(CI, Builder); - case LibFunc::ffs: - case LibFunc::ffsl: - case LibFunc::ffsll: + case LF_ffs: + case LF_ffsl: + case LF_ffsll: return optimizeFFS(CI, Builder); - case LibFunc::fls: - case LibFunc::flsl: - case LibFunc::flsll: + case LF_fls: + case LF_flsl: + case LF_flsll: return optimizeFls(CI, Builder); - case LibFunc::abs: - case LibFunc::labs: - case LibFunc::llabs: + case LF_abs: + case LF_labs: + case LF_llabs: return optimizeAbs(CI, Builder); - case LibFunc::isdigit: + case LF_isdigit: return optimizeIsDigit(CI, Builder); - case LibFunc::isascii: + case LF_isascii: return optimizeIsAscii(CI, Builder); - case LibFunc::toascii: + case LF_toascii: return optimizeToAscii(CI, Builder); - case LibFunc::printf: + case LF_printf: return optimizePrintF(CI, Builder); - case LibFunc::sprintf: + case LF_sprintf: return optimizeSPrintF(CI, Builder); - case LibFunc::fprintf: + case LF_fprintf: return optimizeFPrintF(CI, Builder); - case LibFunc::fwrite: + case LF_fwrite: return optimizeFWrite(CI, Builder); - case LibFunc::fputs: + case LF_fputs: return optimizeFPuts(CI, Builder); - case LibFunc::log: - case LibFunc::log10: - case LibFunc::log1p: - case LibFunc::log2: - case LibFunc::logb: + case LF_log: + case LF_log10: + case LF_log1p: + case LF_log2: + case LF_logb: return optimizeLog(CI, Builder); - case LibFunc::puts: + case LF_puts: return optimizePuts(CI, Builder); - case LibFunc::tan: - case LibFunc::tanf: - case LibFunc::tanl: + case LF_tan: + case LF_tanf: + case LF_tanl: return optimizeTan(CI, Builder); - case LibFunc::perror: + case LF_perror: return optimizeErrorReporting(CI, Builder); - case LibFunc::vfprintf: - case LibFunc::fiprintf: + case LF_vfprintf: + case LF_fiprintf: return optimizeErrorReporting(CI, Builder, 0); - case LibFunc::fputc: + case LF_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 LF_ceil: + case LF_floor: + case LF_rint: + case LF_round: + case LF_nearbyint: + case LF_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 LF_acos: + case LF_acosh: + case LF_asin: + case LF_asinh: + case LF_atan: + case LF_atanh: + case LF_cbrt: + case LF_cosh: + case LF_exp: + case LF_exp10: + case LF_expm1: + case LF_sin: + case LF_sinh: + case LF_tanh: if (UnsafeFPShrink && hasFloatVersion(FuncName)) return optimizeUnaryDoubleFP(CI, Builder, true); return nullptr; - case LibFunc::copysign: + case LF_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 LF_fminf: + case LF_fmin: + case LF_fminl: + case LF_fmaxf: + case LF_fmax: + case LF_fmaxl: return optimizeFMinFMax(CI, Builder); default: return nullptr; @@ -2279,7 +2276,7 @@ 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(); @@ -2287,7 +2284,7 @@ *ObjSize = CI->getArgOperand(2); // __stpcpy_chk(x,x,...) -> x+strlen(x) - if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { + if (Func == LF_stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { Value *StrLen = emitStrLen(Src, B, DL, TLI); return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr; } @@ -2313,14 +2310,14 @@ 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 == LF_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)) { @@ -2345,7 +2342,7 @@ // // PR23093. - LibFunc::Func Func; + LibFunc Func; Function *Callee = CI->getCalledFunction(); SmallVector OpBundles; @@ -2363,17 +2360,17 @@ return nullptr; switch (Func) { - case LibFunc::memcpy_chk: + case LF_memcpy_chk: return optimizeMemCpyChk(CI, Builder); - case LibFunc::memmove_chk: + case LF_memmove_chk: return optimizeMemMoveChk(CI, Builder); - case LibFunc::memset_chk: + case LF_memset_chk: return optimizeMemSetChk(CI, Builder); - case LibFunc::stpcpy_chk: - case LibFunc::strcpy_chk: + case LF_stpcpy_chk: + case LF_strcpy_chk: return optimizeStrpCpyChk(CI, Builder, Func); - case LibFunc::stpncpy_chk: - case LibFunc::strncpy_chk: + case LF_stpncpy_chk: + case LF_strncpy_chk: return optimizeStrpNCpyChk(CI, Builder, Func); default: break;