From f808bfddccd048e10362ba3f9109e868fc72f376 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 7 Mar 2018 00:03:27 +0000 Subject: [PATCH 1/5] Fix jldownload for busybox built-in wget --- deps/tools/jldownload | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/tools/jldownload b/deps/tools/jldownload index ab4fd696ae4c2..99822195fe303 100755 --- a/deps/tools/jldownload +++ b/deps/tools/jldownload @@ -30,7 +30,7 @@ CACHE_URL="$CACHE_HOST/$URL" if [ -x "$CURL" ] && $CURL -V >/dev/null; then GETURL="$CURL $CURL_OPTS" -elif [ -x "$WGET" ] && $WGET -V >/dev/null; then +elif [ -x "$WGET" ] && $WGET --help >/dev/null 2>&1; then GETURL="$WGET $WGET_OPTS" elif [ -x "$FETCH" ]; then GETURL="$FETCH $FETCH_OPTS" From 4bcbd45232d5d7e611e6785608623d6096df5ecd Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 7 Mar 2018 00:33:14 +0000 Subject: [PATCH 2/5] Add llvm patch to fix DynamicLibrary.cpp on musl libc --- deps/llvm.mk | 3 ++ ...llvm-D39297-musl-dynamiclibrary-pre5.patch | 40 +++++++++++++++++++ .../llvm-D39297-musl-dynamiclibrary.patch | 40 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 deps/patches/llvm-D39297-musl-dynamiclibrary-pre5.patch create mode 100644 deps/patches/llvm-D39297-musl-dynamiclibrary.patch diff --git a/deps/llvm.mk b/deps/llvm.mk index dc342210ab139..a3b575c6a3348 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -467,6 +467,7 @@ $(eval $(call LLVM_PATCH,llvm-3.9-c_api_nullptr)) $(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC $(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0 $(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0 +$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0 ifeq ($(BUILD_LLVM_CLANG),1) $(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0 endif @@ -498,6 +499,7 @@ $(eval $(call LLVM_PATCH,llvm-D42262-jumpthreading-not-i1)) $(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC $(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0 $(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0 +$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0 ifeq ($(BUILD_LLVM_CLANG),1) $(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0 endif @@ -514,6 +516,7 @@ $(eval $(call LLVM_PATCH,llvm-D38765-gvn_5.0)) # Remove for 6.0 $(eval $(call LLVM_PATCH,llvm-D42262-jumpthreading-not-i1)) $(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC $(eval $(call LLVM_PATCH,llvm-PR36292-5.0)) # PPC fixes #26249, remove for 6.0 +$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary)) # Remove for 6.0 endif # LLVM_VER # Remove hardcoded OS X requirements in compilter-rt cmake build diff --git a/deps/patches/llvm-D39297-musl-dynamiclibrary-pre5.patch b/deps/patches/llvm-D39297-musl-dynamiclibrary-pre5.patch new file mode 100644 index 0000000000000..2ed33c9969f9f --- /dev/null +++ b/deps/patches/llvm-D39297-musl-dynamiclibrary-pre5.patch @@ -0,0 +1,40 @@ +From ae8900a8833835309aecb0a3d947c2ae46fd86c3 Mon Sep 17 00:00:00 2001 +From: Keno Fischer +Date: Thu, 26 Oct 2017 16:44:13 +0000 +Subject: [PATCH] [DynamicLibrary] Fix build on musl libc + +Summary: +On musl libc, stdin/out/err are defined as `FILE* const` globals, +and their address is not implicitly convertible to void *, +or at least gcc 6 doesn't allow it, giving errors like: + +``` +error: cannot initialize return object of type 'void *' with an rvalue of type 'FILE *const *' (aka '_IO_FILE *const *') + EXPLICIT_SYMBOL(stderr); + ^~~~~~~~~~~~~~~~~~~~~~~ +``` + +Add an explicit cast to fix that problem. + +Reviewers: marsupial, krytarowski, dim +Reviewed By: dim +Differential Revision: https://reviews.llvm.org/D39297 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316672 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Support/Unix/DynamicLibrary.inc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc +index f05103ccd1eb..029451f347e8 100644 +--- a/lib/Support/DynamicLibrary.cpp ++++ b/lib/Support/DynamicLibrary.cpp +@@ -71,7 +71,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) { + + // This macro returns the address of a well-known, explicit symbol + #define EXPLICIT_SYMBOL(SYM) \ +- if (!strcmp(symbolName, #SYM)) return &SYM ++ if (!strcmp(symbolName, #SYM)) return (void*)&SYM + + // On linux we have a weird situation. The stderr/out/in symbols are both + // macros and global variables because of standards requirements. So, we diff --git a/deps/patches/llvm-D39297-musl-dynamiclibrary.patch b/deps/patches/llvm-D39297-musl-dynamiclibrary.patch new file mode 100644 index 0000000000000..f1956d841b39c --- /dev/null +++ b/deps/patches/llvm-D39297-musl-dynamiclibrary.patch @@ -0,0 +1,40 @@ +From ae8900a8833835309aecb0a3d947c2ae46fd86c3 Mon Sep 17 00:00:00 2001 +From: Keno Fischer +Date: Thu, 26 Oct 2017 16:44:13 +0000 +Subject: [PATCH] [DynamicLibrary] Fix build on musl libc + +Summary: +On musl libc, stdin/out/err are defined as `FILE* const` globals, +and their address is not implicitly convertible to void *, +or at least gcc 6 doesn't allow it, giving errors like: + +``` +error: cannot initialize return object of type 'void *' with an rvalue of type 'FILE *const *' (aka '_IO_FILE *const *') + EXPLICIT_SYMBOL(stderr); + ^~~~~~~~~~~~~~~~~~~~~~~ +``` + +Add an explicit cast to fix that problem. + +Reviewers: marsupial, krytarowski, dim +Reviewed By: dim +Differential Revision: https://reviews.llvm.org/D39297 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316672 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Support/Unix/DynamicLibrary.inc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc +index f05103ccd1eb..029451f347e8 100644 +--- a/lib/Support/Unix/DynamicLibrary.inc ++++ b/lib/Support/Unix/DynamicLibrary.inc +@@ -71,7 +71,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) { + // Must declare the symbols in the global namespace. + static void *DoSearch(const char* SymbolName) { + #define EXPLICIT_SYMBOL(SYM) \ +- extern void *SYM; if (!strcmp(SymbolName, #SYM)) return &SYM ++ extern void *SYM; if (!strcmp(SymbolName, #SYM)) return (void*)&SYM + + // If this is darwin, it has some funky issues, try to solve them here. Some + // important symbols are marked 'private external' which doesn't allow From 8b6c6f2ad5fa4be39925bed70f7abb110c197b8a Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 7 Mar 2018 01:31:56 +0000 Subject: [PATCH 3/5] LLVM patch for building TargetLibraryInfo on musl libc --- deps/llvm.mk | 2 + ...vm-D28476-musl-targetlibraryinfo_3.9.patch | 3955 +++++++++++++++ ...vm-D28476-musl-targetlibraryinfo_4.0.patch | 4480 +++++++++++++++++ 3 files changed, 8437 insertions(+) create mode 100644 deps/patches/llvm-D28476-musl-targetlibraryinfo_3.9.patch create mode 100644 deps/patches/llvm-D28476-musl-targetlibraryinfo_4.0.patch diff --git a/deps/llvm.mk b/deps/llvm.mk index a3b575c6a3348..863dea8abb8f9 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -468,6 +468,7 @@ $(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC $(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0 $(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0 $(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0 +$(eval $(call LLVM_PATCH,llvm-D28476-musl-targetlibraryinfo_3.9)) # Remove for 5.0 ifeq ($(BUILD_LLVM_CLANG),1) $(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0 endif @@ -500,6 +501,7 @@ $(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC $(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0 $(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0 $(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0 +$(eval $(call LLVM_PATCH,llvm-D28476-musl-targetlibraryinfo_4.0)) # Remove for 5.0 ifeq ($(BUILD_LLVM_CLANG),1) $(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0 endif diff --git a/deps/patches/llvm-D28476-musl-targetlibraryinfo_3.9.patch b/deps/patches/llvm-D28476-musl-targetlibraryinfo_3.9.patch new file mode 100644 index 0000000000000..764512f5066a6 --- /dev/null +++ b/deps/patches/llvm-D28476-musl-targetlibraryinfo_3.9.patch @@ -0,0 +1,3955 @@ +commit 30f85ead353e6606db51b73908dd9862b005385b +Author: David L. Jones +Date: Mon Jan 23 23:16:46 2017 +0000 + + [Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC) + + Summary: + The LibFunc::Func enum holds enumerators named for libc functions. + Unfortunately, there are real situations, including libc implementations, where + function names are actually macros (musl uses "#define fopen64 fopen", for + example; any other transitively visible macro would have similar effects). + + Strictly speaking, a conforming C++ Standard Library should provide any such + macros as functions instead (via ). However, there are some "library" + functions which are not part of the standard, and thus not subject to this + rule (fopen64, for example). So, in order to be both portable and consistent, + the enum should not use the bare function names. + + The old enum naming used a namespace LibFunc and an enum Func, with bare + enumerators. This patch changes LibFunc to be an enum with enumerators prefixed + with "LibFFunc_". (Unfortunately, a scoped enum is not sufficient to override + macros.) + + There are additional changes required in clang. + + Reviewers: rsmith + + Subscribers: mehdi_amini, mzolotukhin, nemanjai, llvm-commits + + Differential Revision: https://reviews.llvm.org/D28476 + + git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292848 91177308-0d34-0410-b5e6-96231b3b80d8 + +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def +index b2a593d67dc..775e2f31733 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.def ++++ b/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) LibFunc_##enum_variant, + #define TLI_DEFINE_STRING_INTERNAL(string_repr) + #else + #define TLI_DEFINE_ENUM_INTERNAL(enum_variant) +diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h +index 7efa6f05970..48156de1c3b 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.h ++++ b/include/llvm/Analysis/TargetLibraryInfo.h +@@ -30,14 +30,12 @@ struct VecDesc { + unsigned VectorizationFactor; + }; + +- namespace LibFunc { +- enum Func { ++ enum LibFunc { + #define TLI_DEFINE_ENUM + #include "llvm/Analysis/TargetLibraryInfo.def" + +- NumLibFuncs +- }; +- } ++ NumLibFuncs ++ }; + + /// Implementation of the target library information. + /// +@@ -48,20 +46,20 @@ struct VecDesc { + class TargetLibraryInfoImpl { + friend class TargetLibraryInfo; + +- unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4]; ++ unsigned char AvailableArray[(NumLibFuncs+3)/4]; + llvm::DenseMap CustomNames; +- static const char *const StandardNames[LibFunc::NumLibFuncs]; ++ static const char *const StandardNames[NumLibFuncs]; + + enum AvailabilityState { + StandardName = 3, // (memset to all ones) + 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); + } + +@@ -73,7 +71,7 @@ class TargetLibraryInfoImpl { + + /// Return true if the function type FTy is valid for the library function + /// F, regardless of whether the function is available. +- bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc::Func F, ++ bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F, + const DataLayout *DL) const; + + public: +@@ -102,28 +100,28 @@ public: + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(StringRef funcName, LibFunc::Func &F) const; ++ bool getLibFunc(StringRef funcName, LibFunc &F) const; + + /// Searches for a particular function name, also checking that its type is + /// valid for the library function matching that name. + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const; ++ bool getLibFunc(const Function &FDecl, LibFunc &F) const; + + /// Forces a function to be marked as unavailable. +- void setUnavailable(LibFunc::Func F) { ++ void setUnavailable(LibFunc F) { + setState(F, Unavailable); + } + + /// Forces a function to be marked as available. +- void setAvailable(LibFunc::Func F) { ++ void setAvailable(LibFunc F) { + setState(F, StandardName); + } + + /// Forces a function to be marked as available and provide an alternate name + /// that must be used. +- void setAvailableWithName(LibFunc::Func F, StringRef Name) { ++ void setAvailableWithName(LibFunc F, StringRef Name) { + if (StandardNames[F] != Name) { + setState(F, CustomName); + CustomNames[F] = Name; +@@ -203,16 +201,16 @@ public: + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(StringRef funcName, LibFunc::Func &F) const { ++ bool getLibFunc(StringRef funcName, LibFunc &F) const { + return Impl->getLibFunc(funcName, F); + } + +- bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const { ++ bool getLibFunc(const Function &FDecl, LibFunc &F) const { + return Impl->getLibFunc(FDecl, F); + } + + /// Tests whether a library function is available. +- bool has(LibFunc::Func F) const { ++ bool has(LibFunc F) const { + return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable; + } + bool isFunctionVectorizable(StringRef F, unsigned VF) const { +@@ -227,37 +225,37 @@ public: + + /// Tests if the function is both available and a candidate for optimized code + /// generation. +- bool hasOptimizedCodeGen(LibFunc::Func F) const { ++ bool hasOptimizedCodeGen(LibFunc F) const { + if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable) + return false; + switch (F) { + default: break; +- case LibFunc::copysign: case LibFunc::copysignf: case LibFunc::copysignl: +- case LibFunc::fabs: case LibFunc::fabsf: case LibFunc::fabsl: +- case LibFunc::sin: case LibFunc::sinf: case LibFunc::sinl: +- case LibFunc::cos: case LibFunc::cosf: case LibFunc::cosl: +- case LibFunc::sqrt: case LibFunc::sqrtf: case LibFunc::sqrtl: +- case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite: +- case LibFunc::sqrtl_finite: +- case LibFunc::fmax: case LibFunc::fmaxf: case LibFunc::fmaxl: +- case LibFunc::fmin: case LibFunc::fminf: case LibFunc::fminl: +- case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl: +- case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl: +- case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill: +- case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl: +- case LibFunc::round: case LibFunc::roundf: case LibFunc::roundl: +- case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: +- case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: +- case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: +- case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: +- case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen: +- case LibFunc::memchr: ++ case LibFunc_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: + 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(); +diff --git a/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/include/llvm/Transforms/Utils/SimplifyLibCalls.h +index 92ee2463395..a294ebae4b6 100644 +--- a/include/llvm/Transforms/Utils/SimplifyLibCalls.h ++++ b/include/llvm/Transforms/Utils/SimplifyLibCalls.h +@@ -56,8 +56,8 @@ private: + Value *optimizeMemSetChk(CallInst *CI, IRBuilder<> &B); + + // Str/Stp cpy are similar enough to be handled in the same functions. +- Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func); +- Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func); ++ Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func); ++ Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func); + + /// \brief Checks whether the call \p CI to a fortified libcall is foldable + /// to the non-fortified version. +diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp +index 43d5c3ccf90..cce9aa5c2c0 100644 +--- a/lib/Analysis/BasicAliasAnalysis.cpp ++++ b/lib/Analysis/BasicAliasAnalysis.cpp +@@ -619,9 +619,9 @@ static bool isWriteOnlyParam(ImmutableCallSite CS, unsigned ArgIdx, + // whenever possible. + // FIXME Consider handling this in InferFunctionAttr.cpp together with other + // attributes. +- LibFunc::Func F; ++ LibFunc F; + if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) && +- F == LibFunc::memset_pattern16 && TLI.has(F)) ++ F == LibFunc_memset_pattern16 && TLI.has(F)) + if (ArgIdx == 0) + return true; + +diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp +index c9adaa7b111..9672dcfdf97 100644 +--- a/lib/Analysis/ConstantFolding.cpp ++++ b/lib/Analysis/ConstantFolding.cpp +@@ -1554,51 +1554,51 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + + switch (Name[0]) { + case 'a': +- if ((Name == "acos" && TLI->has(LibFunc::acos)) || +- (Name == "acosf" && TLI->has(LibFunc::acosf))) ++ if ((Name == "acos" && TLI->has(LibFunc_acos)) || ++ (Name == "acosf" && TLI->has(LibFunc_acosf))) + return ConstantFoldFP(acos, V, Ty); +- else if ((Name == "asin" && TLI->has(LibFunc::asin)) || +- (Name == "asinf" && TLI->has(LibFunc::asinf))) ++ else if ((Name == "asin" && TLI->has(LibFunc_asin)) || ++ (Name == "asinf" && TLI->has(LibFunc_asinf))) + return ConstantFoldFP(asin, V, Ty); +- else if ((Name == "atan" && TLI->has(LibFunc::atan)) || +- (Name == "atanf" && TLI->has(LibFunc::atanf))) ++ else if ((Name == "atan" && TLI->has(LibFunc_atan)) || ++ (Name == "atanf" && TLI->has(LibFunc_atanf))) + return ConstantFoldFP(atan, V, Ty); + break; + case 'c': +- if ((Name == "ceil" && TLI->has(LibFunc::ceil)) || +- (Name == "ceilf" && TLI->has(LibFunc::ceilf))) ++ if ((Name == "ceil" && TLI->has(LibFunc_ceil)) || ++ (Name == "ceilf" && TLI->has(LibFunc_ceilf))) + return ConstantFoldFP(ceil, V, Ty); +- else if ((Name == "cos" && TLI->has(LibFunc::cos)) || +- (Name == "cosf" && TLI->has(LibFunc::cosf))) ++ else if ((Name == "cos" && TLI->has(LibFunc_cos)) || ++ (Name == "cosf" && TLI->has(LibFunc_cosf))) + return ConstantFoldFP(cos, V, Ty); +- else if ((Name == "cosh" && TLI->has(LibFunc::cosh)) || +- (Name == "coshf" && TLI->has(LibFunc::coshf))) ++ else if ((Name == "cosh" && TLI->has(LibFunc_cosh)) || ++ (Name == "coshf" && TLI->has(LibFunc_coshf))) + return ConstantFoldFP(cosh, V, Ty); + break; + case 'e': +- if ((Name == "exp" && TLI->has(LibFunc::exp)) || +- (Name == "expf" && TLI->has(LibFunc::expf))) ++ if ((Name == "exp" && TLI->has(LibFunc_exp)) || ++ (Name == "expf" && TLI->has(LibFunc_expf))) + return ConstantFoldFP(exp, V, Ty); +- if ((Name == "exp2" && TLI->has(LibFunc::exp2)) || +- (Name == "exp2f" && TLI->has(LibFunc::exp2f))) ++ if ((Name == "exp2" && TLI->has(LibFunc_exp2)) || ++ (Name == "exp2f" && TLI->has(LibFunc_exp2f))) + // Constant fold exp2(x) as pow(2,x) in case the host doesn't have a + // C99 library. + return ConstantFoldBinaryFP(pow, 2.0, V, Ty); + break; + case 'f': +- if ((Name == "fabs" && TLI->has(LibFunc::fabs)) || +- (Name == "fabsf" && TLI->has(LibFunc::fabsf))) ++ if ((Name == "fabs" && TLI->has(LibFunc_fabs)) || ++ (Name == "fabsf" && TLI->has(LibFunc_fabsf))) + return ConstantFoldFP(fabs, V, Ty); +- else if ((Name == "floor" && TLI->has(LibFunc::floor)) || +- (Name == "floorf" && TLI->has(LibFunc::floorf))) ++ else if ((Name == "floor" && TLI->has(LibFunc_floor)) || ++ (Name == "floorf" && TLI->has(LibFunc_floorf))) + return ConstantFoldFP(floor, V, Ty); + break; + case 'l': +- if ((Name == "log" && V > 0 && TLI->has(LibFunc::log)) || +- (Name == "logf" && V > 0 && TLI->has(LibFunc::logf))) ++ if ((Name == "log" && V > 0 && TLI->has(LibFunc_log)) || ++ (Name == "logf" && V > 0 && TLI->has(LibFunc_logf))) + return ConstantFoldFP(log, V, Ty); +- else if ((Name == "log10" && V > 0 && TLI->has(LibFunc::log10)) || +- (Name == "log10f" && V > 0 && TLI->has(LibFunc::log10f))) ++ else if ((Name == "log10" && V > 0 && TLI->has(LibFunc_log10)) || ++ (Name == "log10f" && V > 0 && TLI->has(LibFunc_log10f))) + return ConstantFoldFP(log10, V, Ty); + else if (IntrinsicID == Intrinsic::sqrt && + (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())) { +@@ -1615,22 +1615,22 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + } + break; + case 's': +- if ((Name == "sin" && TLI->has(LibFunc::sin)) || +- (Name == "sinf" && TLI->has(LibFunc::sinf))) ++ if ((Name == "sin" && TLI->has(LibFunc_sin)) || ++ (Name == "sinf" && TLI->has(LibFunc_sinf))) + return ConstantFoldFP(sin, V, Ty); +- else if ((Name == "sinh" && TLI->has(LibFunc::sinh)) || +- (Name == "sinhf" && TLI->has(LibFunc::sinhf))) ++ else if ((Name == "sinh" && TLI->has(LibFunc_sinh)) || ++ (Name == "sinhf" && TLI->has(LibFunc_sinhf))) + return ConstantFoldFP(sinh, V, Ty); +- else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc::sqrt)) || +- (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc::sqrtf))) ++ else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc_sqrt)) || ++ (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc_sqrtf))) + return ConstantFoldFP(sqrt, V, Ty); + break; + case 't': +- if ((Name == "tan" && TLI->has(LibFunc::tan)) || +- (Name == "tanf" && TLI->has(LibFunc::tanf))) ++ if ((Name == "tan" && TLI->has(LibFunc_tan)) || ++ (Name == "tanf" && TLI->has(LibFunc_tanf))) + return ConstantFoldFP(tan, V, Ty); +- else if ((Name == "tanh" && TLI->has(LibFunc::tanh)) || +- (Name == "tanhf" && TLI->has(LibFunc::tanhf))) ++ else if ((Name == "tanh" && TLI->has(LibFunc_tanh)) || ++ (Name == "tanhf" && TLI->has(LibFunc_tanhf))) + return ConstantFoldFP(tanh, V, Ty); + break; + default: +@@ -1735,14 +1735,14 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + + if (!TLI) + return nullptr; +- if ((Name == "pow" && TLI->has(LibFunc::pow)) || +- (Name == "powf" && TLI->has(LibFunc::powf))) ++ if ((Name == "pow" && TLI->has(LibFunc_pow)) || ++ (Name == "powf" && TLI->has(LibFunc_powf))) + return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); +- if ((Name == "fmod" && TLI->has(LibFunc::fmod)) || +- (Name == "fmodf" && TLI->has(LibFunc::fmodf))) ++ if ((Name == "fmod" && TLI->has(LibFunc_fmod)) || ++ (Name == "fmodf" && TLI->has(LibFunc_fmodf))) + return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty); +- if ((Name == "atan2" && TLI->has(LibFunc::atan2)) || +- (Name == "atan2f" && TLI->has(LibFunc::atan2f))) ++ if ((Name == "atan2" && TLI->has(LibFunc_atan2)) || ++ (Name == "atan2f" && TLI->has(LibFunc_atan2f))) + return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty); + } else if (auto *Op2C = dyn_cast(Operands[1])) { + if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy()) +diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp +index f23477622be..89e7a358d4b 100644 +--- a/lib/Analysis/MemoryBuiltins.cpp ++++ b/lib/Analysis/MemoryBuiltins.cpp +@@ -50,30 +50,30 @@ struct AllocFnsTy { + + // FIXME: certain users need more information. E.g., SimplifyLibCalls needs to + // know which functions are nounwind, noalias, nocapture parameters, etc. +-static const std::pair 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[] = { ++ {LibFunc_malloc, {MallocLike, 1, 0, -1}}, ++ {LibFunc_valloc, {MallocLike, 1, 0, -1}}, ++ {LibFunc_Znwj, {OpNewLike, 1, 0, -1}}, // new(unsigned int) ++ {LibFunc_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) ++ {LibFunc_Znwm, {OpNewLike, 1, 0, -1}}, // new(unsigned long) ++ {LibFunc_ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned long, nothrow) ++ {LibFunc_Znaj, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) ++ {LibFunc_ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) ++ {LibFunc_Znam, {OpNewLike, 1, 0, -1}}, // new[](unsigned long) ++ {LibFunc_ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned long, nothrow) ++ {LibFunc_msvc_new_int, {OpNewLike, 1, 0, -1}}, // new(unsigned int) ++ {LibFunc_msvc_new_int_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) ++ {LibFunc_msvc_new_longlong, {OpNewLike, 1, 0, -1}}, // new(unsigned long long) ++ {LibFunc_msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned long long, nothrow) ++ {LibFunc_msvc_new_array_int, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) ++ {LibFunc_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) ++ {LibFunc_msvc_new_array_longlong, {OpNewLike, 1, 0, -1}}, // new[](unsigned long long) ++ {LibFunc_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned long long, nothrow) ++ {LibFunc_calloc, {CallocLike, 2, 0, 1}}, ++ {LibFunc_realloc, {ReallocLike, 2, 1, -1}}, ++ {LibFunc_reallocf, {ReallocLike, 2, 1, -1}}, ++ {LibFunc_strdup, {StrDupLike, 1, -1, -1}}, ++ {LibFunc_strndup, {StrDupLike, 2, 1, -1}} + // TODO: Handle "int posix_memalign(void **, size_t, size_t)" + }; + +@@ -130,13 +130,13 @@ static Optional getAllocationData(const Value *V, AllocType AllocTy, + + // 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 = + std::find_if(std::begin(AllocationFnData), std::end(AllocationFnData), +- [TLIFn](const std::pair &P) { ++ [TLIFn](const std::pair &P) { + return P.first == TLIFn; + }); + +@@ -316,33 +316,33 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) { + return nullptr; + + StringRef FnName = Callee->getName(); +- LibFunc::Func TLIFn; ++ LibFunc TLIFn; + if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn)) + return nullptr; + + unsigned ExpectedNumParams; +- if (TLIFn == LibFunc::free || +- TLIFn == LibFunc::ZdlPv || // operator delete(void*) +- TLIFn == LibFunc::ZdaPv || // operator delete[](void*) +- TLIFn == LibFunc::msvc_delete_ptr32 || // operator delete(void*) +- TLIFn == LibFunc::msvc_delete_ptr64 || // operator delete(void*) +- TLIFn == LibFunc::msvc_delete_array_ptr32 || // operator delete[](void*) +- TLIFn == LibFunc::msvc_delete_array_ptr64) // operator delete[](void*) ++ if (TLIFn == LibFunc_free || ++ TLIFn == LibFunc_ZdlPv || // operator delete(void*) ++ TLIFn == LibFunc_ZdaPv || // operator delete[](void*) ++ TLIFn == LibFunc_msvc_delete_ptr32 || // operator delete(void*) ++ TLIFn == LibFunc_msvc_delete_ptr64 || // operator delete(void*) ++ TLIFn == LibFunc_msvc_delete_array_ptr32 || // operator delete[](void*) ++ TLIFn == LibFunc_msvc_delete_array_ptr64) // operator delete[](void*) + ExpectedNumParams = 1; +- else if (TLIFn == LibFunc::ZdlPvj || // delete(void*, uint) +- TLIFn == LibFunc::ZdlPvm || // delete(void*, ulong) +- TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) +- TLIFn == LibFunc::ZdaPvj || // delete[](void*, uint) +- TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong) +- TLIFn == LibFunc::ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow) +- TLIFn == LibFunc::msvc_delete_ptr32_int || // delete(void*, uint) +- TLIFn == LibFunc::msvc_delete_ptr64_longlong || // delete(void*, ulonglong) +- TLIFn == LibFunc::msvc_delete_ptr32_nothrow || // delete(void*, nothrow) +- TLIFn == LibFunc::msvc_delete_ptr64_nothrow || // delete(void*, nothrow) +- TLIFn == LibFunc::msvc_delete_array_ptr32_int || // delete[](void*, uint) +- TLIFn == LibFunc::msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong) +- TLIFn == LibFunc::msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow) +- TLIFn == LibFunc::msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow) ++ else if (TLIFn == LibFunc_ZdlPvj || // delete(void*, uint) ++ TLIFn == LibFunc_ZdlPvm || // delete(void*, ulong) ++ TLIFn == LibFunc_ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) ++ TLIFn == LibFunc_ZdaPvj || // delete[](void*, uint) ++ TLIFn == LibFunc_ZdaPvm || // delete[](void*, ulong) ++ TLIFn == LibFunc_ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_ptr32_int || // delete(void*, uint) ++ TLIFn == LibFunc_msvc_delete_ptr64_longlong || // delete(void*, ulonglong) ++ TLIFn == LibFunc_msvc_delete_ptr32_nothrow || // delete(void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_ptr64_nothrow || // delete(void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_array_ptr32_int || // delete[](void*, uint) ++ TLIFn == LibFunc_msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong) ++ TLIFn == LibFunc_msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow) + ExpectedNumParams = 2; + else + return nullptr; +diff --git a/lib/Analysis/MemoryLocation.cpp b/lib/Analysis/MemoryLocation.cpp +index a0ae72f1415..9db6c499129 100644 +--- a/lib/Analysis/MemoryLocation.cpp ++++ b/lib/Analysis/MemoryLocation.cpp +@@ -142,9 +142,9 @@ MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS, + // for memcpy/memset. This is particularly important because the + // LoopIdiomRecognizer likes to turn loops into calls to memset_pattern16 + // whenever possible. +- LibFunc::Func F; ++ LibFunc F; + if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) && +- F == LibFunc::memset_pattern16 && TLI.has(F)) { ++ F == LibFunc_memset_pattern16 && TLI.has(F)) { + assert((ArgIdx == 0 || ArgIdx == 1) && + "Invalid argument index for memset_pattern16"); + if (ArgIdx == 1) +diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp +index 93d537ad3ab..0895b8a6cfa 100644 +--- a/lib/Analysis/TargetLibraryInfo.cpp ++++ b/lib/Analysis/TargetLibraryInfo.cpp +@@ -62,24 +62,24 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + + 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(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); + } + + // 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(LibFunc_memcpy); ++ TLI.setUnavailable(LibFunc_memset); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + return; + } + +@@ -87,21 +87,21 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // All versions of watchOS support it. + if (T.isMacOSX()) { + if (T.isMacOSXVersionLT(10, 5)) +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + } else if (T.isiOS()) { + if (T.isOSVersionLT(3, 0)) +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + } else if (!T.isWatchOS()) { +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_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(LibFunc_sinpi); ++ TLI.setUnavailable(LibFunc_sinpif); ++ TLI.setUnavailable(LibFunc_cospi); ++ TLI.setUnavailable(LibFunc_cospif); ++ TLI.setUnavailable(LibFunc_sincospi_stret); ++ TLI.setUnavailable(LibFunc_sincospif_stret); + } + + if (T.isMacOSX() && T.getArch() == Triple::x86 && +@@ -111,179 +111,179 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_fwrite, "fwrite$UNIX2003"); ++ TLI.setAvailableWithName(LibFunc_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(LibFunc_iprintf); ++ TLI.setUnavailable(LibFunc_siprintf); ++ TLI.setUnavailable(LibFunc_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(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); + + // 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(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); + + // Win32 provides some C99 math with mangled names +- TLI.setAvailableWithName(LibFunc::copysign, "_copysign"); ++ TLI.setAvailableWithName(LibFunc_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(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); + } + + // 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(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); + + // 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(LibFunc_atoll); ++ TLI.setUnavailable(LibFunc_frexpf); ++ TLI.setUnavailable(LibFunc_llabs); + } + + switch (T.getOS()) { +@@ -291,28 +291,28 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_exp10l); + if (T.isMacOSXVersionLT(10, 9)) { +- TLI.setUnavailable(LibFunc::exp10); +- TLI.setUnavailable(LibFunc::exp10f); ++ TLI.setUnavailable(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); + } else { +- TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); +- TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); ++ TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); ++ TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); + } + break; + case Triple::IOS: + case Triple::TvOS: + case Triple::WatchOS: +- TLI.setUnavailable(LibFunc::exp10l); ++ TLI.setUnavailable(LibFunc_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(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); + } else { +- TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); +- TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); ++ TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); ++ TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); + } + break; + case Triple::Linux: +@@ -323,9 +323,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // + // Fall through to disable all of them. + default: +- TLI.setUnavailable(LibFunc::exp10); +- TLI.setUnavailable(LibFunc::exp10f); +- TLI.setUnavailable(LibFunc::exp10l); ++ TLI.setUnavailable(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); ++ TLI.setUnavailable(LibFunc_exp10l); + } + + // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and +@@ -343,7 +343,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + case Triple::Linux: + break; + default: +- TLI.setUnavailable(LibFunc::ffsl); ++ TLI.setUnavailable(LibFunc_ffsl); + } + + // ffsll is available on at least FreeBSD and Linux (GLIBC): +@@ -359,7 +359,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + case Triple::Linux: + break; + default: +- TLI.setUnavailable(LibFunc::ffsll); ++ TLI.setUnavailable(LibFunc_ffsll); + } + + // The following functions are available on at least FreeBSD: +@@ -367,30 +367,30 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_fls); ++ TLI.setUnavailable(LibFunc_flsl); ++ TLI.setUnavailable(LibFunc_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(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); + } + + // As currently implemented in clang, NVPTX code has no standard library to +@@ -406,9 +406,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // optimizations, so this situation should be fixed. + if (T.isNVPTX()) { + TLI.disableAllFunctions(); +- TLI.setAvailable(LibFunc::nvvm_reflect); ++ TLI.setAvailable(LibFunc_nvvm_reflect); + } else { +- TLI.setUnavailable(LibFunc::nvvm_reflect); ++ TLI.setUnavailable(LibFunc_nvvm_reflect); + } + + TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary); +@@ -468,9 +468,9 @@ static StringRef sanitizeFunctionName(StringRef funcName) { + } + + bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName, +- LibFunc::Func &F) const { ++ LibFunc &F) const { + const char *const *Start = &StandardNames[0]; +- const char *const *End = &StandardNames[LibFunc::NumLibFuncs]; ++ const char *const *End = &StandardNames[NumLibFuncs]; + + funcName = sanitizeFunctionName(funcName); + if (funcName.empty()) +@@ -481,14 +481,14 @@ bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName, + return std::strncmp(LHS, RHS.data(), RHS.size()) < 0; + }); + 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); +@@ -499,488 +499,488 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, + unsigned NumParams = FTy.getNumParams(); + + switch (F) { +- case LibFunc::strlen: ++ case LibFunc_strlen: + return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && + FTy.getReturnType()->isIntegerTy()); + +- case LibFunc::strchr: +- case LibFunc::strrchr: ++ case LibFunc_strchr: ++ case LibFunc_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 LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + return ((NumParams == 2 || NumParams == 3) && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::strcat: ++ case LibFunc_strcat: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0) == FTy.getReturnType() && + FTy.getParamType(1) == FTy.getReturnType()); + +- case LibFunc::strncat: ++ case LibFunc_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 LibFunc_strcpy_chk: ++ case LibFunc_stpcpy_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + // fallthrough +- case LibFunc::strcpy: +- case LibFunc::stpcpy: ++ case LibFunc_strcpy: ++ case LibFunc_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 LibFunc_strncpy_chk: ++ case LibFunc_stpncpy_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + // fallthrough +- case LibFunc::strncpy: +- case LibFunc::stpncpy: ++ case LibFunc_strncpy: ++ case LibFunc_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 LibFunc_strxfrm: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(0) == FTy.getParamType(1)); + +- case LibFunc::strncmp: ++ case LibFunc_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 LibFunc_strspn: ++ case LibFunc_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 LibFunc_strcoll: ++ case LibFunc_strcasecmp: ++ case LibFunc_strncasecmp: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strstr: ++ case LibFunc_strstr: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strpbrk: ++ case LibFunc_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 LibFunc_strtok: ++ case LibFunc_strtok_r: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::scanf: +- case LibFunc::setbuf: +- case LibFunc::setvbuf: ++ case LibFunc_scanf: ++ case LibFunc_setbuf: ++ case LibFunc_setvbuf: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::strdup: +- case LibFunc::strndup: ++ case LibFunc_strdup: ++ case LibFunc_strndup: + return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::sscanf: +- case LibFunc::stat: +- case LibFunc::statvfs: +- case LibFunc::sprintf: ++ case LibFunc_sscanf: ++ case LibFunc_stat: ++ case LibFunc_statvfs: ++ case LibFunc_sprintf: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::snprintf: ++ case LibFunc_snprintf: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::setitimer: ++ case LibFunc_setitimer: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::system: ++ case LibFunc_system: + return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::malloc: ++ case LibFunc_malloc: + return (NumParams == 1 && FTy.getReturnType()->isPointerTy()); +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy() && + FTy.getReturnType()->isIntegerTy(32)); + +- case LibFunc::memchr: +- case LibFunc::memrchr: ++ case LibFunc_memchr: ++ case LibFunc_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 LibFunc_modf: ++ case LibFunc_modff: ++ case LibFunc_modfl: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::memcpy_chk: +- case LibFunc::memmove_chk: ++ case LibFunc_memcpy_chk: ++ case LibFunc_memmove_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + // fallthrough +- case LibFunc::memcpy: +- case LibFunc::memmove: ++ case LibFunc_memcpy: ++ case LibFunc_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 LibFunc_memset_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + // fallthrough +- case LibFunc::memset: ++ case LibFunc_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 LibFunc_memccpy: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::memalign: ++ case LibFunc_memalign: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::realloc: ++ case LibFunc_realloc: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getReturnType()->isPointerTy()); +- case LibFunc::read: ++ case LibFunc_read: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::rewind: +- case LibFunc::rmdir: +- case LibFunc::remove: +- case LibFunc::realpath: ++ case LibFunc_rewind: ++ case LibFunc_rmdir: ++ case LibFunc_remove: ++ case LibFunc_realpath: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::rename: ++ case LibFunc_rename: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::readlink: ++ case LibFunc_readlink: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::write: ++ case LibFunc_write: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::bcopy: +- case LibFunc::bcmp: ++ case LibFunc_bcopy: ++ case LibFunc_bcmp: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::bzero: ++ case LibFunc_bzero: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::calloc: ++ case LibFunc_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 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: + 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 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: + return (NumParams != 0 && FTy.getParamType(0)->isPointerTy()); + +- case LibFunc::access: ++ case LibFunc_access: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::fopen: ++ case LibFunc_fopen: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fdopen: ++ case LibFunc_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 LibFunc_fputc: ++ case LibFunc_fstat: ++ case LibFunc_frexp: ++ case LibFunc_frexpf: ++ case LibFunc_frexpl: ++ case LibFunc_fstatvfs: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fgets: ++ case LibFunc_fgets: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::fread: ++ case LibFunc_fread: + return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(3)->isPointerTy()); +- case LibFunc::fwrite: ++ case LibFunc_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 LibFunc_fputs: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fscanf: +- case LibFunc::fprintf: ++ case LibFunc_fscanf: ++ case LibFunc_fprintf: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fgetpos: ++ case LibFunc_fgetpos: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::gets: +- case LibFunc::getchar: +- case LibFunc::getitimer: ++ case LibFunc_gets: ++ case LibFunc_getchar: ++ case LibFunc_getitimer: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::ungetc: ++ case LibFunc_ungetc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::utime: +- case LibFunc::utimes: ++ case LibFunc_utime: ++ case LibFunc_utimes: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::putc: ++ case LibFunc_putc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::pread: +- case LibFunc::pwrite: ++ case LibFunc_pread: ++ case LibFunc_pwrite: + return (NumParams == 4 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::popen: ++ case LibFunc_popen: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vscanf: ++ case LibFunc_vscanf: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vsscanf: ++ case LibFunc_vsscanf: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::vfscanf: ++ case LibFunc_vfscanf: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::valloc: ++ case LibFunc_valloc: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::vprintf: ++ case LibFunc_vprintf: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::vfprintf: +- case LibFunc::vsprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_vsprintf: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vsnprintf: ++ case LibFunc_vsnprintf: + return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::open: ++ case LibFunc_open: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::opendir: ++ case LibFunc_opendir: + return (NumParams == 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::tmpfile: ++ case LibFunc_tmpfile: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::htonl: +- case LibFunc::htons: +- case LibFunc::ntohl: +- case LibFunc::ntohs: +- case LibFunc::lstat: ++ case LibFunc_htonl: ++ case LibFunc_htons: ++ case LibFunc_ntohl: ++ case LibFunc_ntohs: ++ case LibFunc_lstat: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::lchown: ++ case LibFunc_lchown: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::qsort: ++ case LibFunc_qsort: + return (NumParams == 4 && FTy.getParamType(3)->isPointerTy()); +- case LibFunc::dunder_strdup: +- case LibFunc::dunder_strndup: ++ case LibFunc_dunder_strdup: ++ case LibFunc_dunder_strndup: + return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::dunder_strtok_r: ++ case LibFunc_dunder_strtok_r: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::under_IO_putc: ++ case LibFunc_under_IO_putc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::dunder_isoc99_scanf: ++ case LibFunc_dunder_isoc99_scanf: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::stat64: +- case LibFunc::lstat64: +- case LibFunc::statvfs64: ++ case LibFunc_stat64: ++ case LibFunc_lstat64: ++ case LibFunc_statvfs64: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::dunder_isoc99_sscanf: ++ case LibFunc_dunder_isoc99_sscanf: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fopen64: ++ case LibFunc_fopen64: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::tmpfile64: ++ case LibFunc_tmpfile64: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::fstat64: +- case LibFunc::fstatvfs64: ++ case LibFunc_fstat64: ++ case LibFunc_fstatvfs64: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::open64: ++ case LibFunc_open64: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::gettimeofday: ++ case LibFunc_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 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); + return (NumParams == 1); + +- case LibFunc::memset_pattern16: ++ case LibFunc_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 LibFunc_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 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: + 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 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: + 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::isdigit: +- case LibFunc::isascii: +- case LibFunc::toascii: ++ case LibFunc_ffs: ++ case LibFunc_ffsl: ++ case LibFunc_ffsll: ++ case LibFunc_isdigit: ++ case LibFunc_isascii: ++ case LibFunc_toascii: + return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && + FTy.getParamType(0)->isIntegerTy()); + +- case LibFunc::fls: +- case LibFunc::flsl: +- case LibFunc::flsll: +- case LibFunc::abs: +- case LibFunc::labs: +- case LibFunc::llabs: ++ case LibFunc_fls: ++ case LibFunc_flsl: ++ case LibFunc_flsll: ++ case LibFunc_abs: ++ case LibFunc_labs: ++ case LibFunc_llabs: + return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +- case LibFunc::cxa_atexit: ++ case LibFunc_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 LibFunc_sinpi: ++ case LibFunc_cospi: + return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +- case LibFunc::sinpif: +- case LibFunc::cospif: ++ case LibFunc_sinpif: ++ case LibFunc_cospif: + return (NumParams == 1 && FTy.getReturnType()->isFloatTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +@@ -992,7 +992,7 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, + } + + 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) && +diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp +index f2b40787443..4dcf08b1c81 100644 +--- a/lib/Analysis/ValueTracking.cpp ++++ b/lib/Analysis/ValueTracking.cpp +@@ -2304,7 +2304,7 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS, + if (!TLI) + return Intrinsic::not_intrinsic; + +- LibFunc::Func Func; ++ LibFunc Func; + // We're going to make assumptions on the semantics of the functions, check + // that the target knows that it's available in this environment and it does + // not have local linkage. +@@ -2319,81 +2319,81 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS, + switch (Func) { + default: + break; +- case LibFunc::sin: +- case LibFunc::sinf: +- case LibFunc::sinl: ++ case LibFunc_sin: ++ case LibFunc_sinf: ++ case LibFunc_sinl: + return Intrinsic::sin; +- case LibFunc::cos: +- case LibFunc::cosf: +- case LibFunc::cosl: ++ case LibFunc_cos: ++ case LibFunc_cosf: ++ case LibFunc_cosl: + return Intrinsic::cos; +- case LibFunc::exp: +- case LibFunc::expf: +- case LibFunc::expl: ++ case LibFunc_exp: ++ case LibFunc_expf: ++ case LibFunc_expl: + return Intrinsic::exp; +- case LibFunc::exp2: +- case LibFunc::exp2f: +- case LibFunc::exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: ++ case LibFunc_exp2l: + return Intrinsic::exp2; +- case LibFunc::log: +- case LibFunc::logf: +- case LibFunc::logl: ++ case LibFunc_log: ++ case LibFunc_logf: ++ case LibFunc_logl: + return Intrinsic::log; +- case LibFunc::log10: +- case LibFunc::log10f: +- case LibFunc::log10l: ++ case LibFunc_log10: ++ case LibFunc_log10f: ++ case LibFunc_log10l: + return Intrinsic::log10; +- case LibFunc::log2: +- case LibFunc::log2f: +- case LibFunc::log2l: ++ case LibFunc_log2: ++ case LibFunc_log2f: ++ case LibFunc_log2l: + return Intrinsic::log2; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + return Intrinsic::fabs; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + return Intrinsic::minnum; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + return Intrinsic::maxnum; +- case LibFunc::copysign: +- case LibFunc::copysignf: +- case LibFunc::copysignl: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: ++ case LibFunc_copysignl: + return Intrinsic::copysign; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + return Intrinsic::floor; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + return Intrinsic::ceil; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + return Intrinsic::trunc; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + return Intrinsic::rint; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + return Intrinsic::nearbyint; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + return Intrinsic::round; +- case LibFunc::pow: +- case LibFunc::powf: +- case LibFunc::powl: ++ case LibFunc_pow: ++ case LibFunc_powf: ++ case LibFunc_powl: + return Intrinsic::pow; +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: + if (ICS->hasNoNaNs()) + return Intrinsic::sqrt; + return Intrinsic::not_intrinsic; +diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp +index b10da002fcf..35ee744b943 100644 +--- a/lib/CodeGen/SelectionDAG/FastISel.cpp ++++ b/lib/CodeGen/SelectionDAG/FastISel.cpp +@@ -1383,7 +1383,7 @@ bool FastISel::selectInstruction(const Instruction *I) { + + 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. +diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +index e03282cad6b..d96677e7795 100644 +--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp ++++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +@@ -6222,15 +6222,15 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { + // Check for well-known libc/libm calls. If the function is internal, it + // can't be a library call. Don't do the check if marked as nobuiltin for + // some reason. +- LibFunc::Func Func; ++ LibFunc Func; + if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() && + LibInfo->getLibFunc(F->getName(), Func) && + LibInfo->hasOptimizedCodeGen(Func)) { + switch (Func) { + default: break; +- case LibFunc::copysign: +- case LibFunc::copysignf: +- case LibFunc::copysignl: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: ++ case LibFunc_copysignl: + if (I.getNumArgOperands() == 2 && // Basic sanity checks. + I.getArgOperand(0)->getType()->isFloatingPointTy() && + I.getType() == I.getArgOperand(0)->getType() && +@@ -6243,118 +6243,118 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { + return; + } + break; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + if (visitUnaryFloatCall(I, ISD::FABS)) + return; + break; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + if (visitBinaryFloatCall(I, ISD::FMINNUM)) + return; + break; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + if (visitBinaryFloatCall(I, ISD::FMAXNUM)) + return; + break; +- case LibFunc::sin: +- case LibFunc::sinf: +- case LibFunc::sinl: ++ case LibFunc_sin: ++ case LibFunc_sinf: ++ case LibFunc_sinl: + if (visitUnaryFloatCall(I, ISD::FSIN)) + return; + break; +- case LibFunc::cos: +- case LibFunc::cosf: +- case LibFunc::cosl: ++ case LibFunc_cos: ++ case LibFunc_cosf: ++ case LibFunc_cosl: + if (visitUnaryFloatCall(I, ISD::FCOS)) + return; + break; +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: +- case LibFunc::sqrt_finite: +- case LibFunc::sqrtf_finite: +- case LibFunc::sqrtl_finite: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: ++ case LibFunc_sqrt_finite: ++ case LibFunc_sqrtf_finite: ++ case LibFunc_sqrtl_finite: + if (visitUnaryFloatCall(I, ISD::FSQRT)) + return; + break; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + if (visitUnaryFloatCall(I, ISD::FFLOOR)) + return; + break; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + if (visitUnaryFloatCall(I, ISD::FNEARBYINT)) + return; + break; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + if (visitUnaryFloatCall(I, ISD::FCEIL)) + return; + break; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + if (visitUnaryFloatCall(I, ISD::FRINT)) + return; + break; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + if (visitUnaryFloatCall(I, ISD::FROUND)) + return; + break; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + if (visitUnaryFloatCall(I, ISD::FTRUNC)) + return; + break; +- case LibFunc::log2: +- case LibFunc::log2f: +- case LibFunc::log2l: ++ case LibFunc_log2: ++ case LibFunc_log2f: ++ case LibFunc_log2l: + if (visitUnaryFloatCall(I, ISD::FLOG2)) + return; + break; +- case LibFunc::exp2: +- case LibFunc::exp2f: +- case LibFunc::exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: ++ case LibFunc_exp2l: + if (visitUnaryFloatCall(I, ISD::FEXP2)) + return; + break; +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + if (visitMemCmpCall(I)) + return; + break; +- case LibFunc::memchr: ++ case LibFunc_memchr: + if (visitMemChrCall(I)) + return; + break; +- case LibFunc::strcpy: ++ case LibFunc_strcpy: + if (visitStrCpyCall(I, false)) + return; + break; +- case LibFunc::stpcpy: ++ case LibFunc_stpcpy: + if (visitStrCpyCall(I, true)) + return; + break; +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + if (visitStrCmpCall(I)) + return; + break; +- case LibFunc::strlen: ++ case LibFunc_strlen: + if (visitStrLenCall(I)) + return; + break; +- case LibFunc::strnlen: ++ case LibFunc_strnlen: + if (visitStrNLenCall(I)) + return; + break; +diff --git a/lib/LTO/UpdateCompilerUsed.cpp b/lib/LTO/UpdateCompilerUsed.cpp +index a574db6fb5a..3af239b7549 100644 +--- a/lib/LTO/UpdateCompilerUsed.cpp ++++ b/lib/LTO/UpdateCompilerUsed.cpp +@@ -64,7 +64,7 @@ private: + // 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)); + } +diff --git a/lib/Target/PowerPC/PPCCTRLoops.cpp b/lib/Target/PowerPC/PPCCTRLoops.cpp +index 87522663591..ad7bcd9d752 100644 +--- a/lib/Target/PowerPC/PPCCTRLoops.cpp ++++ b/lib/Target/PowerPC/PPCCTRLoops.cpp +@@ -315,7 +315,7 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { + // (i.e. soft float or atomics). If adapting for targets that do, + // additional care is required here. + +- LibFunc::Func Func; ++ LibFunc Func; + if (!F->hasLocalLinkage() && F->hasName() && LibInfo && + LibInfo->getLibFunc(F->getName(), Func) && + LibInfo->hasOptimizedCodeGen(Func)) { +@@ -329,50 +329,50 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { + + switch (Func) { + default: return true; +- case LibFunc::copysign: +- case LibFunc::copysignf: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: + continue; // ISD::FCOPYSIGN is never a library call. +- case LibFunc::copysignl: ++ case LibFunc_copysignl: + return true; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + continue; // ISD::FABS is never a library call. +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: + Opcode = ISD::FSQRT; break; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + Opcode = ISD::FFLOOR; break; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + Opcode = ISD::FNEARBYINT; break; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + Opcode = ISD::FCEIL; break; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + Opcode = ISD::FRINT; break; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + Opcode = ISD::FROUND; break; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + Opcode = ISD::FTRUNC; break; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + Opcode = ISD::FMINNUM; break; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + Opcode = ISD::FMAXNUM; break; + } + } +diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp +index 99b12d4db0d..3fd706f4914 100644 +--- a/lib/Transforms/IPO/GlobalOpt.cpp ++++ b/lib/Transforms/IPO/GlobalOpt.cpp +@@ -2403,7 +2403,7 @@ OptimizeGlobalAliases(Module &M, + } + + static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) { +- LibFunc::Func F = LibFunc::cxa_atexit; ++ LibFunc F = LibFunc_cxa_atexit; + if (!TLI->has(F)) + return nullptr; + +@@ -2412,7 +2412,7 @@ static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) { + return nullptr; + + // Make sure that the function has the correct prototype. +- if (!TLI->getLibFunc(*Fn, F) || F != LibFunc::cxa_atexit) ++ if (!TLI->getLibFunc(*Fn, F) || F != LibFunc_cxa_atexit) + return nullptr; + + return Fn; +diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp +index ed58a87ae1a..c2052042253 100644 +--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp ++++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp +@@ -130,13 +130,13 @@ static bool hasMemoryWrite(Instruction *I, const TargetLibraryInfo &TLI) { + if (auto CS = CallSite(I)) { + if (Function *F = CS.getCalledFunction()) { + StringRef FnName = F->getName(); +- if (TLI.has(LibFunc::strcpy) && FnName == TLI.getName(LibFunc::strcpy)) ++ if (TLI.has(LibFunc_strcpy) && FnName == TLI.getName(LibFunc_strcpy)) + return true; +- if (TLI.has(LibFunc::strncpy) && FnName == TLI.getName(LibFunc::strncpy)) ++ if (TLI.has(LibFunc_strncpy) && FnName == TLI.getName(LibFunc_strncpy)) + return true; +- if (TLI.has(LibFunc::strcat) && FnName == TLI.getName(LibFunc::strcat)) ++ if (TLI.has(LibFunc_strcat) && FnName == TLI.getName(LibFunc_strcat)) + return true; +- if (TLI.has(LibFunc::strncat) && FnName == TLI.getName(LibFunc::strncat)) ++ if (TLI.has(LibFunc_strncat) && FnName == TLI.getName(LibFunc_strncat)) + return true; + } + } +diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +index 1468676a354..43c33ec7a52 100644 +--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp ++++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +@@ -229,9 +229,9 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) { + if (Name == "memset" || Name == "memcpy") + return false; + +- HasMemset = TLI->has(LibFunc::memset); +- HasMemsetPattern = TLI->has(LibFunc::memset_pattern16); +- HasMemcpy = TLI->has(LibFunc::memcpy); ++ HasMemset = TLI->has(LibFunc_memset); ++ HasMemsetPattern = TLI->has(LibFunc_memset_pattern16); ++ HasMemcpy = TLI->has(LibFunc_memcpy); + + if (HasMemset || HasMemsetPattern || HasMemcpy) + if (SE->hasLoopInvariantBackedgeTakenCount(L)) +diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp +index d64c658f843..6c45e9e1e2b 100644 +--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp ++++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp +@@ -1233,7 +1233,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M) { + bool MemCpyOptPass::processMemMove(MemMoveInst *M) { + AliasAnalysis &AA = LookupAliasAnalysis(); + +- if (!TLI->has(LibFunc::memmove)) ++ if (!TLI->has(LibFunc_memmove)) + return false; + + // See if the pointers alias. +@@ -1407,7 +1407,7 @@ bool MemCpyOptPass::runImpl( + // If we don't have at least memset and memcpy, there is little point of doing + // anything here. These are required by a freestanding implementation, so if + // even they are disabled, there is no point in trying hard. +- if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy)) ++ if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy)) + return false; + + while (1) { +diff --git a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +index c4b3e3464f4..b66859d9eee 100644 +--- a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp ++++ b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +@@ -98,14 +98,14 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI, + + // Skip if function either has local linkage or is not a known library + // function. +- LibFunc::Func LibFunc; ++ LibFunc LF; + if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() || +- !TLI->getLibFunc(CalledFunc->getName(), LibFunc)) ++ !TLI->getLibFunc(CalledFunc->getName(), LF)) + continue; + +- switch (LibFunc) { +- case LibFunc::sqrtf: +- case LibFunc::sqrt: ++ switch (LF) { ++ case LibFunc_sqrtf: ++ case LibFunc_sqrt: + if (TTI->haveFastSqrt(Call->getType()) && + optimizeSQRT(Call, CalledFunc, *CurrBB, BB)) + break; +diff --git a/lib/Transforms/Utils/BuildLibCalls.cpp b/lib/Transforms/Utils/BuildLibCalls.cpp +index f4260a9ff98..740fb31c1de 100644 +--- a/lib/Transforms/Utils/BuildLibCalls.cpp ++++ b/lib/Transforms/Utils/BuildLibCalls.cpp +@@ -107,254 +107,254 @@ static bool setNonNull(Function &F, unsigned n) { + } + + bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { +- LibFunc::Func TheLibFunc; ++ LibFunc TheLibFunc; + if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc))) + return false; + + bool Changed = false; + switch (TheLibFunc) { +- case LibFunc::strlen: ++ case LibFunc_strlen: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::strchr: +- case LibFunc::strrchr: ++ case LibFunc_strchr: ++ case LibFunc_strrchr: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::strtol: +- case LibFunc::strtod: +- case LibFunc::strtof: +- case LibFunc::strtoul: +- case LibFunc::strtoll: +- case LibFunc::strtold: +- case LibFunc::strtoull: ++ case LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::strcpy: +- case LibFunc::stpcpy: +- case LibFunc::strcat: +- case LibFunc::strncat: +- case LibFunc::strncpy: +- case LibFunc::stpncpy: ++ case LibFunc_strcpy: ++ case LibFunc_stpcpy: ++ case LibFunc_strcat: ++ case LibFunc_strncat: ++ case LibFunc_strncpy: ++ case LibFunc_stpncpy: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::strxfrm: ++ case LibFunc_strxfrm: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::strcmp: // 0,1 +- case LibFunc::strspn: // 0,1 +- case LibFunc::strncmp: // 0,1 +- case LibFunc::strcspn: // 0,1 +- case LibFunc::strcoll: // 0,1 +- case LibFunc::strcasecmp: // 0,1 +- case LibFunc::strncasecmp: // ++ case LibFunc_strcmp: // 0,1 ++ case LibFunc_strspn: // 0,1 ++ case LibFunc_strncmp: // 0,1 ++ case LibFunc_strcspn: // 0,1 ++ case LibFunc_strcoll: // 0,1 ++ case LibFunc_strcasecmp: // 0,1 ++ case LibFunc_strncasecmp: // + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::strstr: +- case LibFunc::strpbrk: ++ case LibFunc_strstr: ++ case LibFunc_strpbrk: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::strtok: +- case LibFunc::strtok_r: ++ case LibFunc_strtok: ++ case LibFunc_strtok_r: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::scanf: ++ case LibFunc_scanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::setbuf: +- case LibFunc::setvbuf: ++ case LibFunc_setbuf: ++ case LibFunc_setvbuf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::strdup: +- case LibFunc::strndup: ++ case LibFunc_strdup: ++ case LibFunc_strndup: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::stat: +- case LibFunc::statvfs: ++ case LibFunc_stat: ++ case LibFunc_statvfs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::sscanf: ++ case LibFunc_sscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::sprintf: ++ case LibFunc_sprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::snprintf: ++ case LibFunc_snprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 3); + return Changed; +- case LibFunc::setitimer: ++ case LibFunc_setitimer: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::system: ++ case LibFunc_system: + // May throw; "system" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::malloc: ++ case LibFunc_malloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::memchr: +- case LibFunc::memrchr: ++ case LibFunc_memchr: ++ case LibFunc_memrchr: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::modf: +- case LibFunc::modff: +- case LibFunc::modfl: ++ case LibFunc_modf: ++ case LibFunc_modff: ++ case LibFunc_modfl: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::memcpy: +- case LibFunc::memccpy: +- case LibFunc::memmove: ++ case LibFunc_memcpy: ++ case LibFunc_memccpy: ++ case LibFunc_memmove: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::memcpy_chk: ++ case LibFunc_memcpy_chk: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::memalign: ++ case LibFunc_memalign: + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::mkdir: ++ case LibFunc_mkdir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::mktime: ++ case LibFunc_mktime: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::realloc: ++ case LibFunc_realloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::read: ++ case LibFunc_read: + // May throw; "read" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::rewind: ++ case LibFunc_rewind: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::rmdir: +- case LibFunc::remove: +- case LibFunc::realpath: ++ case LibFunc_rmdir: ++ case LibFunc_remove: ++ case LibFunc_realpath: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::rename: ++ case LibFunc_rename: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::readlink: ++ case LibFunc_readlink: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::write: ++ case LibFunc_write: + // May throw; "write" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::bcopy: ++ case LibFunc_bcopy: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::bcmp: ++ case LibFunc_bcmp: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::bzero: ++ case LibFunc_bzero: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::calloc: ++ case LibFunc_calloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::chmod: +- case LibFunc::chown: ++ case LibFunc_chmod: ++ case LibFunc_chown: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::ctermid: +- case LibFunc::clearerr: +- case LibFunc::closedir: ++ case LibFunc_ctermid: ++ case LibFunc_clearerr: ++ case LibFunc_closedir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::atoi: +- case LibFunc::atol: +- case LibFunc::atof: +- case LibFunc::atoll: ++ case LibFunc_atoi: ++ case LibFunc_atol: ++ case LibFunc_atof: ++ case LibFunc_atoll: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::access: ++ case LibFunc_access: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::fopen: ++ case LibFunc_fopen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -362,150 +362,150 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fdopen: ++ case LibFunc_fdopen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::feof: +- case LibFunc::free: +- case LibFunc::fseek: +- case LibFunc::ftell: +- case LibFunc::fgetc: +- case LibFunc::fseeko: +- case LibFunc::ftello: +- case LibFunc::fileno: +- case LibFunc::fflush: +- case LibFunc::fclose: +- case LibFunc::fsetpos: +- case LibFunc::flockfile: +- case LibFunc::funlockfile: +- case LibFunc::ftrylockfile: ++ case LibFunc_feof: ++ case LibFunc_free: ++ case LibFunc_fseek: ++ case LibFunc_ftell: ++ case LibFunc_fgetc: ++ case LibFunc_fseeko: ++ case LibFunc_ftello: ++ case LibFunc_fileno: ++ case LibFunc_fflush: ++ case LibFunc_fclose: ++ case LibFunc_fsetpos: ++ case LibFunc_flockfile: ++ case LibFunc_funlockfile: ++ case LibFunc_ftrylockfile: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::ferror: ++ case LibFunc_ferror: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F); + return Changed; +- case LibFunc::fputc: +- case LibFunc::fstat: +- case LibFunc::frexp: +- case LibFunc::frexpf: +- case LibFunc::frexpl: +- case LibFunc::fstatvfs: ++ case LibFunc_fputc: ++ case LibFunc_fstat: ++ case LibFunc_frexp: ++ case LibFunc_frexpf: ++ case LibFunc_frexpl: ++ case LibFunc_fstatvfs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::fgets: ++ case LibFunc_fgets: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 3); + return Changed; +- case LibFunc::fread: ++ case LibFunc_fread: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 4); + return Changed; +- case LibFunc::fwrite: ++ case LibFunc_fwrite: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 4); + // FIXME: readonly #1? + return Changed; +- case LibFunc::fputs: ++ case LibFunc_fputs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::fscanf: +- case LibFunc::fprintf: ++ case LibFunc_fscanf: ++ case LibFunc_fprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fgetpos: ++ case LibFunc_fgetpos: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::getc: +- case LibFunc::getlogin_r: +- case LibFunc::getc_unlocked: ++ case LibFunc_getc: ++ case LibFunc_getlogin_r: ++ case LibFunc_getc_unlocked: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::getenv: ++ case LibFunc_getenv: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::gets: +- case LibFunc::getchar: ++ case LibFunc_gets: ++ case LibFunc_getchar: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::getitimer: ++ case LibFunc_getitimer: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::getpwnam: ++ case LibFunc_getpwnam: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::ungetc: ++ case LibFunc_ungetc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::uname: ++ case LibFunc_uname: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::unlink: ++ case LibFunc_unlink: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::unsetenv: ++ case LibFunc_unsetenv: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::utime: +- case LibFunc::utimes: ++ case LibFunc_utime: ++ case LibFunc_utimes: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::putc: ++ case LibFunc_putc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::puts: +- case LibFunc::printf: +- case LibFunc::perror: ++ case LibFunc_puts: ++ case LibFunc_printf: ++ case LibFunc_perror: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::pread: ++ case LibFunc_pread: + // May throw; "pread" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::pwrite: ++ case LibFunc_pwrite: + // May throw; "pwrite" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::putchar: ++ case LibFunc_putchar: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::popen: ++ case LibFunc_popen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -513,132 +513,132 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::pclose: ++ case LibFunc_pclose: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::vscanf: ++ case LibFunc_vscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::vsscanf: ++ case LibFunc_vsscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::vfscanf: ++ case LibFunc_vfscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::valloc: ++ case LibFunc_valloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::vprintf: ++ case LibFunc_vprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::vfprintf: +- case LibFunc::vsprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_vsprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::vsnprintf: ++ case LibFunc_vsnprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 3); + return Changed; +- case LibFunc::open: ++ case LibFunc_open: + // May throw; "open" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::opendir: ++ case LibFunc_opendir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::tmpfile: ++ case LibFunc_tmpfile: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::times: ++ case LibFunc_times: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::htonl: +- case LibFunc::htons: +- case LibFunc::ntohl: +- case LibFunc::ntohs: ++ case LibFunc_htonl: ++ case LibFunc_htons: ++ case LibFunc_ntohl: ++ case LibFunc_ntohs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAccessMemory(F); + return Changed; +- case LibFunc::lstat: ++ case LibFunc_lstat: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::lchown: ++ case LibFunc_lchown: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::qsort: ++ case LibFunc_qsort: + // May throw; places call through function pointer. + Changed |= setDoesNotCapture(F, 4); + return Changed; +- case LibFunc::dunder_strdup: +- case LibFunc::dunder_strndup: ++ case LibFunc_dunder_strdup: ++ case LibFunc_dunder_strndup: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::dunder_strtok_r: ++ case LibFunc_dunder_strtok_r: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::under_IO_getc: ++ case LibFunc_under_IO_getc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::under_IO_putc: ++ case LibFunc_under_IO_putc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::dunder_isoc99_scanf: ++ case LibFunc_dunder_isoc99_scanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::stat64: +- case LibFunc::lstat64: +- case LibFunc::statvfs64: ++ case LibFunc_stat64: ++ case LibFunc_lstat64: ++ case LibFunc_statvfs64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::dunder_isoc99_sscanf: ++ case LibFunc_dunder_isoc99_sscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fopen64: ++ case LibFunc_fopen64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -646,26 +646,26 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fseeko64: +- case LibFunc::ftello64: ++ case LibFunc_fseeko64: ++ case LibFunc_ftello64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::tmpfile64: ++ case LibFunc_tmpfile64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::fstat64: +- case LibFunc::fstatvfs64: ++ case LibFunc_fstat64: ++ case LibFunc_fstatvfs64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::open64: ++ case LibFunc_open64: + // May throw; "open" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::gettimeofday: ++ case LibFunc_gettimeofday: + // Currently some platforms have the restrict keyword on the arguments to + // gettimeofday. To be conservative, do not add noalias to gettimeofday's + // arguments. +@@ -673,29 +673,29 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::Znwj: // new(unsigned int) +- case LibFunc::Znwm: // new(unsigned long) +- case LibFunc::Znaj: // new[](unsigned int) +- case LibFunc::Znam: // new[](unsigned long) +- case LibFunc::msvc_new_int: // new(unsigned int) +- case LibFunc::msvc_new_longlong: // new(unsigned long long) +- case LibFunc::msvc_new_array_int: // new[](unsigned int) +- case LibFunc::msvc_new_array_longlong: // new[](unsigned long long) ++ case LibFunc_Znwj: // new(unsigned int) ++ case LibFunc_Znwm: // new(unsigned long) ++ case LibFunc_Znaj: // new[](unsigned int) ++ case LibFunc_Znam: // new[](unsigned long) ++ case LibFunc_msvc_new_int: // new(unsigned int) ++ case LibFunc_msvc_new_longlong: // new(unsigned long long) ++ case LibFunc_msvc_new_array_int: // new[](unsigned int) ++ case LibFunc_msvc_new_array_longlong: // new[](unsigned long long) + // Operator new always returns a nonnull noalias pointer + Changed |= setNonNull(F, AttributeSet::ReturnIndex); + Changed |= setDoesNotAlias(F, AttributeSet::ReturnIndex); + return Changed; + //TODO: add LibFunc entries for: +- //case LibFunc::memset_pattern4: +- //case LibFunc::memset_pattern8: +- case LibFunc::memset_pattern16: ++ //case LibFunc_memset_pattern4: ++ //case LibFunc_memset_pattern8: ++ case LibFunc_memset_pattern16: + Changed |= setOnlyAccessesArgMemory(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; + // int __nvvm_reflect(const char *) +- case LibFunc::nvvm_reflect: ++ case LibFunc_nvvm_reflect: + Changed |= setDoesNotAccessMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +@@ -716,7 +716,7 @@ Value *llvm::castToCStr(Value *V, IRBuilder<> &B) { + + Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strlen)) ++ if (!TLI->has(LibFunc_strlen)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -733,7 +733,7 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, + + Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strchr)) ++ if (!TLI->has(LibFunc_strchr)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -751,7 +751,7 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, + + Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strncmp)) ++ if (!TLI->has(LibFunc_strncmp)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -771,7 +771,7 @@ Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + + Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, + const TargetLibraryInfo *TLI, StringRef Name) { +- if (!TLI->has(LibFunc::strcpy)) ++ if (!TLI->has(LibFunc_strcpy)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -787,7 +787,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, + + Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, + const TargetLibraryInfo *TLI, StringRef Name) { +- if (!TLI->has(LibFunc::strncpy)) ++ if (!TLI->has(LibFunc_strncpy)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -805,7 +805,7 @@ Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, + Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, + IRBuilder<> &B, const DataLayout &DL, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memcpy_chk)) ++ if (!TLI->has(LibFunc_memcpy_chk)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -827,7 +827,7 @@ Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, + + Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memchr)) ++ if (!TLI->has(LibFunc_memchr)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -846,7 +846,7 @@ Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, + + Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memcmp)) ++ if (!TLI->has(LibFunc_memcmp)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -913,7 +913,7 @@ Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name, + + Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::putchar)) ++ if (!TLI->has(LibFunc_putchar)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -933,7 +933,7 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, + + Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::puts)) ++ if (!TLI->has(LibFunc_puts)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -948,7 +948,7 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, + + Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fputc)) ++ if (!TLI->has(LibFunc_fputc)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -967,11 +967,11 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, + + Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fputs)) ++ if (!TLI->has(LibFunc_fputs)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +- StringRef FPutsName = TLI->getName(LibFunc::fputs); ++ StringRef FPutsName = TLI->getName(LibFunc_fputs); + Constant *F = M->getOrInsertFunction( + FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType(), nullptr); + if (File->getType()->isPointerTy()) +@@ -985,12 +985,12 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, + + Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fwrite)) ++ if (!TLI->has(LibFunc_fwrite)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); + LLVMContext &Context = B.GetInsertBlock()->getContext(); +- StringRef FWriteName = TLI->getName(LibFunc::fwrite); ++ StringRef FWriteName = TLI->getName(LibFunc_fwrite); + Constant *F = M->getOrInsertFunction( + FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(), + DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType(), +diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp +index f1838d89146..7667312bb0e 100644 +--- a/lib/Transforms/Utils/Local.cpp ++++ b/lib/Transforms/Utils/Local.cpp +@@ -1957,19 +1957,19 @@ bool llvm::recognizeBSwapOrBitReverseIdiom( + void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI, + const TargetLibraryInfo *TLI) { + Function *F = CI->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (!F || F->hasLocalLinkage() || !F->hasName() || + !TLI->getLibFunc(F->getName(), Func)) + return; + switch (Func) { + default: break; +- case LibFunc::memcmp: +- case LibFunc::memchr: +- case LibFunc::strcpy: +- case LibFunc::stpcpy: +- case LibFunc::strcmp: +- case LibFunc::strlen: +- case LibFunc::strnlen: ++ case LibFunc_memcmp: ++ case LibFunc_memchr: ++ case LibFunc_strcpy: ++ case LibFunc_stpcpy: ++ case LibFunc_strcmp: ++ case LibFunc_strlen: ++ case LibFunc_strnlen: + CI->addAttribute(AttributeSet::FunctionIndex, Attribute::NoBuiltin); + break; + } +diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp +index c2986951e48..69ac831fcfd 100644 +--- a/lib/Transforms/Utils/SimplifyLibCalls.cpp ++++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp +@@ -51,9 +51,9 @@ static cl::opt + // Helper Functions + //===----------------------------------------------------------------------===// + +-static bool ignoreCallingConv(LibFunc::Func Func) { +- return Func == LibFunc::abs || Func == LibFunc::labs || +- Func == LibFunc::llabs || Func == LibFunc::strlen; ++static bool ignoreCallingConv(LibFunc Func) { ++ return Func == LibFunc_abs || Func == LibFunc_labs || ++ Func == LibFunc_llabs || Func == LibFunc_strlen; + } + + /// Return true if it only matters that the value is equal or not-equal to zero. +@@ -91,8 +91,8 @@ static bool callHasFloatingPointArgument(const CallInst *CI) { + /// \brief Check whether the overloaded unary floating point function + /// corresponding to \a Ty is available. + static bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty, +- LibFunc::Func DoubleFn, LibFunc::Func FloatFn, +- LibFunc::Func LongDoubleFn) { ++ LibFunc DoubleFn, LibFunc FloatFn, ++ LibFunc LongDoubleFn) { + switch (Ty->getTypeID()) { + case Type::FloatTyID: + return TLI->has(FloatFn); +@@ -779,7 +779,7 @@ Value *LibCallSimplifier::optimizeMemMove(CallInst *CI, IRBuilder<> &B) { + // functions be moved here? + static Value *emitCalloc(Value *Num, Value *Size, const AttributeSet &Attrs, + IRBuilder<> &B, const TargetLibraryInfo &TLI) { +- LibFunc::Func Func; ++ LibFunc Func; + if (!TLI.getLibFunc("calloc", Func) || !TLI.has(Func)) + return nullptr; + +@@ -814,9 +814,9 @@ static Value *foldMallocMemset(CallInst *Memset, IRBuilder<> &B, + + // Is the inner call really malloc()? + Function *InnerCallee = Malloc->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (!TLI.getLibFunc(*InnerCallee, Func) || !TLI.has(Func) || +- Func != LibFunc::malloc) ++ Func != LibFunc_malloc) + return nullptr; + + // The memset must cover the same number of bytes that are malloc'd. +@@ -999,15 +999,15 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + return Op1C; + // pow(2.0, x) -> exp2(x) + if (Op1C->isExactlyValue(2.0) && +- hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp2, LibFunc::exp2f, +- LibFunc::exp2l)) +- return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc::exp2), B, ++ hasUnaryFloatFn(TLI, Op1->getType(), LibFunc_exp2, LibFunc_exp2f, ++ LibFunc_exp2l)) ++ return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc_exp2), B, + Callee->getAttributes()); + // pow(10.0, x) -> exp10(x) + if (Op1C->isExactlyValue(10.0) && +- hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp10, LibFunc::exp10f, +- LibFunc::exp10l)) +- return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc::exp10), B, ++ hasUnaryFloatFn(TLI, Op1->getType(), LibFunc_exp10, LibFunc_exp10f, ++ LibFunc_exp10l)) ++ return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc_exp10), B, + Callee->getAttributes()); + } + +@@ -1019,10 +1019,10 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + // pow(exp(x), y) = pow(inf, 0.001) = inf, whereas exp(x*y) = exp(1). + auto *OpC = dyn_cast(Op1); + if (OpC && OpC->hasUnsafeAlgebra() && CI->hasUnsafeAlgebra()) { +- LibFunc::Func Func; ++ LibFunc Func; + Function *OpCCallee = OpC->getCalledFunction(); + if (OpCCallee && TLI->getLibFunc(OpCCallee->getName(), Func) && +- TLI->has(Func) && (Func == LibFunc::exp || Func == LibFunc::exp2)) { ++ TLI->has(Func) && (Func == LibFunc_exp || Func == LibFunc_exp2)) { + IRBuilder<>::FastMathFlagGuard Guard(B); + B.setFastMathFlags(CI->getFastMathFlags()); + Value *FMul = B.CreateFMul(OpC->getArgOperand(0), Op2, "mul"); +@@ -1039,16 +1039,16 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + return ConstantFP::get(CI->getType(), 1.0); + + if (Op2C->isExactlyValue(0.5) && +- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf, +- LibFunc::sqrtl) && +- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::fabs, LibFunc::fabsf, +- LibFunc::fabsl)) { ++ hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_sqrt, LibFunc_sqrtf, ++ LibFunc_sqrtl) && ++ hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_fabs, LibFunc_fabsf, ++ LibFunc_fabsl)) { + + // In -ffast-math, pow(x, 0.5) -> sqrt(x). + if (CI->hasUnsafeAlgebra()) { + IRBuilder<>::FastMathFlagGuard Guard(B); + B.setFastMathFlags(CI->getFastMathFlags()); +- return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B, ++ return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc_sqrt), B, + Callee->getAttributes()); + } + +@@ -1113,11 +1113,11 @@ Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilder<> &B) { + Value *Op = CI->getArgOperand(0); + // Turn exp2(sitofp(x)) -> ldexp(1.0, sext(x)) if sizeof(x) <= 32 + // Turn exp2(uitofp(x)) -> ldexp(1.0, zext(x)) if sizeof(x) < 32 +- LibFunc::Func LdExp = LibFunc::ldexpl; ++ LibFunc LdExp = LibFunc_ldexpl; + if (Op->getType()->isFloatTy()) +- LdExp = LibFunc::ldexpf; ++ LdExp = LibFunc_ldexpf; + else if (Op->getType()->isDoubleTy()) +- LdExp = LibFunc::ldexp; ++ LdExp = LibFunc_ldexp; + + if (TLI->has(LdExp)) { + Value *LdExpArg = nullptr; +@@ -1228,17 +1228,17 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) { + FMF.setUnsafeAlgebra(); + B.setFastMathFlags(FMF); + +- LibFunc::Func Func; ++ LibFunc Func; + Function *F = OpC->getCalledFunction(); + if (F && ((TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) && +- Func == LibFunc::pow) || F->getIntrinsicID() == Intrinsic::pow)) ++ Func == LibFunc_pow) || F->getIntrinsicID() == Intrinsic::pow)) + return B.CreateFMul(OpC->getArgOperand(1), + emitUnaryFloatFnCall(OpC->getOperand(0), Callee->getName(), B, + Callee->getAttributes()), "mul"); + + // log(exp2(y)) -> y*log(2) + if (F && Name == "log" && TLI->getLibFunc(F->getName(), Func) && +- TLI->has(Func) && Func == LibFunc::exp2) ++ TLI->has(Func) && Func == LibFunc_exp2) + return B.CreateFMul( + OpC->getArgOperand(0), + emitUnaryFloatFnCall(ConstantFP::get(CI->getType(), 2.0), +@@ -1250,8 +1250,8 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) { + Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilder<> &B) { + Function *Callee = CI->getCalledFunction(); + Value *Ret = nullptr; +- if (TLI->has(LibFunc::sqrtf) && (Callee->getName() == "sqrt" || +- Callee->getIntrinsicID() == Intrinsic::sqrt)) ++ if (TLI->has(LibFunc_sqrtf) && (Callee->getName() == "sqrt" || ++ Callee->getIntrinsicID() == Intrinsic::sqrt)) + Ret = optimizeUnaryDoubleFP(CI, B, true); + + if (!CI->hasUnsafeAlgebra()) +@@ -1333,12 +1333,12 @@ Value *LibCallSimplifier::optimizeTan(CallInst *CI, IRBuilder<> &B) { + // tan(atan(x)) -> x + // tanf(atanf(x)) -> x + // tanl(atanl(x)) -> x +- LibFunc::Func Func; ++ LibFunc Func; + Function *F = OpC->getCalledFunction(); + if (F && TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) && +- ((Func == LibFunc::atan && Callee->getName() == "tan") || +- (Func == LibFunc::atanf && Callee->getName() == "tanf") || +- (Func == LibFunc::atanl && Callee->getName() == "tanl"))) ++ ((Func == LibFunc_atan && Callee->getName() == "tan") || ++ (Func == LibFunc_atanf && Callee->getName() == "tanf") || ++ (Func == LibFunc_atanl && Callee->getName() == "tanl"))) + Ret = OpC->getArgOperand(0); + return Ret; + } +@@ -1450,24 +1450,24 @@ void LibCallSimplifier::classifyArgUse( + return; + + Function *Callee = CI->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (!Callee || !TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) || + !isTrigLibCall(CI)) + return; + + if (IsFloat) { +- if (Func == LibFunc::sinpif) ++ if (Func == LibFunc_sinpif) + SinCalls.push_back(CI); +- else if (Func == LibFunc::cospif) ++ else if (Func == LibFunc_cospif) + CosCalls.push_back(CI); +- else if (Func == LibFunc::sincospif_stret) ++ else if (Func == LibFunc_sincospif_stret) + SinCosCalls.push_back(CI); + } else { +- if (Func == LibFunc::sinpi) ++ if (Func == LibFunc_sinpi) + SinCalls.push_back(CI); +- else if (Func == LibFunc::cospi) ++ else if (Func == LibFunc_cospi) + CosCalls.push_back(CI); +- else if (Func == LibFunc::sincospi_stret) ++ else if (Func == LibFunc_sincospi_stret) + SinCosCalls.push_back(CI); + } + } +@@ -1645,7 +1645,7 @@ Value *LibCallSimplifier::optimizePrintF(CallInst *CI, IRBuilder<> &B) { + + // printf(format, ...) -> iprintf(format, ...) if no floating point + // arguments. +- if (TLI->has(LibFunc::iprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_iprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *IPrintFFn = + M->getOrInsertFunction("iprintf", FT, Callee->getAttributes()); +@@ -1726,7 +1726,7 @@ Value *LibCallSimplifier::optimizeSPrintF(CallInst *CI, IRBuilder<> &B) { + + // sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating + // point arguments. +- if (TLI->has(LibFunc::siprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_siprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *SIPrintFFn = + M->getOrInsertFunction("siprintf", FT, Callee->getAttributes()); +@@ -1796,7 +1796,7 @@ Value *LibCallSimplifier::optimizeFPrintF(CallInst *CI, IRBuilder<> &B) { + + // fprintf(stream, format, ...) -> fiprintf(stream, format, ...) if no + // floating point arguments. +- if (TLI->has(LibFunc::fiprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_fiprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *FIPrintFFn = + M->getOrInsertFunction("fiprintf", FT, Callee->getAttributes()); +@@ -1875,7 +1875,7 @@ Value *LibCallSimplifier::optimizePuts(CallInst *CI, IRBuilder<> &B) { + } + + bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { +- LibFunc::Func Func; ++ LibFunc Func; + SmallString<20> FloatFuncName = FuncName; + FloatFuncName += 'f'; + if (TLI->getLibFunc(FloatFuncName, Func)) +@@ -1885,7 +1885,7 @@ bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { + + Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI, + IRBuilder<> &Builder) { +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + // Check for string/memory library functions. + if (TLI->getLibFunc(*Callee, Func) && TLI->has(Func)) { +@@ -1894,51 +1894,51 @@ Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI, + CI->getCallingConv() == llvm::CallingConv::C) && + "Optimizing string/memory libcall would change the calling convention"); + switch (Func) { +- case LibFunc::strcat: ++ case LibFunc_strcat: + return optimizeStrCat(CI, Builder); +- case LibFunc::strncat: ++ case LibFunc_strncat: + return optimizeStrNCat(CI, Builder); +- case LibFunc::strchr: ++ case LibFunc_strchr: + return optimizeStrChr(CI, Builder); +- case LibFunc::strrchr: ++ case LibFunc_strrchr: + return optimizeStrRChr(CI, Builder); +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + return optimizeStrCmp(CI, Builder); +- case LibFunc::strncmp: ++ case LibFunc_strncmp: + return optimizeStrNCmp(CI, Builder); +- case LibFunc::strcpy: ++ case LibFunc_strcpy: + return optimizeStrCpy(CI, Builder); +- case LibFunc::stpcpy: ++ case LibFunc_stpcpy: + return optimizeStpCpy(CI, Builder); +- case LibFunc::strncpy: ++ case LibFunc_strncpy: + return optimizeStrNCpy(CI, Builder); +- case LibFunc::strlen: ++ case LibFunc_strlen: + return optimizeStrLen(CI, Builder); +- case LibFunc::strpbrk: ++ case LibFunc_strpbrk: + return optimizeStrPBrk(CI, Builder); +- case LibFunc::strtol: +- case LibFunc::strtod: +- case LibFunc::strtof: +- case LibFunc::strtoul: +- case LibFunc::strtoll: +- case LibFunc::strtold: +- case LibFunc::strtoull: ++ case LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + return optimizeStrTo(CI, Builder); +- case LibFunc::strspn: ++ case LibFunc_strspn: + return optimizeStrSpn(CI, Builder); +- case LibFunc::strcspn: ++ case LibFunc_strcspn: + return optimizeStrCSpn(CI, Builder); +- case LibFunc::strstr: ++ case LibFunc_strstr: + return optimizeStrStr(CI, Builder); +- case LibFunc::memchr: ++ case LibFunc_memchr: + return optimizeMemChr(CI, Builder); +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + return optimizeMemCmp(CI, Builder); +- case LibFunc::memcpy: ++ case LibFunc_memcpy: + return optimizeMemCpy(CI, Builder); +- case LibFunc::memmove: ++ case LibFunc_memmove: + return optimizeMemMove(CI, Builder); +- case LibFunc::memset: ++ case LibFunc_memset: + return optimizeMemSet(CI, Builder); + default: + break; +@@ -1951,7 +1951,7 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { + if (CI->isNoBuiltin()) + return nullptr; + +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + StringRef FuncName = Callee->getName(); + +@@ -2013,110 +2013,110 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { + if (Value *V = optimizeStringMemoryLibCall(CI, Builder)) + return V; + switch (Func) { +- case LibFunc::cosf: +- case LibFunc::cos: +- case LibFunc::cosl: ++ case LibFunc_cosf: ++ case LibFunc_cos: ++ case LibFunc_cosl: + return optimizeCos(CI, Builder); +- case LibFunc::sinpif: +- case LibFunc::sinpi: +- case LibFunc::cospif: +- case LibFunc::cospi: ++ case LibFunc_sinpif: ++ case LibFunc_sinpi: ++ case LibFunc_cospif: ++ case LibFunc_cospi: + return optimizeSinCosPi(CI, Builder); +- case LibFunc::powf: +- case LibFunc::pow: +- case LibFunc::powl: ++ case LibFunc_powf: ++ case LibFunc_pow: ++ case LibFunc_powl: + return optimizePow(CI, Builder); +- case LibFunc::exp2l: +- case LibFunc::exp2: +- case LibFunc::exp2f: ++ case LibFunc_exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: + return optimizeExp2(CI, Builder); +- case LibFunc::fabsf: +- case LibFunc::fabs: +- case LibFunc::fabsl: ++ case LibFunc_fabsf: ++ case LibFunc_fabs: ++ case LibFunc_fabsl: + return optimizeFabs(CI, Builder); +- case LibFunc::sqrtf: +- case LibFunc::sqrt: +- case LibFunc::sqrtl: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtl: + return optimizeSqrt(CI, Builder); +- case LibFunc::ffs: +- case LibFunc::ffsl: +- case LibFunc::ffsll: ++ case LibFunc_ffs: ++ case LibFunc_ffsl: ++ case LibFunc_ffsll: + return optimizeFFS(CI, Builder); +- case LibFunc::abs: +- case LibFunc::labs: +- case LibFunc::llabs: ++ case LibFunc_abs: ++ case LibFunc_labs: ++ case LibFunc_llabs: + return optimizeAbs(CI, Builder); +- case LibFunc::isdigit: ++ case LibFunc_isdigit: + return optimizeIsDigit(CI, Builder); +- case LibFunc::isascii: ++ case LibFunc_isascii: + return optimizeIsAscii(CI, Builder); +- case LibFunc::toascii: ++ case LibFunc_toascii: + return optimizeToAscii(CI, Builder); +- case LibFunc::printf: ++ case LibFunc_printf: + return optimizePrintF(CI, Builder); +- case LibFunc::sprintf: ++ case LibFunc_sprintf: + return optimizeSPrintF(CI, Builder); +- case LibFunc::fprintf: ++ case LibFunc_fprintf: + return optimizeFPrintF(CI, Builder); +- case LibFunc::fwrite: ++ case LibFunc_fwrite: + return optimizeFWrite(CI, Builder); +- case LibFunc::fputs: ++ case LibFunc_fputs: + return optimizeFPuts(CI, Builder); +- case LibFunc::log: +- case LibFunc::log10: +- case LibFunc::log1p: +- case LibFunc::log2: +- case LibFunc::logb: ++ case LibFunc_log: ++ case LibFunc_log10: ++ case LibFunc_log1p: ++ case LibFunc_log2: ++ case LibFunc_logb: + return optimizeLog(CI, Builder); +- case LibFunc::puts: ++ case LibFunc_puts: + return optimizePuts(CI, Builder); +- case LibFunc::tan: +- case LibFunc::tanf: +- case LibFunc::tanl: ++ case LibFunc_tan: ++ case LibFunc_tanf: ++ case LibFunc_tanl: + return optimizeTan(CI, Builder); +- case LibFunc::perror: ++ case LibFunc_perror: + return optimizeErrorReporting(CI, Builder); +- case LibFunc::vfprintf: +- case LibFunc::fiprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_fiprintf: + return optimizeErrorReporting(CI, Builder, 0); +- case LibFunc::fputc: ++ case LibFunc_fputc: + return optimizeErrorReporting(CI, Builder, 1); +- case LibFunc::ceil: +- case LibFunc::floor: +- case LibFunc::rint: +- case LibFunc::round: +- case LibFunc::nearbyint: +- case LibFunc::trunc: ++ case LibFunc_ceil: ++ case LibFunc_floor: ++ case LibFunc_rint: ++ case LibFunc_round: ++ case LibFunc_nearbyint: ++ case LibFunc_trunc: + if (hasFloatVersion(FuncName)) + return optimizeUnaryDoubleFP(CI, Builder, false); + return nullptr; +- case LibFunc::acos: +- case LibFunc::acosh: +- case LibFunc::asin: +- case LibFunc::asinh: +- case LibFunc::atan: +- case LibFunc::atanh: +- case LibFunc::cbrt: +- case LibFunc::cosh: +- case LibFunc::exp: +- case LibFunc::exp10: +- case LibFunc::expm1: +- case LibFunc::sin: +- case LibFunc::sinh: +- case LibFunc::tanh: ++ case LibFunc_acos: ++ case LibFunc_acosh: ++ case LibFunc_asin: ++ case LibFunc_asinh: ++ case LibFunc_atan: ++ case LibFunc_atanh: ++ case LibFunc_cbrt: ++ case LibFunc_cosh: ++ case LibFunc_exp: ++ case LibFunc_exp10: ++ case LibFunc_expm1: ++ case LibFunc_sin: ++ case LibFunc_sinh: ++ case LibFunc_tanh: + if (UnsafeFPShrink && hasFloatVersion(FuncName)) + return optimizeUnaryDoubleFP(CI, Builder, true); + return nullptr; +- case LibFunc::copysign: ++ case LibFunc_copysign: + if (hasFloatVersion(FuncName)) + return optimizeBinaryDoubleFP(CI, Builder); + return nullptr; +- case LibFunc::fminf: +- case LibFunc::fmin: +- case LibFunc::fminl: +- case LibFunc::fmaxf: +- case LibFunc::fmax: +- case LibFunc::fmaxl: ++ case LibFunc_fminf: ++ case LibFunc_fmin: ++ case LibFunc_fminl: ++ case LibFunc_fmaxf: ++ case LibFunc_fmax: ++ case LibFunc_fmaxl: + return optimizeFMinFMax(CI, Builder); + default: + return nullptr; +@@ -2242,7 +2242,7 @@ Value *FortifiedLibCallSimplifier::optimizeMemSetChk(CallInst *CI, + + Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + IRBuilder<> &B, +- LibFunc::Func Func) { ++ LibFunc Func) { + Function *Callee = CI->getCalledFunction(); + StringRef Name = Callee->getName(); + const DataLayout &DL = CI->getModule()->getDataLayout(); +@@ -2250,7 +2250,7 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + *ObjSize = CI->getArgOperand(2); + + // __stpcpy_chk(x,x,...) -> x+strlen(x) +- if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { ++ if (Func == LibFunc_stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { + Value *StrLen = emitStrLen(Src, B, DL, TLI); + return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr; + } +@@ -2276,14 +2276,14 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + Value *Ret = emitMemCpyChk(Dst, Src, LenV, ObjSize, B, DL, TLI); + // If the function was an __stpcpy_chk, and we were able to fold it into + // a __memcpy_chk, we still need to return the correct end pointer. +- if (Ret && Func == LibFunc::stpcpy_chk) ++ if (Ret && Func == LibFunc_stpcpy_chk) + return B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(SizeTTy, Len - 1)); + return Ret; + } + + Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(CallInst *CI, + IRBuilder<> &B, +- LibFunc::Func Func) { ++ LibFunc Func) { + Function *Callee = CI->getCalledFunction(); + StringRef Name = Callee->getName(); + if (isFortifiedCallFoldable(CI, 3, 2, false)) { +@@ -2308,7 +2308,7 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) { + // + // PR23093. + +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + + SmallVector OpBundles; +@@ -2326,17 +2326,17 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) { + return nullptr; + + switch (Func) { +- case LibFunc::memcpy_chk: ++ case LibFunc_memcpy_chk: + return optimizeMemCpyChk(CI, Builder); +- case LibFunc::memmove_chk: ++ case LibFunc_memmove_chk: + return optimizeMemMoveChk(CI, Builder); +- case LibFunc::memset_chk: ++ case LibFunc_memset_chk: + return optimizeMemSetChk(CI, Builder); +- case LibFunc::stpcpy_chk: +- case LibFunc::strcpy_chk: ++ case LibFunc_stpcpy_chk: ++ case LibFunc_strcpy_chk: + return optimizeStrpCpyChk(CI, Builder, Func); +- case LibFunc::stpncpy_chk: +- case LibFunc::strncpy_chk: ++ case LibFunc_stpncpy_chk: ++ case LibFunc_strncpy_chk: + return optimizeStrpNCpyChk(CI, Builder, Func); + default: + break; diff --git a/deps/patches/llvm-D28476-musl-targetlibraryinfo_4.0.patch b/deps/patches/llvm-D28476-musl-targetlibraryinfo_4.0.patch new file mode 100644 index 0000000000000..96da9b768d134 --- /dev/null +++ b/deps/patches/llvm-D28476-musl-targetlibraryinfo_4.0.patch @@ -0,0 +1,4480 @@ +commit fb2d72885243ce2c1c4b7db559d1ae72fa85b792 +Author: David L. Jones +Date: Mon Jan 23 23:16:46 2017 +0000 + + [Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC) + + Summary: + The LibFunc::Func enum holds enumerators named for libc functions. + Unfortunately, there are real situations, including libc implementations, where + function names are actually macros (musl uses "#define fopen64 fopen", for + example; any other transitively visible macro would have similar effects). + + Strictly speaking, a conforming C++ Standard Library should provide any such + macros as functions instead (via ). However, there are some "library" + functions which are not part of the standard, and thus not subject to this + rule (fopen64, for example). So, in order to be both portable and consistent, + the enum should not use the bare function names. + + The old enum naming used a namespace LibFunc and an enum Func, with bare + enumerators. This patch changes LibFunc to be an enum with enumerators prefixed + with "LibFFunc_". (Unfortunately, a scoped enum is not sufficient to override + macros.) + + There are additional changes required in clang. + + Reviewers: rsmith + + Subscribers: mehdi_amini, mzolotukhin, nemanjai, llvm-commits + + Differential Revision: https://reviews.llvm.org/D28476 + + git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292848 91177308-0d34-0410-b5e6-96231b3b80d8 + +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def +index 5d5e5b127e6..637fc7ed30d 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.def ++++ b/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) LibFunc_##enum_variant, + #define TLI_DEFINE_STRING_INTERNAL(string_repr) + #else + #define TLI_DEFINE_ENUM_INTERNAL(enum_variant) +diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h +index 8675882431d..944250cfd6a 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.h ++++ b/include/llvm/Analysis/TargetLibraryInfo.h +@@ -30,14 +30,12 @@ struct VecDesc { + unsigned VectorizationFactor; + }; + +- namespace LibFunc { +- enum Func { ++ enum LibFunc { + #define TLI_DEFINE_ENUM + #include "llvm/Analysis/TargetLibraryInfo.def" + +- NumLibFuncs +- }; +- } ++ NumLibFuncs ++ }; + + /// Implementation of the target library information. + /// +@@ -48,9 +46,9 @@ struct VecDesc { + class TargetLibraryInfoImpl { + friend class TargetLibraryInfo; + +- unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4]; ++ unsigned char AvailableArray[(NumLibFuncs+3)/4]; + llvm::DenseMap CustomNames; +- static StringRef const StandardNames[LibFunc::NumLibFuncs]; ++ static StringRef const StandardNames[NumLibFuncs]; + bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param; + + enum AvailabilityState { +@@ -58,11 +56,11 @@ class TargetLibraryInfoImpl { + CustomName = 1, + Unavailable = 0 // (memset to all zeros) + }; +- void setState(LibFunc::Func F, AvailabilityState State) { ++ void setState(LibFunc F, AvailabilityState State) { + AvailableArray[F/4] &= ~(3 << 2*(F&3)); + AvailableArray[F/4] |= State << 2*(F&3); + } +- AvailabilityState getState(LibFunc::Func F) const { ++ AvailabilityState getState(LibFunc F) const { + return static_cast((AvailableArray[F/4] >> 2*(F&3)) & 3); + } + +@@ -74,7 +72,7 @@ class TargetLibraryInfoImpl { + + /// Return true if the function type FTy is valid for the library function + /// F, regardless of whether the function is available. +- bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc::Func F, ++ bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F, + const DataLayout *DL) const; + + public: +@@ -104,28 +102,28 @@ public: + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(StringRef funcName, LibFunc::Func &F) const; ++ bool getLibFunc(StringRef funcName, LibFunc &F) const; + + /// Searches for a particular function name, also checking that its type is + /// valid for the library function matching that name. + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const; ++ bool getLibFunc(const Function &FDecl, LibFunc &F) const; + + /// Forces a function to be marked as unavailable. +- void setUnavailable(LibFunc::Func F) { ++ void setUnavailable(LibFunc F) { + setState(F, Unavailable); + } + + /// Forces a function to be marked as available. +- void setAvailable(LibFunc::Func F) { ++ void setAvailable(LibFunc F) { + setState(F, StandardName); + } + + /// Forces a function to be marked as available and provide an alternate name + /// that must be used. +- void setAvailableWithName(LibFunc::Func F, StringRef Name) { ++ void setAvailableWithName(LibFunc F, StringRef Name) { + if (StandardNames[F] != Name) { + setState(F, CustomName); + CustomNames[F] = Name; +@@ -225,16 +223,16 @@ public: + /// + /// If it is one of the known library functions, return true and set F to the + /// corresponding value. +- bool getLibFunc(StringRef funcName, LibFunc::Func &F) const { ++ bool getLibFunc(StringRef funcName, LibFunc &F) const { + return Impl->getLibFunc(funcName, F); + } + +- bool getLibFunc(const Function &FDecl, LibFunc::Func &F) const { ++ bool getLibFunc(const Function &FDecl, LibFunc &F) const { + return Impl->getLibFunc(FDecl, F); + } + + /// Tests whether a library function is available. +- bool has(LibFunc::Func F) const { ++ bool has(LibFunc F) const { + return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable; + } + bool isFunctionVectorizable(StringRef F, unsigned VF) const { +@@ -249,37 +247,37 @@ public: + + /// Tests if the function is both available and a candidate for optimized code + /// generation. +- bool hasOptimizedCodeGen(LibFunc::Func F) const { ++ bool hasOptimizedCodeGen(LibFunc F) const { + if (Impl->getState(F) == TargetLibraryInfoImpl::Unavailable) + return false; + switch (F) { + default: break; +- case LibFunc::copysign: case LibFunc::copysignf: case LibFunc::copysignl: +- case LibFunc::fabs: case LibFunc::fabsf: case LibFunc::fabsl: +- case LibFunc::sin: case LibFunc::sinf: case LibFunc::sinl: +- case LibFunc::cos: case LibFunc::cosf: case LibFunc::cosl: +- case LibFunc::sqrt: case LibFunc::sqrtf: case LibFunc::sqrtl: +- case LibFunc::sqrt_finite: case LibFunc::sqrtf_finite: +- case LibFunc::sqrtl_finite: +- case LibFunc::fmax: case LibFunc::fmaxf: case LibFunc::fmaxl: +- case LibFunc::fmin: case LibFunc::fminf: case LibFunc::fminl: +- case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl: +- case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl: +- case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill: +- case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl: +- case LibFunc::round: case LibFunc::roundf: case LibFunc::roundl: +- case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: +- case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: +- case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: +- case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: +- case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen: +- case LibFunc::memchr: case LibFunc::mempcpy: ++ case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl: ++ case LibFunc_fabs: case LibFunc_fabsf: case LibFunc_fabsl: ++ case LibFunc_sin: case LibFunc_sinf: case LibFunc_sinl: ++ case LibFunc_cos: case LibFunc_cosf: case LibFunc_cosl: ++ case LibFunc_sqrt: case LibFunc_sqrtf: case LibFunc_sqrtl: ++ case LibFunc_sqrt_finite: case LibFunc_sqrtf_finite: ++ case LibFunc_sqrtl_finite: ++ case LibFunc_fmax: case LibFunc_fmaxf: case LibFunc_fmaxl: ++ case LibFunc_fmin: case LibFunc_fminf: case LibFunc_fminl: ++ case LibFunc_floor: case LibFunc_floorf: case LibFunc_floorl: ++ case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_nearbyintl: ++ case LibFunc_ceil: case LibFunc_ceilf: case LibFunc_ceill: ++ case LibFunc_rint: case LibFunc_rintf: case LibFunc_rintl: ++ case LibFunc_round: case LibFunc_roundf: case LibFunc_roundl: ++ case LibFunc_trunc: case LibFunc_truncf: case LibFunc_truncl: ++ case LibFunc_log2: case LibFunc_log2f: case LibFunc_log2l: ++ case LibFunc_exp2: case LibFunc_exp2f: case LibFunc_exp2l: ++ case LibFunc_memcmp: case LibFunc_strcmp: case LibFunc_strcpy: ++ case LibFunc_stpcpy: case LibFunc_strlen: case LibFunc_strnlen: ++ case LibFunc_memchr: case LibFunc_mempcpy: + return true; + } + return false; + } + +- StringRef getName(LibFunc::Func F) const { ++ StringRef getName(LibFunc F) const { + auto State = Impl->getState(F); + if (State == TargetLibraryInfoImpl::Unavailable) + return StringRef(); +diff --git a/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/include/llvm/Transforms/Utils/SimplifyLibCalls.h +index 5e217adf198..fbeea5bd95e 100644 +--- a/include/llvm/Transforms/Utils/SimplifyLibCalls.h ++++ b/include/llvm/Transforms/Utils/SimplifyLibCalls.h +@@ -56,8 +56,8 @@ private: + Value *optimizeMemSetChk(CallInst *CI, IRBuilder<> &B); + + // Str/Stp cpy are similar enough to be handled in the same functions. +- Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func); +- Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func); ++ Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func); ++ Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc Func); + + /// \brief Checks whether the call \p CI to a fortified libcall is foldable + /// to the non-fortified version. +diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp +index c8d05794949..55f40a34839 100644 +--- a/lib/Analysis/BasicAliasAnalysis.cpp ++++ b/lib/Analysis/BasicAliasAnalysis.cpp +@@ -644,9 +644,9 @@ static bool isWriteOnlyParam(ImmutableCallSite CS, unsigned ArgIdx, + // whenever possible. + // FIXME Consider handling this in InferFunctionAttr.cpp together with other + // attributes. +- LibFunc::Func F; ++ LibFunc F; + if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) && +- F == LibFunc::memset_pattern16 && TLI.has(F)) ++ F == LibFunc_memset_pattern16 && TLI.has(F)) + if (ArgIdx == 0) + return true; + +diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp +index 73867279abe..1bd51f62a43 100644 +--- a/lib/Analysis/ConstantFolding.cpp ++++ b/lib/Analysis/ConstantFolding.cpp +@@ -1637,51 +1637,51 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + + switch (Name[0]) { + case 'a': +- if ((Name == "acos" && TLI->has(LibFunc::acos)) || +- (Name == "acosf" && TLI->has(LibFunc::acosf))) ++ if ((Name == "acos" && TLI->has(LibFunc_acos)) || ++ (Name == "acosf" && TLI->has(LibFunc_acosf))) + return ConstantFoldFP(acos, V, Ty); +- else if ((Name == "asin" && TLI->has(LibFunc::asin)) || +- (Name == "asinf" && TLI->has(LibFunc::asinf))) ++ else if ((Name == "asin" && TLI->has(LibFunc_asin)) || ++ (Name == "asinf" && TLI->has(LibFunc_asinf))) + return ConstantFoldFP(asin, V, Ty); +- else if ((Name == "atan" && TLI->has(LibFunc::atan)) || +- (Name == "atanf" && TLI->has(LibFunc::atanf))) ++ else if ((Name == "atan" && TLI->has(LibFunc_atan)) || ++ (Name == "atanf" && TLI->has(LibFunc_atanf))) + return ConstantFoldFP(atan, V, Ty); + break; + case 'c': +- if ((Name == "ceil" && TLI->has(LibFunc::ceil)) || +- (Name == "ceilf" && TLI->has(LibFunc::ceilf))) ++ if ((Name == "ceil" && TLI->has(LibFunc_ceil)) || ++ (Name == "ceilf" && TLI->has(LibFunc_ceilf))) + return ConstantFoldFP(ceil, V, Ty); +- else if ((Name == "cos" && TLI->has(LibFunc::cos)) || +- (Name == "cosf" && TLI->has(LibFunc::cosf))) ++ else if ((Name == "cos" && TLI->has(LibFunc_cos)) || ++ (Name == "cosf" && TLI->has(LibFunc_cosf))) + return ConstantFoldFP(cos, V, Ty); +- else if ((Name == "cosh" && TLI->has(LibFunc::cosh)) || +- (Name == "coshf" && TLI->has(LibFunc::coshf))) ++ else if ((Name == "cosh" && TLI->has(LibFunc_cosh)) || ++ (Name == "coshf" && TLI->has(LibFunc_coshf))) + return ConstantFoldFP(cosh, V, Ty); + break; + case 'e': +- if ((Name == "exp" && TLI->has(LibFunc::exp)) || +- (Name == "expf" && TLI->has(LibFunc::expf))) ++ if ((Name == "exp" && TLI->has(LibFunc_exp)) || ++ (Name == "expf" && TLI->has(LibFunc_expf))) + return ConstantFoldFP(exp, V, Ty); +- if ((Name == "exp2" && TLI->has(LibFunc::exp2)) || +- (Name == "exp2f" && TLI->has(LibFunc::exp2f))) ++ if ((Name == "exp2" && TLI->has(LibFunc_exp2)) || ++ (Name == "exp2f" && TLI->has(LibFunc_exp2f))) + // Constant fold exp2(x) as pow(2,x) in case the host doesn't have a + // C99 library. + return ConstantFoldBinaryFP(pow, 2.0, V, Ty); + break; + case 'f': +- if ((Name == "fabs" && TLI->has(LibFunc::fabs)) || +- (Name == "fabsf" && TLI->has(LibFunc::fabsf))) ++ if ((Name == "fabs" && TLI->has(LibFunc_fabs)) || ++ (Name == "fabsf" && TLI->has(LibFunc_fabsf))) + return ConstantFoldFP(fabs, V, Ty); +- else if ((Name == "floor" && TLI->has(LibFunc::floor)) || +- (Name == "floorf" && TLI->has(LibFunc::floorf))) ++ else if ((Name == "floor" && TLI->has(LibFunc_floor)) || ++ (Name == "floorf" && TLI->has(LibFunc_floorf))) + return ConstantFoldFP(floor, V, Ty); + break; + case 'l': +- if ((Name == "log" && V > 0 && TLI->has(LibFunc::log)) || +- (Name == "logf" && V > 0 && TLI->has(LibFunc::logf))) ++ if ((Name == "log" && V > 0 && TLI->has(LibFunc_log)) || ++ (Name == "logf" && V > 0 && TLI->has(LibFunc_logf))) + return ConstantFoldFP(log, V, Ty); +- else if ((Name == "log10" && V > 0 && TLI->has(LibFunc::log10)) || +- (Name == "log10f" && V > 0 && TLI->has(LibFunc::log10f))) ++ else if ((Name == "log10" && V > 0 && TLI->has(LibFunc_log10)) || ++ (Name == "log10f" && V > 0 && TLI->has(LibFunc_log10f))) + return ConstantFoldFP(log10, V, Ty); + else if (IntrinsicID == Intrinsic::sqrt && + (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())) { +@@ -1698,26 +1698,26 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + } + break; + case 'r': +- if ((Name == "round" && TLI->has(LibFunc::round)) || +- (Name == "roundf" && TLI->has(LibFunc::roundf))) ++ if ((Name == "round" && TLI->has(LibFunc_round)) || ++ (Name == "roundf" && TLI->has(LibFunc_roundf))) + return ConstantFoldFP(round, V, Ty); + case 's': +- if ((Name == "sin" && TLI->has(LibFunc::sin)) || +- (Name == "sinf" && TLI->has(LibFunc::sinf))) ++ if ((Name == "sin" && TLI->has(LibFunc_sin)) || ++ (Name == "sinf" && TLI->has(LibFunc_sinf))) + return ConstantFoldFP(sin, V, Ty); +- else if ((Name == "sinh" && TLI->has(LibFunc::sinh)) || +- (Name == "sinhf" && TLI->has(LibFunc::sinhf))) ++ else if ((Name == "sinh" && TLI->has(LibFunc_sinh)) || ++ (Name == "sinhf" && TLI->has(LibFunc_sinhf))) + return ConstantFoldFP(sinh, V, Ty); +- else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc::sqrt)) || +- (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc::sqrtf))) ++ else if ((Name == "sqrt" && V >= 0 && TLI->has(LibFunc_sqrt)) || ++ (Name == "sqrtf" && V >= 0 && TLI->has(LibFunc_sqrtf))) + return ConstantFoldFP(sqrt, V, Ty); + break; + case 't': +- if ((Name == "tan" && TLI->has(LibFunc::tan)) || +- (Name == "tanf" && TLI->has(LibFunc::tanf))) ++ if ((Name == "tan" && TLI->has(LibFunc_tan)) || ++ (Name == "tanf" && TLI->has(LibFunc_tanf))) + return ConstantFoldFP(tan, V, Ty); +- else if ((Name == "tanh" && TLI->has(LibFunc::tanh)) || +- (Name == "tanhf" && TLI->has(LibFunc::tanhf))) ++ else if ((Name == "tanh" && TLI->has(LibFunc_tanh)) || ++ (Name == "tanhf" && TLI->has(LibFunc_tanhf))) + return ConstantFoldFP(tanh, V, Ty); + break; + default: +@@ -1822,14 +1822,14 @@ Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty, + + if (!TLI) + return nullptr; +- if ((Name == "pow" && TLI->has(LibFunc::pow)) || +- (Name == "powf" && TLI->has(LibFunc::powf))) ++ if ((Name == "pow" && TLI->has(LibFunc_pow)) || ++ (Name == "powf" && TLI->has(LibFunc_powf))) + return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); +- if ((Name == "fmod" && TLI->has(LibFunc::fmod)) || +- (Name == "fmodf" && TLI->has(LibFunc::fmodf))) ++ if ((Name == "fmod" && TLI->has(LibFunc_fmod)) || ++ (Name == "fmodf" && TLI->has(LibFunc_fmodf))) + return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty); +- if ((Name == "atan2" && TLI->has(LibFunc::atan2)) || +- (Name == "atan2f" && TLI->has(LibFunc::atan2f))) ++ if ((Name == "atan2" && TLI->has(LibFunc_atan2)) || ++ (Name == "atan2f" && TLI->has(LibFunc_atan2f))) + return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty); + } else if (auto *Op2C = dyn_cast(Operands[1])) { + if (IntrinsicID == Intrinsic::powi && Ty->isHalfTy()) +@@ -2022,7 +2022,7 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + if (!F) + return false; + +- LibFunc::Func Func; ++ LibFunc Func; + if (!TLI || !TLI->getLibFunc(*F, Func)) + return false; + +@@ -2030,20 +2030,20 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + 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_logl: ++ case LibFunc_log: ++ case LibFunc_logf: ++ case LibFunc_log2l: ++ case LibFunc_log2: ++ case LibFunc_log2f: ++ case LibFunc_log10l: ++ case LibFunc_log10: ++ case LibFunc_log10f: + return Op.isNaN() || (!Op.isZero() && !Op.isNegative()); + +- case LibFunc::expl: +- case LibFunc::exp: +- case LibFunc::expf: ++ case LibFunc_expl: ++ case LibFunc_exp: ++ case LibFunc_expf: + // FIXME: These boundaries are slightly conservative. + if (OpC->getType()->isDoubleTy()) + return Op.compare(APFloat(-745.0)) != APFloat::cmpLessThan && +@@ -2053,9 +2053,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + Op.compare(APFloat(88.0f)) != APFloat::cmpGreaterThan; + break; + +- case LibFunc::exp2l: +- case LibFunc::exp2: +- case LibFunc::exp2f: ++ case LibFunc_exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: + // FIXME: These boundaries are slightly conservative. + if (OpC->getType()->isDoubleTy()) + return Op.compare(APFloat(-1074.0)) != APFloat::cmpLessThan && +@@ -2065,17 +2065,17 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + Op.compare(APFloat(127.0f)) != APFloat::cmpGreaterThan; + break; + +- case LibFunc::sinl: +- case LibFunc::sin: +- case LibFunc::sinf: +- case LibFunc::cosl: +- case LibFunc::cos: +- case LibFunc::cosf: ++ case LibFunc_sinl: ++ case LibFunc_sin: ++ case LibFunc_sinf: ++ case LibFunc_cosl: ++ case LibFunc_cos: ++ case LibFunc_cosf: + return !Op.isInfinity(); + +- case LibFunc::tanl: +- case LibFunc::tan: +- case LibFunc::tanf: { ++ case LibFunc_tanl: ++ case LibFunc_tan: ++ case LibFunc_tanf: { + // FIXME: Stop using the host math library. + // FIXME: The computation isn't done in the right precision. + Type *Ty = OpC->getType(); +@@ -2086,23 +2086,23 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + break; + } + +- case LibFunc::asinl: +- case LibFunc::asin: +- case LibFunc::asinf: +- case LibFunc::acosl: +- case LibFunc::acos: +- case LibFunc::acosf: ++ case LibFunc_asinl: ++ case LibFunc_asin: ++ case LibFunc_asinf: ++ case LibFunc_acosl: ++ case LibFunc_acos: ++ case LibFunc_acosf: + return Op.compare(APFloat(Op.getSemantics(), "-1")) != + APFloat::cmpLessThan && + Op.compare(APFloat(Op.getSemantics(), "1")) != + APFloat::cmpGreaterThan; + +- case LibFunc::sinh: +- case LibFunc::cosh: +- case LibFunc::sinhf: +- case LibFunc::coshf: +- case LibFunc::sinhl: +- case LibFunc::coshl: ++ case LibFunc_sinh: ++ case LibFunc_cosh: ++ case LibFunc_sinhf: ++ case LibFunc_coshf: ++ case LibFunc_sinhl: ++ case LibFunc_coshl: + // FIXME: These boundaries are slightly conservative. + if (OpC->getType()->isDoubleTy()) + return Op.compare(APFloat(-710.0)) != APFloat::cmpLessThan && +@@ -2112,9 +2112,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + Op.compare(APFloat(89.0f)) != APFloat::cmpGreaterThan; + break; + +- case LibFunc::sqrtl: +- case LibFunc::sqrt: +- case LibFunc::sqrtf: ++ case LibFunc_sqrtl: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: + return Op.isNaN() || Op.isZero() || !Op.isNegative(); + + // FIXME: Add more functions: sqrt_finite, atanh, expm1, log1p, +@@ -2133,9 +2133,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + const APFloat &Op1 = Op1C->getValueAPF(); + + switch (Func) { +- case LibFunc::powl: +- case LibFunc::pow: +- case LibFunc::powf: { ++ case LibFunc_powl: ++ case LibFunc_pow: ++ case LibFunc_powf: { + // FIXME: Stop using the host math library. + // FIXME: The computation isn't done in the right precision. + Type *Ty = Op0C->getType(); +@@ -2149,9 +2149,9 @@ bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) { + break; + } + +- case LibFunc::fmodl: +- case LibFunc::fmod: +- case LibFunc::fmodf: ++ case LibFunc_fmodl: ++ case LibFunc_fmod: ++ case LibFunc_fmodf: + return Op0.isNaN() || Op1.isNaN() || + (!Op0.isInfinity() && !Op1.isZero()); + +diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp +index 2d8274040d3..e9d27b5e367 100644 +--- a/lib/Analysis/MemoryBuiltins.cpp ++++ b/lib/Analysis/MemoryBuiltins.cpp +@@ -50,30 +50,30 @@ struct AllocFnsTy { + + // FIXME: certain users need more information. E.g., SimplifyLibCalls needs to + // know which functions are nounwind, noalias, nocapture parameters, etc. +-static const std::pair 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[] = { ++ {LibFunc_malloc, {MallocLike, 1, 0, -1}}, ++ {LibFunc_valloc, {MallocLike, 1, 0, -1}}, ++ {LibFunc_Znwj, {OpNewLike, 1, 0, -1}}, // new(unsigned int) ++ {LibFunc_ZnwjRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) ++ {LibFunc_Znwm, {OpNewLike, 1, 0, -1}}, // new(unsigned long) ++ {LibFunc_ZnwmRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new(unsigned long, nothrow) ++ {LibFunc_Znaj, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) ++ {LibFunc_ZnajRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) ++ {LibFunc_Znam, {OpNewLike, 1, 0, -1}}, // new[](unsigned long) ++ {LibFunc_ZnamRKSt9nothrow_t, {MallocLike, 2, 0, -1}}, // new[](unsigned long, nothrow) ++ {LibFunc_msvc_new_int, {OpNewLike, 1, 0, -1}}, // new(unsigned int) ++ {LibFunc_msvc_new_int_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned int, nothrow) ++ {LibFunc_msvc_new_longlong, {OpNewLike, 1, 0, -1}}, // new(unsigned long long) ++ {LibFunc_msvc_new_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new(unsigned long long, nothrow) ++ {LibFunc_msvc_new_array_int, {OpNewLike, 1, 0, -1}}, // new[](unsigned int) ++ {LibFunc_msvc_new_array_int_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned int, nothrow) ++ {LibFunc_msvc_new_array_longlong, {OpNewLike, 1, 0, -1}}, // new[](unsigned long long) ++ {LibFunc_msvc_new_array_longlong_nothrow, {MallocLike, 2, 0, -1}}, // new[](unsigned long long, nothrow) ++ {LibFunc_calloc, {CallocLike, 2, 0, 1}}, ++ {LibFunc_realloc, {ReallocLike, 2, 1, -1}}, ++ {LibFunc_reallocf, {ReallocLike, 2, 1, -1}}, ++ {LibFunc_strdup, {StrDupLike, 1, -1, -1}}, ++ {LibFunc_strndup, {StrDupLike, 2, 1, -1}} + // TODO: Handle "int posix_memalign(void **, size_t, size_t)" + }; + +@@ -106,12 +106,12 @@ getAllocationDataForFunction(const Function *Callee, AllocType AllocTy, + const TargetLibraryInfo *TLI) { + // Make sure that the function is available. + StringRef FnName = Callee->getName(); +- LibFunc::Func TLIFn; ++ LibFunc TLIFn; + if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn)) + return None; + + const auto *Iter = find_if( +- AllocationFnData, [TLIFn](const std::pair &P) { ++ AllocationFnData, [TLIFn](const std::pair &P) { + return P.first == TLIFn; + }); + +@@ -333,33 +333,33 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) { + return nullptr; + + StringRef FnName = Callee->getName(); +- LibFunc::Func TLIFn; ++ LibFunc TLIFn; + if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn)) + return nullptr; + + unsigned ExpectedNumParams; +- if (TLIFn == LibFunc::free || +- TLIFn == LibFunc::ZdlPv || // operator delete(void*) +- TLIFn == LibFunc::ZdaPv || // operator delete[](void*) +- TLIFn == LibFunc::msvc_delete_ptr32 || // operator delete(void*) +- TLIFn == LibFunc::msvc_delete_ptr64 || // operator delete(void*) +- TLIFn == LibFunc::msvc_delete_array_ptr32 || // operator delete[](void*) +- TLIFn == LibFunc::msvc_delete_array_ptr64) // operator delete[](void*) ++ if (TLIFn == LibFunc_free || ++ TLIFn == LibFunc_ZdlPv || // operator delete(void*) ++ TLIFn == LibFunc_ZdaPv || // operator delete[](void*) ++ TLIFn == LibFunc_msvc_delete_ptr32 || // operator delete(void*) ++ TLIFn == LibFunc_msvc_delete_ptr64 || // operator delete(void*) ++ TLIFn == LibFunc_msvc_delete_array_ptr32 || // operator delete[](void*) ++ TLIFn == LibFunc_msvc_delete_array_ptr64) // operator delete[](void*) + ExpectedNumParams = 1; +- else if (TLIFn == LibFunc::ZdlPvj || // delete(void*, uint) +- TLIFn == LibFunc::ZdlPvm || // delete(void*, ulong) +- TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) +- TLIFn == LibFunc::ZdaPvj || // delete[](void*, uint) +- TLIFn == LibFunc::ZdaPvm || // delete[](void*, ulong) +- TLIFn == LibFunc::ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow) +- TLIFn == LibFunc::msvc_delete_ptr32_int || // delete(void*, uint) +- TLIFn == LibFunc::msvc_delete_ptr64_longlong || // delete(void*, ulonglong) +- TLIFn == LibFunc::msvc_delete_ptr32_nothrow || // delete(void*, nothrow) +- TLIFn == LibFunc::msvc_delete_ptr64_nothrow || // delete(void*, nothrow) +- TLIFn == LibFunc::msvc_delete_array_ptr32_int || // delete[](void*, uint) +- TLIFn == LibFunc::msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong) +- TLIFn == LibFunc::msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow) +- TLIFn == LibFunc::msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow) ++ else if (TLIFn == LibFunc_ZdlPvj || // delete(void*, uint) ++ TLIFn == LibFunc_ZdlPvm || // delete(void*, ulong) ++ TLIFn == LibFunc_ZdlPvRKSt9nothrow_t || // delete(void*, nothrow) ++ TLIFn == LibFunc_ZdaPvj || // delete[](void*, uint) ++ TLIFn == LibFunc_ZdaPvm || // delete[](void*, ulong) ++ TLIFn == LibFunc_ZdaPvRKSt9nothrow_t || // delete[](void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_ptr32_int || // delete(void*, uint) ++ TLIFn == LibFunc_msvc_delete_ptr64_longlong || // delete(void*, ulonglong) ++ TLIFn == LibFunc_msvc_delete_ptr32_nothrow || // delete(void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_ptr64_nothrow || // delete(void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_array_ptr32_int || // delete[](void*, uint) ++ TLIFn == LibFunc_msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong) ++ TLIFn == LibFunc_msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow) ++ TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow) + ExpectedNumParams = 2; + else + return nullptr; +diff --git a/lib/Analysis/MemoryLocation.cpp b/lib/Analysis/MemoryLocation.cpp +index a0ae72f1415..9db6c499129 100644 +--- a/lib/Analysis/MemoryLocation.cpp ++++ b/lib/Analysis/MemoryLocation.cpp +@@ -142,9 +142,9 @@ MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS, + // for memcpy/memset. This is particularly important because the + // LoopIdiomRecognizer likes to turn loops into calls to memset_pattern16 + // whenever possible. +- LibFunc::Func F; ++ LibFunc F; + if (CS.getCalledFunction() && TLI.getLibFunc(*CS.getCalledFunction(), F) && +- F == LibFunc::memset_pattern16 && TLI.has(F)) { ++ F == LibFunc_memset_pattern16 && TLI.has(F)) { + assert((ArgIdx == 0 || ArgIdx == 1) && + "Invalid argument index for memset_pattern16"); + if (ArgIdx == 1) +diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp +index 450901aca7d..775abfd18c1 100644 +--- a/lib/Analysis/TargetLibraryInfo.cpp ++++ b/lib/Analysis/TargetLibraryInfo.cpp +@@ -82,24 +82,24 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + + 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(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); + } + + // 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(LibFunc_memcpy); ++ TLI.setUnavailable(LibFunc_memset); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + return; + } + +@@ -107,21 +107,21 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // All versions of watchOS support it. + if (T.isMacOSX()) { + if (T.isMacOSXVersionLT(10, 5)) +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + } else if (T.isiOS()) { + if (T.isOSVersionLT(3, 0)) +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_memset_pattern16); + } else if (!T.isWatchOS()) { +- TLI.setUnavailable(LibFunc::memset_pattern16); ++ TLI.setUnavailable(LibFunc_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(LibFunc_sinpi); ++ TLI.setUnavailable(LibFunc_sinpif); ++ TLI.setUnavailable(LibFunc_cospi); ++ TLI.setUnavailable(LibFunc_cospif); ++ TLI.setUnavailable(LibFunc_sincospi_stret); ++ TLI.setUnavailable(LibFunc_sincospif_stret); + } + + if (T.isMacOSX() && T.getArch() == Triple::x86 && +@@ -131,179 +131,179 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_fwrite, "fwrite$UNIX2003"); ++ TLI.setAvailableWithName(LibFunc_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(LibFunc_iprintf); ++ TLI.setUnavailable(LibFunc_siprintf); ++ TLI.setUnavailable(LibFunc_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(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); + + // 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(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); + + // Win32 provides some C99 math with mangled names +- TLI.setAvailableWithName(LibFunc::copysign, "_copysign"); ++ TLI.setAvailableWithName(LibFunc_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(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); + } + + // 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(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); + + // 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(LibFunc_atoll); ++ TLI.setUnavailable(LibFunc_frexpf); ++ TLI.setUnavailable(LibFunc_llabs); + } + + switch (T.getOS()) { +@@ -311,28 +311,28 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_exp10l); + if (T.isMacOSXVersionLT(10, 9)) { +- TLI.setUnavailable(LibFunc::exp10); +- TLI.setUnavailable(LibFunc::exp10f); ++ TLI.setUnavailable(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); + } else { +- TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); +- TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); ++ TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); ++ TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); + } + break; + case Triple::IOS: + case Triple::TvOS: + case Triple::WatchOS: +- TLI.setUnavailable(LibFunc::exp10l); ++ TLI.setUnavailable(LibFunc_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(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); + } else { +- TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); +- TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); ++ TLI.setAvailableWithName(LibFunc_exp10, "__exp10"); ++ TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f"); + } + break; + case Triple::Linux: +@@ -344,9 +344,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // Fall through to disable all of them. + LLVM_FALLTHROUGH; + default: +- TLI.setUnavailable(LibFunc::exp10); +- TLI.setUnavailable(LibFunc::exp10f); +- TLI.setUnavailable(LibFunc::exp10l); ++ TLI.setUnavailable(LibFunc_exp10); ++ TLI.setUnavailable(LibFunc_exp10f); ++ TLI.setUnavailable(LibFunc_exp10l); + } + + // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and +@@ -364,7 +364,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + case Triple::Linux: + break; + default: +- TLI.setUnavailable(LibFunc::ffsl); ++ TLI.setUnavailable(LibFunc_ffsl); + } + + // ffsll is available on at least FreeBSD and Linux (GLIBC): +@@ -380,7 +380,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + case Triple::Linux: + break; + default: +- TLI.setUnavailable(LibFunc::ffsll); ++ TLI.setUnavailable(LibFunc_ffsll); + } + + // The following functions are available on at least FreeBSD: +@@ -388,30 +388,30 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // 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(LibFunc_fls); ++ TLI.setUnavailable(LibFunc_flsl); ++ TLI.setUnavailable(LibFunc_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(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); + } + + // As currently implemented in clang, NVPTX code has no standard library to +@@ -427,9 +427,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, + // optimizations, so this situation should be fixed. + if (T.isNVPTX()) { + TLI.disableAllFunctions(); +- TLI.setAvailable(LibFunc::nvvm_reflect); ++ TLI.setAvailable(LibFunc_nvvm_reflect); + } else { +- TLI.setUnavailable(LibFunc::nvvm_reflect); ++ TLI.setUnavailable(LibFunc_nvvm_reflect); + } + + TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary); +@@ -500,9 +500,9 @@ static StringRef sanitizeFunctionName(StringRef funcName) { + } + + 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 @@ bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName, + 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,493 +531,493 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, + unsigned NumParams = FTy.getNumParams(); + + switch (F) { +- case LibFunc::strlen: ++ case LibFunc_strlen: + return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() && + FTy.getReturnType()->isIntegerTy()); + +- case LibFunc::strchr: +- case LibFunc::strrchr: ++ case LibFunc_strchr: ++ case LibFunc_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 LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + return ((NumParams == 2 || NumParams == 3) && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::strcat: ++ case LibFunc_strcat: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0) == FTy.getReturnType() && + FTy.getParamType(1) == FTy.getReturnType()); + +- case LibFunc::strncat: ++ case LibFunc_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 LibFunc_strcpy_chk: ++ case LibFunc_stpcpy_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + LLVM_FALLTHROUGH; +- case LibFunc::strcpy: +- case LibFunc::stpcpy: ++ case LibFunc_strcpy: ++ case LibFunc_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 LibFunc_strncpy_chk: ++ case LibFunc_stpncpy_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + LLVM_FALLTHROUGH; +- case LibFunc::strncpy: +- case LibFunc::stpncpy: ++ case LibFunc_strncpy: ++ case LibFunc_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 LibFunc_strxfrm: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(0) == FTy.getParamType(1)); + +- case LibFunc::strncmp: ++ case LibFunc_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 LibFunc_strspn: ++ case LibFunc_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 LibFunc_strcoll: ++ case LibFunc_strcasecmp: ++ case LibFunc_strncasecmp: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strstr: ++ case LibFunc_strstr: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::strpbrk: ++ case LibFunc_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 LibFunc_strtok: ++ case LibFunc_strtok_r: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::scanf: +- case LibFunc::setbuf: +- case LibFunc::setvbuf: ++ case LibFunc_scanf: ++ case LibFunc_setbuf: ++ case LibFunc_setvbuf: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::strdup: +- case LibFunc::strndup: ++ case LibFunc_strdup: ++ case LibFunc_strndup: + return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::sscanf: +- case LibFunc::stat: +- case LibFunc::statvfs: +- case LibFunc::sprintf: ++ case LibFunc_sscanf: ++ case LibFunc_stat: ++ case LibFunc_statvfs: ++ case LibFunc_sprintf: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::snprintf: ++ case LibFunc_snprintf: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::setitimer: ++ case LibFunc_setitimer: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::system: ++ case LibFunc_system: + return (NumParams == 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::malloc: ++ case LibFunc_malloc: + return (NumParams == 1 && FTy.getReturnType()->isPointerTy()); +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy() && + FTy.getReturnType()->isIntegerTy(32)); + +- case LibFunc::memchr: +- case LibFunc::memrchr: ++ case LibFunc_memchr: ++ case LibFunc_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 LibFunc_modf: ++ case LibFunc_modff: ++ case LibFunc_modfl: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); + +- case LibFunc::memcpy_chk: +- case LibFunc::memmove_chk: ++ case LibFunc_memcpy_chk: ++ case LibFunc_memmove_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + LLVM_FALLTHROUGH; +- case LibFunc::memcpy: +- case LibFunc::mempcpy: +- case LibFunc::memmove: ++ case LibFunc_memcpy: ++ case LibFunc_mempcpy: ++ case LibFunc_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 LibFunc_memset_chk: + --NumParams; + if (!IsSizeTTy(FTy.getParamType(NumParams))) + return false; + LLVM_FALLTHROUGH; +- case LibFunc::memset: ++ case LibFunc_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 LibFunc_memccpy: + return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::memalign: ++ case LibFunc_memalign: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::realloc: ++ case LibFunc_realloc: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getReturnType()->isPointerTy()); +- case LibFunc::read: ++ case LibFunc_read: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::rewind: +- case LibFunc::rmdir: +- case LibFunc::remove: +- case LibFunc::realpath: ++ case LibFunc_rewind: ++ case LibFunc_rmdir: ++ case LibFunc_remove: ++ case LibFunc_realpath: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::rename: ++ case LibFunc_rename: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::readlink: ++ case LibFunc_readlink: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::write: ++ case LibFunc_write: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::bcopy: +- case LibFunc::bcmp: ++ case LibFunc_bcopy: ++ case LibFunc_bcmp: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::bzero: ++ case LibFunc_bzero: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::calloc: ++ case LibFunc_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 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: + 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 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: + return (NumParams != 0 && FTy.getParamType(0)->isPointerTy()); + +- case LibFunc::access: ++ case LibFunc_access: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::fopen: ++ case LibFunc_fopen: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fdopen: ++ case LibFunc_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 LibFunc_fputc: ++ case LibFunc_fstat: ++ case LibFunc_frexp: ++ case LibFunc_frexpf: ++ case LibFunc_frexpl: ++ case LibFunc_fstatvfs: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fgets: ++ case LibFunc_fgets: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::fread: ++ case LibFunc_fread: + return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(3)->isPointerTy()); +- case LibFunc::fwrite: ++ case LibFunc_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 LibFunc_fputs: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fscanf: +- case LibFunc::fprintf: ++ case LibFunc_fscanf: ++ case LibFunc_fprintf: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fgetpos: ++ case LibFunc_fgetpos: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::gets: +- case LibFunc::getchar: +- case LibFunc::getitimer: ++ case LibFunc_gets: ++ case LibFunc_getchar: ++ case LibFunc_getitimer: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::ungetc: ++ case LibFunc_ungetc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::utime: +- case LibFunc::utimes: ++ case LibFunc_utime: ++ case LibFunc_utimes: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::putc: ++ case LibFunc_putc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::pread: +- case LibFunc::pwrite: ++ case LibFunc_pread: ++ case LibFunc_pwrite: + return (NumParams == 4 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::popen: ++ case LibFunc_popen: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vscanf: ++ case LibFunc_vscanf: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vsscanf: ++ case LibFunc_vsscanf: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::vfscanf: ++ case LibFunc_vfscanf: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::valloc: ++ case LibFunc_valloc: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::vprintf: ++ case LibFunc_vprintf: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::vfprintf: +- case LibFunc::vsprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_vsprintf: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::vsnprintf: ++ case LibFunc_vsnprintf: + return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(2)->isPointerTy()); +- case LibFunc::open: ++ case LibFunc_open: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::opendir: ++ case LibFunc_opendir: + return (NumParams == 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::tmpfile: ++ case LibFunc_tmpfile: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::htonl: +- case LibFunc::htons: +- case LibFunc::ntohl: +- case LibFunc::ntohs: +- case LibFunc::lstat: ++ case LibFunc_htonl: ++ case LibFunc_htons: ++ case LibFunc_ntohl: ++ case LibFunc_ntohs: ++ case LibFunc_lstat: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::lchown: ++ case LibFunc_lchown: + return (NumParams == 3 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::qsort: ++ case LibFunc_qsort: + return (NumParams == 4 && FTy.getParamType(3)->isPointerTy()); +- case LibFunc::dunder_strdup: +- case LibFunc::dunder_strndup: ++ case LibFunc_dunder_strdup: ++ case LibFunc_dunder_strndup: + return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy()); +- case LibFunc::dunder_strtok_r: ++ case LibFunc_dunder_strtok_r: + return (NumParams == 3 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::under_IO_putc: ++ case LibFunc_under_IO_putc: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::dunder_isoc99_scanf: ++ case LibFunc_dunder_isoc99_scanf: + return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::stat64: +- case LibFunc::lstat64: +- case LibFunc::statvfs64: ++ case LibFunc_stat64: ++ case LibFunc_lstat64: ++ case LibFunc_statvfs64: + return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::dunder_isoc99_sscanf: ++ case LibFunc_dunder_isoc99_sscanf: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::fopen64: ++ case LibFunc_fopen64: + return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && + FTy.getParamType(0)->isPointerTy() && + FTy.getParamType(1)->isPointerTy()); +- case LibFunc::tmpfile64: ++ case LibFunc_tmpfile64: + return (FTy.getReturnType()->isPointerTy()); +- case LibFunc::fstat64: +- case LibFunc::fstatvfs64: ++ case LibFunc_fstat64: ++ case LibFunc_fstatvfs64: + return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); +- case LibFunc::open64: ++ case LibFunc_open64: + return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy()); +- case LibFunc::gettimeofday: ++ case LibFunc_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 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); + return (NumParams == 1); + +- case LibFunc::memset_pattern16: ++ case LibFunc_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 LibFunc_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::log1p: +- 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 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_log1p: ++ 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: + 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 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: + 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 LibFunc_ffs: ++ case LibFunc_ffsl: ++ case LibFunc_ffsll: ++ case LibFunc_fls: ++ case LibFunc_flsl: ++ case LibFunc_flsll: + return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && + FTy.getParamType(0)->isIntegerTy()); + +- case LibFunc::isdigit: +- case LibFunc::isascii: +- case LibFunc::toascii: ++ case LibFunc_isdigit: ++ case LibFunc_isascii: ++ case LibFunc_toascii: + return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) && + FTy.getReturnType() == FTy.getParamType(0)); + +- case LibFunc::abs: +- case LibFunc::labs: +- case LibFunc::llabs: ++ case LibFunc_abs: ++ case LibFunc_labs: ++ case LibFunc_llabs: + return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +- case LibFunc::cxa_atexit: ++ case LibFunc_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 LibFunc_sinpi: ++ case LibFunc_cospi: + return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +- case LibFunc::sinpif: +- case LibFunc::cospif: ++ case LibFunc_sinpif: ++ case LibFunc_cospif: + return (NumParams == 1 && FTy.getReturnType()->isFloatTy() && + FTy.getReturnType() == FTy.getParamType(0)); + +@@ -1029,7 +1029,7 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, + } + + 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) && +diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp +index b79370baad1..55f1e676a74 100644 +--- a/lib/Analysis/ValueTracking.cpp ++++ b/lib/Analysis/ValueTracking.cpp +@@ -2436,7 +2436,7 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS, + if (!TLI) + return Intrinsic::not_intrinsic; + +- LibFunc::Func Func; ++ LibFunc Func; + // We're going to make assumptions on the semantics of the functions, check + // that the target knows that it's available in this environment and it does + // not have local linkage. +@@ -2451,81 +2451,81 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS, + switch (Func) { + default: + break; +- case LibFunc::sin: +- case LibFunc::sinf: +- case LibFunc::sinl: ++ case LibFunc_sin: ++ case LibFunc_sinf: ++ case LibFunc_sinl: + return Intrinsic::sin; +- case LibFunc::cos: +- case LibFunc::cosf: +- case LibFunc::cosl: ++ case LibFunc_cos: ++ case LibFunc_cosf: ++ case LibFunc_cosl: + return Intrinsic::cos; +- case LibFunc::exp: +- case LibFunc::expf: +- case LibFunc::expl: ++ case LibFunc_exp: ++ case LibFunc_expf: ++ case LibFunc_expl: + return Intrinsic::exp; +- case LibFunc::exp2: +- case LibFunc::exp2f: +- case LibFunc::exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: ++ case LibFunc_exp2l: + return Intrinsic::exp2; +- case LibFunc::log: +- case LibFunc::logf: +- case LibFunc::logl: ++ case LibFunc_log: ++ case LibFunc_logf: ++ case LibFunc_logl: + return Intrinsic::log; +- case LibFunc::log10: +- case LibFunc::log10f: +- case LibFunc::log10l: ++ case LibFunc_log10: ++ case LibFunc_log10f: ++ case LibFunc_log10l: + return Intrinsic::log10; +- case LibFunc::log2: +- case LibFunc::log2f: +- case LibFunc::log2l: ++ case LibFunc_log2: ++ case LibFunc_log2f: ++ case LibFunc_log2l: + return Intrinsic::log2; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + return Intrinsic::fabs; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + return Intrinsic::minnum; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + return Intrinsic::maxnum; +- case LibFunc::copysign: +- case LibFunc::copysignf: +- case LibFunc::copysignl: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: ++ case LibFunc_copysignl: + return Intrinsic::copysign; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + return Intrinsic::floor; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + return Intrinsic::ceil; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + return Intrinsic::trunc; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + return Intrinsic::rint; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + return Intrinsic::nearbyint; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + return Intrinsic::round; +- case LibFunc::pow: +- case LibFunc::powf: +- case LibFunc::powl: ++ case LibFunc_pow: ++ case LibFunc_powf: ++ case LibFunc_powl: + return Intrinsic::pow; +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: + if (ICS->hasNoNaNs()) + return Intrinsic::sqrt; + return Intrinsic::not_intrinsic; +diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp +index 62de8bf2015..cb1a5ce8be1 100644 +--- a/lib/CodeGen/SelectionDAG/FastISel.cpp ++++ b/lib/CodeGen/SelectionDAG/FastISel.cpp +@@ -1364,7 +1364,7 @@ bool FastISel::selectInstruction(const Instruction *I) { + + 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. +diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +index 95e31a3eaf6..5dad37cd5a1 100644 +--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp ++++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +@@ -6334,15 +6334,15 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { + // Check for well-known libc/libm calls. If the function is internal, it + // can't be a library call. Don't do the check if marked as nobuiltin for + // some reason. +- LibFunc::Func Func; ++ LibFunc Func; + if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() && + LibInfo->getLibFunc(F->getName(), Func) && + LibInfo->hasOptimizedCodeGen(Func)) { + switch (Func) { + default: break; +- case LibFunc::copysign: +- case LibFunc::copysignf: +- case LibFunc::copysignl: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: ++ case LibFunc_copysignl: + if (I.getNumArgOperands() == 2 && // Basic sanity checks. + I.getArgOperand(0)->getType()->isFloatingPointTy() && + I.getType() == I.getArgOperand(0)->getType() && +@@ -6355,122 +6355,122 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { + return; + } + break; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + if (visitUnaryFloatCall(I, ISD::FABS)) + return; + break; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + if (visitBinaryFloatCall(I, ISD::FMINNUM)) + return; + break; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + if (visitBinaryFloatCall(I, ISD::FMAXNUM)) + return; + break; +- case LibFunc::sin: +- case LibFunc::sinf: +- case LibFunc::sinl: ++ case LibFunc_sin: ++ case LibFunc_sinf: ++ case LibFunc_sinl: + if (visitUnaryFloatCall(I, ISD::FSIN)) + return; + break; +- case LibFunc::cos: +- case LibFunc::cosf: +- case LibFunc::cosl: ++ case LibFunc_cos: ++ case LibFunc_cosf: ++ case LibFunc_cosl: + if (visitUnaryFloatCall(I, ISD::FCOS)) + return; + break; +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: +- case LibFunc::sqrt_finite: +- case LibFunc::sqrtf_finite: +- case LibFunc::sqrtl_finite: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: ++ case LibFunc_sqrt_finite: ++ case LibFunc_sqrtf_finite: ++ case LibFunc_sqrtl_finite: + if (visitUnaryFloatCall(I, ISD::FSQRT)) + return; + break; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + if (visitUnaryFloatCall(I, ISD::FFLOOR)) + return; + break; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + if (visitUnaryFloatCall(I, ISD::FNEARBYINT)) + return; + break; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + if (visitUnaryFloatCall(I, ISD::FCEIL)) + return; + break; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + if (visitUnaryFloatCall(I, ISD::FRINT)) + return; + break; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + if (visitUnaryFloatCall(I, ISD::FROUND)) + return; + break; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + if (visitUnaryFloatCall(I, ISD::FTRUNC)) + return; + break; +- case LibFunc::log2: +- case LibFunc::log2f: +- case LibFunc::log2l: ++ case LibFunc_log2: ++ case LibFunc_log2f: ++ case LibFunc_log2l: + if (visitUnaryFloatCall(I, ISD::FLOG2)) + return; + break; +- case LibFunc::exp2: +- case LibFunc::exp2f: +- case LibFunc::exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: ++ case LibFunc_exp2l: + if (visitUnaryFloatCall(I, ISD::FEXP2)) + return; + break; +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + if (visitMemCmpCall(I)) + return; + break; +- case LibFunc::mempcpy: ++ case LibFunc_mempcpy: + if (visitMemPCpyCall(I)) + return; + break; +- case LibFunc::memchr: ++ case LibFunc_memchr: + if (visitMemChrCall(I)) + return; + break; +- case LibFunc::strcpy: ++ case LibFunc_strcpy: + if (visitStrCpyCall(I, false)) + return; + break; +- case LibFunc::stpcpy: ++ case LibFunc_stpcpy: + if (visitStrCpyCall(I, true)) + return; + break; +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + if (visitStrCmpCall(I)) + return; + break; +- case LibFunc::strlen: ++ case LibFunc_strlen: + if (visitStrLenCall(I)) + return; + break; +- case LibFunc::strnlen: ++ case LibFunc_strnlen: + if (visitStrNLenCall(I)) + return; + break; +diff --git a/lib/LTO/UpdateCompilerUsed.cpp b/lib/LTO/UpdateCompilerUsed.cpp +index b67d9ea5989..5165cc96503 100644 +--- a/lib/LTO/UpdateCompilerUsed.cpp ++++ b/lib/LTO/UpdateCompilerUsed.cpp +@@ -65,7 +65,7 @@ private: + // 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)); + } +diff --git a/lib/Target/PowerPC/PPCCTRLoops.cpp b/lib/Target/PowerPC/PPCCTRLoops.cpp +index 2c62a0f1d90..197be8b7db9 100644 +--- a/lib/Target/PowerPC/PPCCTRLoops.cpp ++++ b/lib/Target/PowerPC/PPCCTRLoops.cpp +@@ -315,7 +315,7 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { + // (i.e. soft float or atomics). If adapting for targets that do, + // additional care is required here. + +- LibFunc::Func Func; ++ LibFunc Func; + if (!F->hasLocalLinkage() && F->hasName() && LibInfo && + LibInfo->getLibFunc(F->getName(), Func) && + LibInfo->hasOptimizedCodeGen(Func)) { +@@ -329,50 +329,50 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { + + switch (Func) { + default: return true; +- case LibFunc::copysign: +- case LibFunc::copysignf: ++ case LibFunc_copysign: ++ case LibFunc_copysignf: + continue; // ISD::FCOPYSIGN is never a library call. +- case LibFunc::copysignl: ++ case LibFunc_copysignl: + return true; +- case LibFunc::fabs: +- case LibFunc::fabsf: +- case LibFunc::fabsl: ++ case LibFunc_fabs: ++ case LibFunc_fabsf: ++ case LibFunc_fabsl: + continue; // ISD::FABS is never a library call. +- case LibFunc::sqrt: +- case LibFunc::sqrtf: +- case LibFunc::sqrtl: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrtl: + Opcode = ISD::FSQRT; break; +- case LibFunc::floor: +- case LibFunc::floorf: +- case LibFunc::floorl: ++ case LibFunc_floor: ++ case LibFunc_floorf: ++ case LibFunc_floorl: + Opcode = ISD::FFLOOR; break; +- case LibFunc::nearbyint: +- case LibFunc::nearbyintf: +- case LibFunc::nearbyintl: ++ case LibFunc_nearbyint: ++ case LibFunc_nearbyintf: ++ case LibFunc_nearbyintl: + Opcode = ISD::FNEARBYINT; break; +- case LibFunc::ceil: +- case LibFunc::ceilf: +- case LibFunc::ceill: ++ case LibFunc_ceil: ++ case LibFunc_ceilf: ++ case LibFunc_ceill: + Opcode = ISD::FCEIL; break; +- case LibFunc::rint: +- case LibFunc::rintf: +- case LibFunc::rintl: ++ case LibFunc_rint: ++ case LibFunc_rintf: ++ case LibFunc_rintl: + Opcode = ISD::FRINT; break; +- case LibFunc::round: +- case LibFunc::roundf: +- case LibFunc::roundl: ++ case LibFunc_round: ++ case LibFunc_roundf: ++ case LibFunc_roundl: + Opcode = ISD::FROUND; break; +- case LibFunc::trunc: +- case LibFunc::truncf: +- case LibFunc::truncl: ++ case LibFunc_trunc: ++ case LibFunc_truncf: ++ case LibFunc_truncl: + Opcode = ISD::FTRUNC; break; +- case LibFunc::fmin: +- case LibFunc::fminf: +- case LibFunc::fminl: ++ case LibFunc_fmin: ++ case LibFunc_fminf: ++ case LibFunc_fminl: + Opcode = ISD::FMINNUM; break; +- case LibFunc::fmax: +- case LibFunc::fmaxf: +- case LibFunc::fmaxl: ++ case LibFunc_fmax: ++ case LibFunc_fmaxf: ++ case LibFunc_fmaxl: + Opcode = ISD::FMAXNUM; break; + } + } +diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp +index 5b0d5e3bc01..484fdbed0cb 100644 +--- a/lib/Transforms/IPO/GlobalOpt.cpp ++++ b/lib/Transforms/IPO/GlobalOpt.cpp +@@ -2387,7 +2387,7 @@ OptimizeGlobalAliases(Module &M, + } + + static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) { +- LibFunc::Func F = LibFunc::cxa_atexit; ++ LibFunc F = LibFunc_cxa_atexit; + if (!TLI->has(F)) + return nullptr; + +@@ -2396,7 +2396,7 @@ static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) { + return nullptr; + + // Make sure that the function has the correct prototype. +- if (!TLI->getLibFunc(*Fn, F) || F != LibFunc::cxa_atexit) ++ if (!TLI->getLibFunc(*Fn, F) || F != LibFunc_cxa_atexit) + return nullptr; + + return Fn; +diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp +index 4d4c3baef3f..a1e995aca22 100644 +--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp ++++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp +@@ -135,13 +135,13 @@ static bool hasMemoryWrite(Instruction *I, const TargetLibraryInfo &TLI) { + if (auto CS = CallSite(I)) { + if (Function *F = CS.getCalledFunction()) { + StringRef FnName = F->getName(); +- if (TLI.has(LibFunc::strcpy) && FnName == TLI.getName(LibFunc::strcpy)) ++ if (TLI.has(LibFunc_strcpy) && FnName == TLI.getName(LibFunc_strcpy)) + return true; +- if (TLI.has(LibFunc::strncpy) && FnName == TLI.getName(LibFunc::strncpy)) ++ if (TLI.has(LibFunc_strncpy) && FnName == TLI.getName(LibFunc_strncpy)) + return true; +- if (TLI.has(LibFunc::strcat) && FnName == TLI.getName(LibFunc::strcat)) ++ if (TLI.has(LibFunc_strcat) && FnName == TLI.getName(LibFunc_strcat)) + return true; +- if (TLI.has(LibFunc::strncat) && FnName == TLI.getName(LibFunc::strncat)) ++ if (TLI.has(LibFunc_strncat) && FnName == TLI.getName(LibFunc_strncat)) + return true; + } + } +diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +index 5fec51c095d..d509f2928b1 100644 +--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp ++++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +@@ -236,9 +236,9 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L) { + ApplyCodeSizeHeuristics = + L->getHeader()->getParent()->optForSize() && UseLIRCodeSizeHeurs; + +- HasMemset = TLI->has(LibFunc::memset); +- HasMemsetPattern = TLI->has(LibFunc::memset_pattern16); +- HasMemcpy = TLI->has(LibFunc::memcpy); ++ HasMemset = TLI->has(LibFunc_memset); ++ HasMemsetPattern = TLI->has(LibFunc_memset_pattern16); ++ HasMemcpy = TLI->has(LibFunc_memcpy); + + if (HasMemset || HasMemsetPattern || HasMemcpy) + if (SE->hasLoopInvariantBackedgeTakenCount(L)) +diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp +index 8355f952e31..b84f4780442 100644 +--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp ++++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp +@@ -1240,7 +1240,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M) { + bool MemCpyOptPass::processMemMove(MemMoveInst *M) { + AliasAnalysis &AA = LookupAliasAnalysis(); + +- if (!TLI->has(LibFunc::memmove)) ++ if (!TLI->has(LibFunc_memmove)) + return false; + + // See if the pointers alias. +@@ -1419,7 +1419,7 @@ bool MemCpyOptPass::runImpl( + // If we don't have at least memset and memcpy, there is little point of doing + // anything here. These are required by a freestanding implementation, so if + // even they are disabled, there is no point in trying hard. +- if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy)) ++ if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy)) + return false; + + while (1) { +diff --git a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +index 1a7ddc9585b..5494356a60b 100644 +--- a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp ++++ b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +@@ -98,14 +98,14 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI, + + // Skip if function either has local linkage or is not a known library + // function. +- LibFunc::Func LibFunc; ++ LibFunc LF; + if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() || +- !TLI->getLibFunc(CalledFunc->getName(), LibFunc)) ++ !TLI->getLibFunc(CalledFunc->getName(), LF)) + continue; + +- switch (LibFunc) { +- case LibFunc::sqrtf: +- case LibFunc::sqrt: ++ switch (LF) { ++ case LibFunc_sqrtf: ++ case LibFunc_sqrt: + if (TTI->haveFastSqrt(Call->getType()) && + optimizeSQRT(Call, CalledFunc, *CurrBB, BB)) + break; +diff --git a/lib/Transforms/Utils/BuildLibCalls.cpp b/lib/Transforms/Utils/BuildLibCalls.cpp +index e61b04fbdd5..4f6bfcfe524 100644 +--- a/lib/Transforms/Utils/BuildLibCalls.cpp ++++ b/lib/Transforms/Utils/BuildLibCalls.cpp +@@ -107,255 +107,255 @@ static bool setNonNull(Function &F, unsigned n) { + } + + bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { +- LibFunc::Func TheLibFunc; ++ LibFunc TheLibFunc; + if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc))) + return false; + + bool Changed = false; + switch (TheLibFunc) { +- case LibFunc::strlen: ++ case LibFunc_strlen: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::strchr: +- case LibFunc::strrchr: ++ case LibFunc_strchr: ++ case LibFunc_strrchr: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::strtol: +- case LibFunc::strtod: +- case LibFunc::strtof: +- case LibFunc::strtoul: +- case LibFunc::strtoll: +- case LibFunc::strtold: +- case LibFunc::strtoull: ++ case LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::strcpy: +- case LibFunc::stpcpy: +- case LibFunc::strcat: +- case LibFunc::strncat: +- case LibFunc::strncpy: +- case LibFunc::stpncpy: ++ case LibFunc_strcpy: ++ case LibFunc_stpcpy: ++ case LibFunc_strcat: ++ case LibFunc_strncat: ++ case LibFunc_strncpy: ++ case LibFunc_stpncpy: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::strxfrm: ++ case LibFunc_strxfrm: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::strcmp: // 0,1 +- case LibFunc::strspn: // 0,1 +- case LibFunc::strncmp: // 0,1 +- case LibFunc::strcspn: // 0,1 +- case LibFunc::strcoll: // 0,1 +- case LibFunc::strcasecmp: // 0,1 +- case LibFunc::strncasecmp: // ++ case LibFunc_strcmp: // 0,1 ++ case LibFunc_strspn: // 0,1 ++ case LibFunc_strncmp: // 0,1 ++ case LibFunc_strcspn: // 0,1 ++ case LibFunc_strcoll: // 0,1 ++ case LibFunc_strcasecmp: // 0,1 ++ case LibFunc_strncasecmp: // + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::strstr: +- case LibFunc::strpbrk: ++ case LibFunc_strstr: ++ case LibFunc_strpbrk: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::strtok: +- case LibFunc::strtok_r: ++ case LibFunc_strtok: ++ case LibFunc_strtok_r: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::scanf: ++ case LibFunc_scanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::setbuf: +- case LibFunc::setvbuf: ++ case LibFunc_setbuf: ++ case LibFunc_setvbuf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::strdup: +- case LibFunc::strndup: ++ case LibFunc_strdup: ++ case LibFunc_strndup: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::stat: +- case LibFunc::statvfs: ++ case LibFunc_stat: ++ case LibFunc_statvfs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::sscanf: ++ case LibFunc_sscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::sprintf: ++ case LibFunc_sprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::snprintf: ++ case LibFunc_snprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 3); + return Changed; +- case LibFunc::setitimer: ++ case LibFunc_setitimer: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::system: ++ case LibFunc_system: + // May throw; "system" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::malloc: ++ case LibFunc_malloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::memchr: +- case LibFunc::memrchr: ++ case LibFunc_memchr: ++ case LibFunc_memrchr: + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::modf: +- case LibFunc::modff: +- case LibFunc::modfl: ++ case LibFunc_modf: ++ case LibFunc_modff: ++ case LibFunc_modfl: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::memcpy: +- case LibFunc::mempcpy: +- case LibFunc::memccpy: +- case LibFunc::memmove: ++ case LibFunc_memcpy: ++ case LibFunc_mempcpy: ++ case LibFunc_memccpy: ++ case LibFunc_memmove: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::memcpy_chk: ++ case LibFunc_memcpy_chk: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::memalign: ++ case LibFunc_memalign: + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::mkdir: ++ case LibFunc_mkdir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::mktime: ++ case LibFunc_mktime: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::realloc: ++ case LibFunc_realloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::read: ++ case LibFunc_read: + // May throw; "read" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::rewind: ++ case LibFunc_rewind: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::rmdir: +- case LibFunc::remove: +- case LibFunc::realpath: ++ case LibFunc_rmdir: ++ case LibFunc_remove: ++ case LibFunc_realpath: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::rename: ++ case LibFunc_rename: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::readlink: ++ case LibFunc_readlink: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::write: ++ case LibFunc_write: + // May throw; "write" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::bcopy: ++ case LibFunc_bcopy: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::bcmp: ++ case LibFunc_bcmp: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::bzero: ++ case LibFunc_bzero: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::calloc: ++ case LibFunc_calloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::chmod: +- case LibFunc::chown: ++ case LibFunc_chmod: ++ case LibFunc_chown: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::ctermid: +- case LibFunc::clearerr: +- case LibFunc::closedir: ++ case LibFunc_ctermid: ++ case LibFunc_clearerr: ++ case LibFunc_closedir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::atoi: +- case LibFunc::atol: +- case LibFunc::atof: +- case LibFunc::atoll: ++ case LibFunc_atoi: ++ case LibFunc_atol: ++ case LibFunc_atof: ++ case LibFunc_atoll: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::access: ++ case LibFunc_access: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::fopen: ++ case LibFunc_fopen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -363,150 +363,150 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fdopen: ++ case LibFunc_fdopen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::feof: +- case LibFunc::free: +- case LibFunc::fseek: +- case LibFunc::ftell: +- case LibFunc::fgetc: +- case LibFunc::fseeko: +- case LibFunc::ftello: +- case LibFunc::fileno: +- case LibFunc::fflush: +- case LibFunc::fclose: +- case LibFunc::fsetpos: +- case LibFunc::flockfile: +- case LibFunc::funlockfile: +- case LibFunc::ftrylockfile: ++ case LibFunc_feof: ++ case LibFunc_free: ++ case LibFunc_fseek: ++ case LibFunc_ftell: ++ case LibFunc_fgetc: ++ case LibFunc_fseeko: ++ case LibFunc_ftello: ++ case LibFunc_fileno: ++ case LibFunc_fflush: ++ case LibFunc_fclose: ++ case LibFunc_fsetpos: ++ case LibFunc_flockfile: ++ case LibFunc_funlockfile: ++ case LibFunc_ftrylockfile: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::ferror: ++ case LibFunc_ferror: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F); + return Changed; +- case LibFunc::fputc: +- case LibFunc::fstat: +- case LibFunc::frexp: +- case LibFunc::frexpf: +- case LibFunc::frexpl: +- case LibFunc::fstatvfs: ++ case LibFunc_fputc: ++ case LibFunc_fstat: ++ case LibFunc_frexp: ++ case LibFunc_frexpf: ++ case LibFunc_frexpl: ++ case LibFunc_fstatvfs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::fgets: ++ case LibFunc_fgets: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 3); + return Changed; +- case LibFunc::fread: ++ case LibFunc_fread: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 4); + return Changed; +- case LibFunc::fwrite: ++ case LibFunc_fwrite: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 4); + // FIXME: readonly #1? + return Changed; +- case LibFunc::fputs: ++ case LibFunc_fputs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::fscanf: +- case LibFunc::fprintf: ++ case LibFunc_fscanf: ++ case LibFunc_fprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fgetpos: ++ case LibFunc_fgetpos: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::getc: +- case LibFunc::getlogin_r: +- case LibFunc::getc_unlocked: ++ case LibFunc_getc: ++ case LibFunc_getlogin_r: ++ case LibFunc_getc_unlocked: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::getenv: ++ case LibFunc_getenv: + Changed |= setDoesNotThrow(F); + Changed |= setOnlyReadsMemory(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::gets: +- case LibFunc::getchar: ++ case LibFunc_gets: ++ case LibFunc_getchar: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::getitimer: ++ case LibFunc_getitimer: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::getpwnam: ++ case LibFunc_getpwnam: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::ungetc: ++ case LibFunc_ungetc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::uname: ++ case LibFunc_uname: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::unlink: ++ case LibFunc_unlink: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::unsetenv: ++ case LibFunc_unsetenv: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::utime: +- case LibFunc::utimes: ++ case LibFunc_utime: ++ case LibFunc_utimes: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::putc: ++ case LibFunc_putc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::puts: +- case LibFunc::printf: +- case LibFunc::perror: ++ case LibFunc_puts: ++ case LibFunc_printf: ++ case LibFunc_perror: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::pread: ++ case LibFunc_pread: + // May throw; "pread" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::pwrite: ++ case LibFunc_pwrite: + // May throw; "pwrite" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::putchar: ++ case LibFunc_putchar: + Changed |= setDoesNotThrow(F); + return Changed; +- case LibFunc::popen: ++ case LibFunc_popen: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -514,132 +514,132 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::pclose: ++ case LibFunc_pclose: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::vscanf: ++ case LibFunc_vscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::vsscanf: ++ case LibFunc_vsscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::vfscanf: ++ case LibFunc_vfscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::valloc: ++ case LibFunc_valloc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::vprintf: ++ case LibFunc_vprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::vfprintf: +- case LibFunc::vsprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_vsprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::vsnprintf: ++ case LibFunc_vsnprintf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 3); + Changed |= setOnlyReadsMemory(F, 3); + return Changed; +- case LibFunc::open: ++ case LibFunc_open: + // May throw; "open" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::opendir: ++ case LibFunc_opendir: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::tmpfile: ++ case LibFunc_tmpfile: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::times: ++ case LibFunc_times: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::htonl: +- case LibFunc::htons: +- case LibFunc::ntohl: +- case LibFunc::ntohs: ++ case LibFunc_htonl: ++ case LibFunc_htons: ++ case LibFunc_ntohl: ++ case LibFunc_ntohs: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAccessMemory(F); + return Changed; +- case LibFunc::lstat: ++ case LibFunc_lstat: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::lchown: ++ case LibFunc_lchown: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::qsort: ++ case LibFunc_qsort: + // May throw; places call through function pointer. + Changed |= setDoesNotCapture(F, 4); + return Changed; +- case LibFunc::dunder_strdup: +- case LibFunc::dunder_strndup: ++ case LibFunc_dunder_strdup: ++ case LibFunc_dunder_strndup: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::dunder_strtok_r: ++ case LibFunc_dunder_strtok_r: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::under_IO_getc: ++ case LibFunc_under_IO_getc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::under_IO_putc: ++ case LibFunc_under_IO_putc: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::dunder_isoc99_scanf: ++ case LibFunc_dunder_isoc99_scanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::stat64: +- case LibFunc::lstat64: +- case LibFunc::statvfs64: ++ case LibFunc_stat64: ++ case LibFunc_lstat64: ++ case LibFunc_statvfs64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::dunder_isoc99_sscanf: ++ case LibFunc_dunder_isoc99_sscanf: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fopen64: ++ case LibFunc_fopen64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + Changed |= setDoesNotCapture(F, 1); +@@ -647,26 +647,26 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fseeko64: +- case LibFunc::ftello64: ++ case LibFunc_fseeko64: ++ case LibFunc_ftello64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 1); + return Changed; +- case LibFunc::tmpfile64: ++ case LibFunc_tmpfile64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotAlias(F, 0); + return Changed; +- case LibFunc::fstat64: +- case LibFunc::fstatvfs64: ++ case LibFunc_fstat64: ++ case LibFunc_fstatvfs64: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::open64: ++ case LibFunc_open64: + // May throw; "open" is a valid pthread cancellation point. + Changed |= setDoesNotCapture(F, 1); + Changed |= setOnlyReadsMemory(F, 1); + return Changed; +- case LibFunc::gettimeofday: ++ case LibFunc_gettimeofday: + // Currently some platforms have the restrict keyword on the arguments to + // gettimeofday. To be conservative, do not add noalias to gettimeofday's + // arguments. +@@ -674,29 +674,29 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + return Changed; +- case LibFunc::Znwj: // new(unsigned int) +- case LibFunc::Znwm: // new(unsigned long) +- case LibFunc::Znaj: // new[](unsigned int) +- case LibFunc::Znam: // new[](unsigned long) +- case LibFunc::msvc_new_int: // new(unsigned int) +- case LibFunc::msvc_new_longlong: // new(unsigned long long) +- case LibFunc::msvc_new_array_int: // new[](unsigned int) +- case LibFunc::msvc_new_array_longlong: // new[](unsigned long long) ++ case LibFunc_Znwj: // new(unsigned int) ++ case LibFunc_Znwm: // new(unsigned long) ++ case LibFunc_Znaj: // new[](unsigned int) ++ case LibFunc_Znam: // new[](unsigned long) ++ case LibFunc_msvc_new_int: // new(unsigned int) ++ case LibFunc_msvc_new_longlong: // new(unsigned long long) ++ case LibFunc_msvc_new_array_int: // new[](unsigned int) ++ case LibFunc_msvc_new_array_longlong: // new[](unsigned long long) + // Operator new always returns a nonnull noalias pointer + Changed |= setNonNull(F, AttributeSet::ReturnIndex); + Changed |= setDoesNotAlias(F, AttributeSet::ReturnIndex); + return Changed; + //TODO: add LibFunc entries for: +- //case LibFunc::memset_pattern4: +- //case LibFunc::memset_pattern8: +- case LibFunc::memset_pattern16: ++ //case LibFunc_memset_pattern4: ++ //case LibFunc_memset_pattern8: ++ case LibFunc_memset_pattern16: + Changed |= setOnlyAccessesArgMemory(F); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; + // int __nvvm_reflect(const char *) +- case LibFunc::nvvm_reflect: ++ case LibFunc_nvvm_reflect: + Changed |= setDoesNotAccessMemory(F); + Changed |= setDoesNotThrow(F); + return Changed; +@@ -717,7 +717,7 @@ Value *llvm::castToCStr(Value *V, IRBuilder<> &B) { + + Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strlen)) ++ if (!TLI->has(LibFunc_strlen)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -734,7 +734,7 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, + + Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strchr)) ++ if (!TLI->has(LibFunc_strchr)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -752,7 +752,7 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B, + + Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::strncmp)) ++ if (!TLI->has(LibFunc_strncmp)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -772,7 +772,7 @@ Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + + Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, + const TargetLibraryInfo *TLI, StringRef Name) { +- if (!TLI->has(LibFunc::strcpy)) ++ if (!TLI->has(LibFunc_strcpy)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -788,7 +788,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, + + Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, + const TargetLibraryInfo *TLI, StringRef Name) { +- if (!TLI->has(LibFunc::strncpy)) ++ if (!TLI->has(LibFunc_strncpy)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -806,7 +806,7 @@ Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, + Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, + IRBuilder<> &B, const DataLayout &DL, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memcpy_chk)) ++ if (!TLI->has(LibFunc_memcpy_chk)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -828,7 +828,7 @@ Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, + + Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memchr)) ++ if (!TLI->has(LibFunc_memchr)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -847,7 +847,7 @@ Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, + + Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::memcmp)) ++ if (!TLI->has(LibFunc_memcmp)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -914,7 +914,7 @@ Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name, + + Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::putchar)) ++ if (!TLI->has(LibFunc_putchar)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -934,7 +934,7 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B, + + Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::puts)) ++ if (!TLI->has(LibFunc_puts)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -949,7 +949,7 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B, + + Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fputc)) ++ if (!TLI->has(LibFunc_fputc)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +@@ -968,11 +968,11 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B, + + Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, + const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fputs)) ++ if (!TLI->has(LibFunc_fputs)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); +- StringRef FPutsName = TLI->getName(LibFunc::fputs); ++ StringRef FPutsName = TLI->getName(LibFunc_fputs); + Constant *F = M->getOrInsertFunction( + FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType(), nullptr); + if (File->getType()->isPointerTy()) +@@ -986,12 +986,12 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B, + + Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B, + const DataLayout &DL, const TargetLibraryInfo *TLI) { +- if (!TLI->has(LibFunc::fwrite)) ++ if (!TLI->has(LibFunc_fwrite)) + return nullptr; + + Module *M = B.GetInsertBlock()->getModule(); + LLVMContext &Context = B.GetInsertBlock()->getContext(); +- StringRef FWriteName = TLI->getName(LibFunc::fwrite); ++ StringRef FWriteName = TLI->getName(LibFunc_fwrite); + Constant *F = M->getOrInsertFunction( + FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(), + DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType(), +diff --git a/lib/Transforms/Utils/LibCallsShrinkWrap.cpp b/lib/Transforms/Utils/LibCallsShrinkWrap.cpp +index d97cd7582ea..fe93d6927c6 100644 +--- a/lib/Transforms/Utils/LibCallsShrinkWrap.cpp ++++ b/lib/Transforms/Utils/LibCallsShrinkWrap.cpp +@@ -100,12 +100,12 @@ private: + bool perform(CallInst *CI); + void checkCandidate(CallInst &CI); + void shrinkWrapCI(CallInst *CI, Value *Cond); +- bool performCallDomainErrorOnly(CallInst *CI, const LibFunc::Func &Func); +- bool performCallErrors(CallInst *CI, const LibFunc::Func &Func); +- bool performCallRangeErrorOnly(CallInst *CI, const LibFunc::Func &Func); +- Value *generateOneRangeCond(CallInst *CI, const LibFunc::Func &Func); +- Value *generateTwoRangeCond(CallInst *CI, const LibFunc::Func &Func); +- Value *generateCondForPow(CallInst *CI, const LibFunc::Func &Func); ++ bool performCallDomainErrorOnly(CallInst *CI, const LibFunc &Func); ++ bool performCallErrors(CallInst *CI, const LibFunc &Func); ++ bool performCallRangeErrorOnly(CallInst *CI, const LibFunc &Func); ++ Value *generateOneRangeCond(CallInst *CI, const LibFunc &Func); ++ Value *generateTwoRangeCond(CallInst *CI, const LibFunc &Func); ++ Value *generateCondForPow(CallInst *CI, const LibFunc &Func); + + // Create an OR of two conditions. + Value *createOrCond(CallInst *CI, CmpInst::Predicate Cmp, float Val, +@@ -141,44 +141,44 @@ private: + + // Perform the transformation to calls with errno set by domain error. + bool LibCallsShrinkWrap::performCallDomainErrorOnly(CallInst *CI, +- const LibFunc::Func &Func) { ++ const LibFunc &Func) { + Value *Cond = nullptr; + + switch (Func) { +- case LibFunc::acos: // DomainError: (x < -1 || x > 1) +- case LibFunc::acosf: // Same as acos +- case LibFunc::acosl: // Same as acos +- case LibFunc::asin: // DomainError: (x < -1 || x > 1) +- case LibFunc::asinf: // Same as asin +- case LibFunc::asinl: // Same as asin ++ case LibFunc_acos: // DomainError: (x < -1 || x > 1) ++ case LibFunc_acosf: // Same as acos ++ case LibFunc_acosl: // Same as acos ++ case LibFunc_asin: // DomainError: (x < -1 || x > 1) ++ case LibFunc_asinf: // Same as asin ++ case LibFunc_asinl: // Same as asin + { + ++NumWrappedTwoCond; + Cond = createOrCond(CI, CmpInst::FCMP_OLT, -1.0f, CmpInst::FCMP_OGT, 1.0f); + break; + } +- case LibFunc::cos: // DomainError: (x == +inf || x == -inf) +- case LibFunc::cosf: // Same as cos +- case LibFunc::cosl: // Same as cos +- case LibFunc::sin: // DomainError: (x == +inf || x == -inf) +- case LibFunc::sinf: // Same as sin +- case LibFunc::sinl: // Same as sin ++ case LibFunc_cos: // DomainError: (x == +inf || x == -inf) ++ case LibFunc_cosf: // Same as cos ++ case LibFunc_cosl: // Same as cos ++ case LibFunc_sin: // DomainError: (x == +inf || x == -inf) ++ case LibFunc_sinf: // Same as sin ++ case LibFunc_sinl: // Same as sin + { + ++NumWrappedTwoCond; + Cond = createOrCond(CI, CmpInst::FCMP_OEQ, INFINITY, CmpInst::FCMP_OEQ, + -INFINITY); + break; + } +- case LibFunc::acosh: // DomainError: (x < 1) +- case LibFunc::acoshf: // Same as acosh +- case LibFunc::acoshl: // Same as acosh ++ case LibFunc_acosh: // DomainError: (x < 1) ++ case LibFunc_acoshf: // Same as acosh ++ case LibFunc_acoshl: // Same as acosh + { + ++NumWrappedOneCond; + Cond = createCond(CI, CmpInst::FCMP_OLT, 1.0f); + break; + } +- case LibFunc::sqrt: // DomainError: (x < 0) +- case LibFunc::sqrtf: // Same as sqrt +- case LibFunc::sqrtl: // Same as sqrt ++ case LibFunc_sqrt: // DomainError: (x < 0) ++ case LibFunc_sqrtf: // Same as sqrt ++ case LibFunc_sqrtl: // Same as sqrt + { + ++NumWrappedOneCond; + Cond = createCond(CI, CmpInst::FCMP_OLT, 0.0f); +@@ -193,31 +193,31 @@ bool LibCallsShrinkWrap::performCallDomainErrorOnly(CallInst *CI, + + // Perform the transformation to calls with errno set by range error. + bool LibCallsShrinkWrap::performCallRangeErrorOnly(CallInst *CI, +- const LibFunc::Func &Func) { ++ const LibFunc &Func) { + Value *Cond = nullptr; + + switch (Func) { +- case LibFunc::cosh: +- case LibFunc::coshf: +- case LibFunc::coshl: +- case LibFunc::exp: +- case LibFunc::expf: +- case LibFunc::expl: +- case LibFunc::exp10: +- case LibFunc::exp10f: +- case LibFunc::exp10l: +- case LibFunc::exp2: +- case LibFunc::exp2f: +- case LibFunc::exp2l: +- case LibFunc::sinh: +- case LibFunc::sinhf: +- case LibFunc::sinhl: { ++ case LibFunc_cosh: ++ case LibFunc_coshf: ++ case LibFunc_coshl: ++ case LibFunc_exp: ++ case LibFunc_expf: ++ case LibFunc_expl: ++ case LibFunc_exp10: ++ case LibFunc_exp10f: ++ case LibFunc_exp10l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: ++ case LibFunc_exp2l: ++ case LibFunc_sinh: ++ case LibFunc_sinhf: ++ case LibFunc_sinhl: { + Cond = generateTwoRangeCond(CI, Func); + break; + } +- case LibFunc::expm1: // RangeError: (709, inf) +- case LibFunc::expm1f: // RangeError: (88, inf) +- case LibFunc::expm1l: // RangeError: (11356, inf) ++ case LibFunc_expm1: // RangeError: (709, inf) ++ case LibFunc_expm1f: // RangeError: (88, inf) ++ case LibFunc_expm1l: // RangeError: (11356, inf) + { + Cond = generateOneRangeCond(CI, Func); + break; +@@ -231,15 +231,15 @@ bool LibCallsShrinkWrap::performCallRangeErrorOnly(CallInst *CI, + + // Perform the transformation to calls with errno set by combination of errors. + bool LibCallsShrinkWrap::performCallErrors(CallInst *CI, +- const LibFunc::Func &Func) { ++ const LibFunc &Func) { + Value *Cond = nullptr; + + switch (Func) { +- case LibFunc::atanh: // DomainError: (x < -1 || x > 1) ++ case LibFunc_atanh: // DomainError: (x < -1 || x > 1) + // PoleError: (x == -1 || x == 1) + // Overall Cond: (x <= -1 || x >= 1) +- case LibFunc::atanhf: // Same as atanh +- case LibFunc::atanhl: // Same as atanh ++ case LibFunc_atanhf: // Same as atanh ++ case LibFunc_atanhl: // Same as atanh + { + if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) + return false; +@@ -247,20 +247,20 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI, + Cond = createOrCond(CI, CmpInst::FCMP_OLE, -1.0f, CmpInst::FCMP_OGE, 1.0f); + break; + } +- case LibFunc::log: // DomainError: (x < 0) ++ case LibFunc_log: // DomainError: (x < 0) + // PoleError: (x == 0) + // Overall Cond: (x <= 0) +- case LibFunc::logf: // Same as log +- case LibFunc::logl: // Same as log +- case LibFunc::log10: // Same as log +- case LibFunc::log10f: // Same as log +- case LibFunc::log10l: // Same as log +- case LibFunc::log2: // Same as log +- case LibFunc::log2f: // Same as log +- case LibFunc::log2l: // Same as log +- case LibFunc::logb: // Same as log +- case LibFunc::logbf: // Same as log +- case LibFunc::logbl: // Same as log ++ case LibFunc_logf: // Same as log ++ case LibFunc_logl: // Same as log ++ case LibFunc_log10: // Same as log ++ case LibFunc_log10f: // Same as log ++ case LibFunc_log10l: // Same as log ++ case LibFunc_log2: // Same as log ++ case LibFunc_log2f: // Same as log ++ case LibFunc_log2l: // Same as log ++ case LibFunc_logb: // Same as log ++ case LibFunc_logbf: // Same as log ++ case LibFunc_logbl: // Same as log + { + if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) + return false; +@@ -268,11 +268,11 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI, + Cond = createCond(CI, CmpInst::FCMP_OLE, 0.0f); + break; + } +- case LibFunc::log1p: // DomainError: (x < -1) ++ case LibFunc_log1p: // DomainError: (x < -1) + // PoleError: (x == -1) + // Overall Cond: (x <= -1) +- case LibFunc::log1pf: // Same as log1p +- case LibFunc::log1pl: // Same as log1p ++ case LibFunc_log1pf: // Same as log1p ++ case LibFunc_log1pl: // Same as log1p + { + if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError) + return false; +@@ -280,11 +280,11 @@ bool LibCallsShrinkWrap::performCallErrors(CallInst *CI, + Cond = createCond(CI, CmpInst::FCMP_OLE, -1.0f); + break; + } +- case LibFunc::pow: // DomainError: x < 0 and y is noninteger ++ case LibFunc_pow: // DomainError: x < 0 and y is noninteger + // PoleError: x == 0 and y < 0 + // RangeError: overflow or underflow +- case LibFunc::powf: +- case LibFunc::powl: { ++ case LibFunc_powf: ++ case LibFunc_powl: { + if (!LibCallsShrinkWrapDoDomainError || !LibCallsShrinkWrapDoPoleError || + !LibCallsShrinkWrapDoRangeError) + return false; +@@ -313,7 +313,7 @@ void LibCallsShrinkWrap::checkCandidate(CallInst &CI) { + if (!CI.use_empty()) + return; + +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI.getCalledFunction(); + if (!Callee) + return; +@@ -333,16 +333,16 @@ void LibCallsShrinkWrap::checkCandidate(CallInst &CI) { + + // Generate the upper bound condition for RangeError. + Value *LibCallsShrinkWrap::generateOneRangeCond(CallInst *CI, +- const LibFunc::Func &Func) { ++ const LibFunc &Func) { + float UpperBound; + switch (Func) { +- case LibFunc::expm1: // RangeError: (709, inf) ++ case LibFunc_expm1: // RangeError: (709, inf) + UpperBound = 709.0f; + break; +- case LibFunc::expm1f: // RangeError: (88, inf) ++ case LibFunc_expm1f: // RangeError: (88, inf) + UpperBound = 88.0f; + break; +- case LibFunc::expm1l: // RangeError: (11356, inf) ++ case LibFunc_expm1l: // RangeError: (11356, inf) + UpperBound = 11356.0f; + break; + default: +@@ -355,57 +355,57 @@ Value *LibCallsShrinkWrap::generateOneRangeCond(CallInst *CI, + + // Generate the lower and upper bound condition for RangeError. + Value *LibCallsShrinkWrap::generateTwoRangeCond(CallInst *CI, +- const LibFunc::Func &Func) { ++ const LibFunc &Func) { + float UpperBound, LowerBound; + switch (Func) { +- case LibFunc::cosh: // RangeError: (x < -710 || x > 710) +- case LibFunc::sinh: // Same as cosh ++ case LibFunc_cosh: // RangeError: (x < -710 || x > 710) ++ case LibFunc_sinh: // Same as cosh + LowerBound = -710.0f; + UpperBound = 710.0f; + break; +- case LibFunc::coshf: // RangeError: (x < -89 || x > 89) +- case LibFunc::sinhf: // Same as coshf ++ case LibFunc_coshf: // RangeError: (x < -89 || x > 89) ++ case LibFunc_sinhf: // Same as coshf + LowerBound = -89.0f; + UpperBound = 89.0f; + break; +- case LibFunc::coshl: // RangeError: (x < -11357 || x > 11357) +- case LibFunc::sinhl: // Same as coshl ++ case LibFunc_coshl: // RangeError: (x < -11357 || x > 11357) ++ case LibFunc_sinhl: // Same as coshl + LowerBound = -11357.0f; + UpperBound = 11357.0f; + break; +- case LibFunc::exp: // RangeError: (x < -745 || x > 709) ++ case LibFunc_exp: // RangeError: (x < -745 || x > 709) + LowerBound = -745.0f; + UpperBound = 709.0f; + break; +- case LibFunc::expf: // RangeError: (x < -103 || x > 88) ++ case LibFunc_expf: // RangeError: (x < -103 || x > 88) + LowerBound = -103.0f; + UpperBound = 88.0f; + break; +- case LibFunc::expl: // RangeError: (x < -11399 || x > 11356) ++ case LibFunc_expl: // RangeError: (x < -11399 || x > 11356) + LowerBound = -11399.0f; + UpperBound = 11356.0f; + break; +- case LibFunc::exp10: // RangeError: (x < -323 || x > 308) ++ case LibFunc_exp10: // RangeError: (x < -323 || x > 308) + LowerBound = -323.0f; + UpperBound = 308.0f; + break; +- case LibFunc::exp10f: // RangeError: (x < -45 || x > 38) ++ case LibFunc_exp10f: // RangeError: (x < -45 || x > 38) + LowerBound = -45.0f; + UpperBound = 38.0f; + break; +- case LibFunc::exp10l: // RangeError: (x < -4950 || x > 4932) ++ case LibFunc_exp10l: // RangeError: (x < -4950 || x > 4932) + LowerBound = -4950.0f; + UpperBound = 4932.0f; + break; +- case LibFunc::exp2: // RangeError: (x < -1074 || x > 1023) ++ case LibFunc_exp2: // RangeError: (x < -1074 || x > 1023) + LowerBound = -1074.0f; + UpperBound = 1023.0f; + break; +- case LibFunc::exp2f: // RangeError: (x < -149 || x > 127) ++ case LibFunc_exp2f: // RangeError: (x < -149 || x > 127) + LowerBound = -149.0f; + UpperBound = 127.0f; + break; +- case LibFunc::exp2l: // RangeError: (x < -16445 || x > 11383) ++ case LibFunc_exp2l: // RangeError: (x < -16445 || x > 11383) + LowerBound = -16445.0f; + UpperBound = 11383.0f; + break; +@@ -434,9 +434,9 @@ Value *LibCallsShrinkWrap::generateTwoRangeCond(CallInst *CI, + // (i.e. we might invoke the calls that will not set the errno.). + // + Value *LibCallsShrinkWrap::generateCondForPow(CallInst *CI, +- const LibFunc::Func &Func) { +- // FIXME: LibFunc::powf and powl TBD. +- if (Func != LibFunc::pow) { ++ const LibFunc &Func) { ++ // FIXME: LibFunc_powf and powl TBD. ++ if (Func != LibFunc_pow) { + DEBUG(dbgs() << "Not handled powf() and powl()\n"); + return nullptr; + } +@@ -516,7 +516,7 @@ void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) { + + // Perform the transformation to a single candidate. + bool LibCallsShrinkWrap::perform(CallInst *CI) { +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + assert(Callee && "perform() should apply to a non-empty callee"); + TLI.getLibFunc(*Callee, Func); +diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp +index 6e4174aa0cd..9e217fec20c 100644 +--- a/lib/Transforms/Utils/Local.cpp ++++ b/lib/Transforms/Utils/Local.cpp +@@ -2068,7 +2068,7 @@ bool llvm::recognizeBSwapOrBitReverseIdiom( + void llvm::maybeMarkSanitizerLibraryCallNoBuiltin( + CallInst *CI, const TargetLibraryInfo *TLI) { + Function *F = CI->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (F && !F->hasLocalLinkage() && F->hasName() && + TLI->getLibFunc(F->getName(), Func) && TLI->hasOptimizedCodeGen(Func) && + !F->doesNotAccessMemory()) +diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp +index 8eaeb1073a7..81c8f61fd35 100644 +--- a/lib/Transforms/Utils/SimplifyLibCalls.cpp ++++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp +@@ -51,9 +51,9 @@ static cl::opt + // Helper Functions + //===----------------------------------------------------------------------===// + +-static bool ignoreCallingConv(LibFunc::Func Func) { +- return Func == LibFunc::abs || Func == LibFunc::labs || +- Func == LibFunc::llabs || Func == LibFunc::strlen; ++static bool ignoreCallingConv(LibFunc Func) { ++ return Func == LibFunc_abs || Func == LibFunc_labs || ++ Func == LibFunc_llabs || Func == LibFunc_strlen; + } + + static bool isCallingConvCCompatible(CallInst *CI) { +@@ -123,8 +123,8 @@ static bool callHasFloatingPointArgument(const CallInst *CI) { + /// \brief Check whether the overloaded unary floating point function + /// corresponding to \a Ty is available. + static bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty, +- LibFunc::Func DoubleFn, LibFunc::Func FloatFn, +- LibFunc::Func LongDoubleFn) { ++ LibFunc DoubleFn, LibFunc FloatFn, ++ LibFunc LongDoubleFn) { + switch (Ty->getTypeID()) { + case Type::FloatTyID: + return TLI->has(FloatFn); +@@ -811,7 +811,7 @@ Value *LibCallSimplifier::optimizeMemMove(CallInst *CI, IRBuilder<> &B) { + // functions be moved here? + static Value *emitCalloc(Value *Num, Value *Size, const AttributeSet &Attrs, + IRBuilder<> &B, const TargetLibraryInfo &TLI) { +- LibFunc::Func Func; ++ LibFunc Func; + if (!TLI.getLibFunc("calloc", Func) || !TLI.has(Func)) + return nullptr; + +@@ -846,9 +846,9 @@ static Value *foldMallocMemset(CallInst *Memset, IRBuilder<> &B, + + // Is the inner call really malloc()? + Function *InnerCallee = Malloc->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (!TLI.getLibFunc(*InnerCallee, Func) || !TLI.has(Func) || +- Func != LibFunc::malloc) ++ Func != LibFunc_malloc) + return nullptr; + + // The memset must cover the same number of bytes that are malloc'd. +@@ -1041,9 +1041,9 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + if (ConstantFP *Op1C = dyn_cast(Op1)) { + // pow(10.0, x) -> exp10(x) + if (Op1C->isExactlyValue(10.0) && +- hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp10, LibFunc::exp10f, +- LibFunc::exp10l)) +- return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc::exp10), B, ++ hasUnaryFloatFn(TLI, Op1->getType(), LibFunc_exp10, LibFunc_exp10f, ++ LibFunc_exp10l)) ++ return emitUnaryFloatFnCall(Op2, TLI->getName(LibFunc_exp10), B, + Callee->getAttributes()); + } + +@@ -1055,10 +1055,10 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + // pow(exp(x), y) = pow(inf, 0.001) = inf, whereas exp(x*y) = exp(1). + auto *OpC = dyn_cast(Op1); + if (OpC && OpC->hasUnsafeAlgebra() && CI->hasUnsafeAlgebra()) { +- LibFunc::Func Func; ++ LibFunc Func; + Function *OpCCallee = OpC->getCalledFunction(); + if (OpCCallee && TLI->getLibFunc(OpCCallee->getName(), Func) && +- TLI->has(Func) && (Func == LibFunc::exp || Func == LibFunc::exp2)) { ++ TLI->has(Func) && (Func == LibFunc_exp || Func == LibFunc_exp2)) { + IRBuilder<>::FastMathFlagGuard Guard(B); + B.setFastMathFlags(CI->getFastMathFlags()); + Value *FMul = B.CreateFMul(OpC->getArgOperand(0), Op2, "mul"); +@@ -1075,8 +1075,8 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + return ConstantFP::get(CI->getType(), 1.0); + + if (Op2C->isExactlyValue(-0.5) && +- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf, +- LibFunc::sqrtl)) { ++ hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_sqrt, LibFunc_sqrtf, ++ LibFunc_sqrtl)) { + // If -ffast-math: + // pow(x, -0.5) -> 1.0 / sqrt(x) + if (CI->hasUnsafeAlgebra()) { +@@ -1085,7 +1085,7 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + + // Here we cannot lower to an intrinsic because C99 sqrt() and llvm.sqrt + // are not guaranteed to have the same semantics. +- Value *Sqrt = emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B, ++ Value *Sqrt = emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc_sqrt), B, + Callee->getAttributes()); + + return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Sqrt, "sqrtrecip"); +@@ -1093,10 +1093,10 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + } + + if (Op2C->isExactlyValue(0.5) && +- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf, +- LibFunc::sqrtl) && +- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::fabs, LibFunc::fabsf, +- LibFunc::fabsl)) { ++ hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_sqrt, LibFunc_sqrtf, ++ LibFunc_sqrtl) && ++ hasUnaryFloatFn(TLI, Op2->getType(), LibFunc_fabs, LibFunc_fabsf, ++ LibFunc_fabsl)) { + + // In -ffast-math, pow(x, 0.5) -> sqrt(x). + if (CI->hasUnsafeAlgebra()) { +@@ -1105,7 +1105,7 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { + + // Unlike other math intrinsics, sqrt has differerent semantics + // from the libc function. See LangRef for details. +- return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B, ++ return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc_sqrt), B, + Callee->getAttributes()); + } + +@@ -1173,11 +1173,11 @@ Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilder<> &B) { + Value *Op = CI->getArgOperand(0); + // Turn exp2(sitofp(x)) -> ldexp(1.0, sext(x)) if sizeof(x) <= 32 + // Turn exp2(uitofp(x)) -> ldexp(1.0, zext(x)) if sizeof(x) < 32 +- LibFunc::Func LdExp = LibFunc::ldexpl; ++ LibFunc LdExp = LibFunc_ldexpl; + if (Op->getType()->isFloatTy()) +- LdExp = LibFunc::ldexpf; ++ LdExp = LibFunc_ldexpf; + else if (Op->getType()->isDoubleTy()) +- LdExp = LibFunc::ldexp; ++ LdExp = LibFunc_ldexp; + + if (TLI->has(LdExp)) { + Value *LdExpArg = nullptr; +@@ -1280,17 +1280,17 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) { + FMF.setUnsafeAlgebra(); + B.setFastMathFlags(FMF); + +- LibFunc::Func Func; ++ LibFunc Func; + Function *F = OpC->getCalledFunction(); + if (F && ((TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) && +- Func == LibFunc::pow) || F->getIntrinsicID() == Intrinsic::pow)) ++ Func == LibFunc_pow) || F->getIntrinsicID() == Intrinsic::pow)) + return B.CreateFMul(OpC->getArgOperand(1), + emitUnaryFloatFnCall(OpC->getOperand(0), Callee->getName(), B, + Callee->getAttributes()), "mul"); + + // log(exp2(y)) -> y*log(2) + if (F && Name == "log" && TLI->getLibFunc(F->getName(), Func) && +- TLI->has(Func) && Func == LibFunc::exp2) ++ TLI->has(Func) && Func == LibFunc_exp2) + return B.CreateFMul( + OpC->getArgOperand(0), + emitUnaryFloatFnCall(ConstantFP::get(CI->getType(), 2.0), +@@ -1302,8 +1302,8 @@ Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) { + Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilder<> &B) { + Function *Callee = CI->getCalledFunction(); + Value *Ret = nullptr; +- if (TLI->has(LibFunc::sqrtf) && (Callee->getName() == "sqrt" || +- Callee->getIntrinsicID() == Intrinsic::sqrt)) ++ if (TLI->has(LibFunc_sqrtf) && (Callee->getName() == "sqrt" || ++ Callee->getIntrinsicID() == Intrinsic::sqrt)) + Ret = optimizeUnaryDoubleFP(CI, B, true); + + if (!CI->hasUnsafeAlgebra()) +@@ -1385,12 +1385,12 @@ Value *LibCallSimplifier::optimizeTan(CallInst *CI, IRBuilder<> &B) { + // tan(atan(x)) -> x + // tanf(atanf(x)) -> x + // tanl(atanl(x)) -> x +- LibFunc::Func Func; ++ LibFunc Func; + Function *F = OpC->getCalledFunction(); + if (F && TLI->getLibFunc(F->getName(), Func) && TLI->has(Func) && +- ((Func == LibFunc::atan && Callee->getName() == "tan") || +- (Func == LibFunc::atanf && Callee->getName() == "tanf") || +- (Func == LibFunc::atanl && Callee->getName() == "tanl"))) ++ ((Func == LibFunc_atan && Callee->getName() == "tan") || ++ (Func == LibFunc_atanf && Callee->getName() == "tanf") || ++ (Func == LibFunc_atanl && Callee->getName() == "tanl"))) + Ret = OpC->getArgOperand(0); + return Ret; + } +@@ -1508,24 +1508,24 @@ void LibCallSimplifier::classifyArgUse( + return; + + Function *Callee = CI->getCalledFunction(); +- LibFunc::Func Func; ++ LibFunc Func; + if (!Callee || !TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) || + !isTrigLibCall(CI)) + return; + + if (IsFloat) { +- if (Func == LibFunc::sinpif) ++ if (Func == LibFunc_sinpif) + SinCalls.push_back(CI); +- else if (Func == LibFunc::cospif) ++ else if (Func == LibFunc_cospif) + CosCalls.push_back(CI); +- else if (Func == LibFunc::sincospif_stret) ++ else if (Func == LibFunc_sincospif_stret) + SinCosCalls.push_back(CI); + } else { +- if (Func == LibFunc::sinpi) ++ if (Func == LibFunc_sinpi) + SinCalls.push_back(CI); +- else if (Func == LibFunc::cospi) ++ else if (Func == LibFunc_cospi) + CosCalls.push_back(CI); +- else if (Func == LibFunc::sincospi_stret) ++ else if (Func == LibFunc_sincospi_stret) + SinCosCalls.push_back(CI); + } + } +@@ -1699,7 +1699,7 @@ Value *LibCallSimplifier::optimizePrintF(CallInst *CI, IRBuilder<> &B) { + + // printf(format, ...) -> iprintf(format, ...) if no floating point + // arguments. +- if (TLI->has(LibFunc::iprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_iprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *IPrintFFn = + M->getOrInsertFunction("iprintf", FT, Callee->getAttributes()); +@@ -1780,7 +1780,7 @@ Value *LibCallSimplifier::optimizeSPrintF(CallInst *CI, IRBuilder<> &B) { + + // sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating + // point arguments. +- if (TLI->has(LibFunc::siprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_siprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *SIPrintFFn = + M->getOrInsertFunction("siprintf", FT, Callee->getAttributes()); +@@ -1850,7 +1850,7 @@ Value *LibCallSimplifier::optimizeFPrintF(CallInst *CI, IRBuilder<> &B) { + + // fprintf(stream, format, ...) -> fiprintf(stream, format, ...) if no + // floating point arguments. +- if (TLI->has(LibFunc::fiprintf) && !callHasFloatingPointArgument(CI)) { ++ if (TLI->has(LibFunc_fiprintf) && !callHasFloatingPointArgument(CI)) { + Module *M = B.GetInsertBlock()->getParent()->getParent(); + Constant *FIPrintFFn = + M->getOrInsertFunction("fiprintf", FT, Callee->getAttributes()); +@@ -1929,7 +1929,7 @@ Value *LibCallSimplifier::optimizePuts(CallInst *CI, IRBuilder<> &B) { + } + + bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { +- LibFunc::Func Func; ++ LibFunc Func; + SmallString<20> FloatFuncName = FuncName; + FloatFuncName += 'f'; + if (TLI->getLibFunc(FloatFuncName, Func)) +@@ -1939,7 +1939,7 @@ bool LibCallSimplifier::hasFloatVersion(StringRef FuncName) { + + Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI, + IRBuilder<> &Builder) { +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + // Check for string/memory library functions. + if (TLI->getLibFunc(*Callee, Func) && TLI->has(Func)) { +@@ -1948,51 +1948,51 @@ Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI, + isCallingConvCCompatible(CI)) && + "Optimizing string/memory libcall would change the calling convention"); + switch (Func) { +- case LibFunc::strcat: ++ case LibFunc_strcat: + return optimizeStrCat(CI, Builder); +- case LibFunc::strncat: ++ case LibFunc_strncat: + return optimizeStrNCat(CI, Builder); +- case LibFunc::strchr: ++ case LibFunc_strchr: + return optimizeStrChr(CI, Builder); +- case LibFunc::strrchr: ++ case LibFunc_strrchr: + return optimizeStrRChr(CI, Builder); +- case LibFunc::strcmp: ++ case LibFunc_strcmp: + return optimizeStrCmp(CI, Builder); +- case LibFunc::strncmp: ++ case LibFunc_strncmp: + return optimizeStrNCmp(CI, Builder); +- case LibFunc::strcpy: ++ case LibFunc_strcpy: + return optimizeStrCpy(CI, Builder); +- case LibFunc::stpcpy: ++ case LibFunc_stpcpy: + return optimizeStpCpy(CI, Builder); +- case LibFunc::strncpy: ++ case LibFunc_strncpy: + return optimizeStrNCpy(CI, Builder); +- case LibFunc::strlen: ++ case LibFunc_strlen: + return optimizeStrLen(CI, Builder); +- case LibFunc::strpbrk: ++ case LibFunc_strpbrk: + return optimizeStrPBrk(CI, Builder); +- case LibFunc::strtol: +- case LibFunc::strtod: +- case LibFunc::strtof: +- case LibFunc::strtoul: +- case LibFunc::strtoll: +- case LibFunc::strtold: +- case LibFunc::strtoull: ++ case LibFunc_strtol: ++ case LibFunc_strtod: ++ case LibFunc_strtof: ++ case LibFunc_strtoul: ++ case LibFunc_strtoll: ++ case LibFunc_strtold: ++ case LibFunc_strtoull: + return optimizeStrTo(CI, Builder); +- case LibFunc::strspn: ++ case LibFunc_strspn: + return optimizeStrSpn(CI, Builder); +- case LibFunc::strcspn: ++ case LibFunc_strcspn: + return optimizeStrCSpn(CI, Builder); +- case LibFunc::strstr: ++ case LibFunc_strstr: + return optimizeStrStr(CI, Builder); +- case LibFunc::memchr: ++ case LibFunc_memchr: + return optimizeMemChr(CI, Builder); +- case LibFunc::memcmp: ++ case LibFunc_memcmp: + return optimizeMemCmp(CI, Builder); +- case LibFunc::memcpy: ++ case LibFunc_memcpy: + return optimizeMemCpy(CI, Builder); +- case LibFunc::memmove: ++ case LibFunc_memmove: + return optimizeMemMove(CI, Builder); +- case LibFunc::memset: ++ case LibFunc_memset: + return optimizeMemSet(CI, Builder); + default: + break; +@@ -2005,7 +2005,7 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { + if (CI->isNoBuiltin()) + return nullptr; + +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + StringRef FuncName = Callee->getName(); + +@@ -2067,114 +2067,114 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) { + if (Value *V = optimizeStringMemoryLibCall(CI, Builder)) + return V; + switch (Func) { +- case LibFunc::cosf: +- case LibFunc::cos: +- case LibFunc::cosl: ++ case LibFunc_cosf: ++ case LibFunc_cos: ++ case LibFunc_cosl: + return optimizeCos(CI, Builder); +- case LibFunc::sinpif: +- case LibFunc::sinpi: +- case LibFunc::cospif: +- case LibFunc::cospi: ++ case LibFunc_sinpif: ++ case LibFunc_sinpi: ++ case LibFunc_cospif: ++ case LibFunc_cospi: + return optimizeSinCosPi(CI, Builder); +- case LibFunc::powf: +- case LibFunc::pow: +- case LibFunc::powl: ++ case LibFunc_powf: ++ case LibFunc_pow: ++ case LibFunc_powl: + return optimizePow(CI, Builder); +- case LibFunc::exp2l: +- case LibFunc::exp2: +- case LibFunc::exp2f: ++ case LibFunc_exp2l: ++ case LibFunc_exp2: ++ case LibFunc_exp2f: + return optimizeExp2(CI, Builder); +- case LibFunc::fabsf: +- case LibFunc::fabs: +- case LibFunc::fabsl: ++ case LibFunc_fabsf: ++ case LibFunc_fabs: ++ case LibFunc_fabsl: + return optimizeFabs(CI, Builder); +- case LibFunc::sqrtf: +- case LibFunc::sqrt: +- case LibFunc::sqrtl: ++ case LibFunc_sqrtf: ++ case LibFunc_sqrt: ++ case LibFunc_sqrtl: + return optimizeSqrt(CI, Builder); +- case LibFunc::ffs: +- case LibFunc::ffsl: +- case LibFunc::ffsll: ++ case LibFunc_ffs: ++ case LibFunc_ffsl: ++ case LibFunc_ffsll: + return optimizeFFS(CI, Builder); +- case LibFunc::fls: +- case LibFunc::flsl: +- case LibFunc::flsll: ++ case LibFunc_fls: ++ case LibFunc_flsl: ++ case LibFunc_flsll: + return optimizeFls(CI, Builder); +- case LibFunc::abs: +- case LibFunc::labs: +- case LibFunc::llabs: ++ case LibFunc_abs: ++ case LibFunc_labs: ++ case LibFunc_llabs: + return optimizeAbs(CI, Builder); +- case LibFunc::isdigit: ++ case LibFunc_isdigit: + return optimizeIsDigit(CI, Builder); +- case LibFunc::isascii: ++ case LibFunc_isascii: + return optimizeIsAscii(CI, Builder); +- case LibFunc::toascii: ++ case LibFunc_toascii: + return optimizeToAscii(CI, Builder); +- case LibFunc::printf: ++ case LibFunc_printf: + return optimizePrintF(CI, Builder); +- case LibFunc::sprintf: ++ case LibFunc_sprintf: + return optimizeSPrintF(CI, Builder); +- case LibFunc::fprintf: ++ case LibFunc_fprintf: + return optimizeFPrintF(CI, Builder); +- case LibFunc::fwrite: ++ case LibFunc_fwrite: + return optimizeFWrite(CI, Builder); +- case LibFunc::fputs: ++ case LibFunc_fputs: + return optimizeFPuts(CI, Builder); +- case LibFunc::log: +- case LibFunc::log10: +- case LibFunc::log1p: +- case LibFunc::log2: +- case LibFunc::logb: ++ case LibFunc_log: ++ case LibFunc_log10: ++ case LibFunc_log1p: ++ case LibFunc_log2: ++ case LibFunc_logb: + return optimizeLog(CI, Builder); +- case LibFunc::puts: ++ case LibFunc_puts: + return optimizePuts(CI, Builder); +- case LibFunc::tan: +- case LibFunc::tanf: +- case LibFunc::tanl: ++ case LibFunc_tan: ++ case LibFunc_tanf: ++ case LibFunc_tanl: + return optimizeTan(CI, Builder); +- case LibFunc::perror: ++ case LibFunc_perror: + return optimizeErrorReporting(CI, Builder); +- case LibFunc::vfprintf: +- case LibFunc::fiprintf: ++ case LibFunc_vfprintf: ++ case LibFunc_fiprintf: + return optimizeErrorReporting(CI, Builder, 0); +- case LibFunc::fputc: ++ case LibFunc_fputc: + return optimizeErrorReporting(CI, Builder, 1); +- case LibFunc::ceil: +- case LibFunc::floor: +- case LibFunc::rint: +- case LibFunc::round: +- case LibFunc::nearbyint: +- case LibFunc::trunc: ++ case LibFunc_ceil: ++ case LibFunc_floor: ++ case LibFunc_rint: ++ case LibFunc_round: ++ case LibFunc_nearbyint: ++ case LibFunc_trunc: + if (hasFloatVersion(FuncName)) + return optimizeUnaryDoubleFP(CI, Builder, false); + return nullptr; +- case LibFunc::acos: +- case LibFunc::acosh: +- case LibFunc::asin: +- case LibFunc::asinh: +- case LibFunc::atan: +- case LibFunc::atanh: +- case LibFunc::cbrt: +- case LibFunc::cosh: +- case LibFunc::exp: +- case LibFunc::exp10: +- case LibFunc::expm1: +- case LibFunc::sin: +- case LibFunc::sinh: +- case LibFunc::tanh: ++ case LibFunc_acos: ++ case LibFunc_acosh: ++ case LibFunc_asin: ++ case LibFunc_asinh: ++ case LibFunc_atan: ++ case LibFunc_atanh: ++ case LibFunc_cbrt: ++ case LibFunc_cosh: ++ case LibFunc_exp: ++ case LibFunc_exp10: ++ case LibFunc_expm1: ++ case LibFunc_sin: ++ case LibFunc_sinh: ++ case LibFunc_tanh: + if (UnsafeFPShrink && hasFloatVersion(FuncName)) + return optimizeUnaryDoubleFP(CI, Builder, true); + return nullptr; +- case LibFunc::copysign: ++ case LibFunc_copysign: + if (hasFloatVersion(FuncName)) + return optimizeBinaryDoubleFP(CI, Builder); + return nullptr; +- case LibFunc::fminf: +- case LibFunc::fmin: +- case LibFunc::fminl: +- case LibFunc::fmaxf: +- case LibFunc::fmax: +- case LibFunc::fmaxl: ++ case LibFunc_fminf: ++ case LibFunc_fmin: ++ case LibFunc_fminl: ++ case LibFunc_fmaxf: ++ case LibFunc_fmax: ++ case LibFunc_fmaxl: + return optimizeFMinFMax(CI, Builder); + default: + return nullptr; +@@ -2300,7 +2300,7 @@ Value *FortifiedLibCallSimplifier::optimizeMemSetChk(CallInst *CI, + + Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + IRBuilder<> &B, +- LibFunc::Func Func) { ++ LibFunc Func) { + Function *Callee = CI->getCalledFunction(); + StringRef Name = Callee->getName(); + const DataLayout &DL = CI->getModule()->getDataLayout(); +@@ -2308,7 +2308,7 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + *ObjSize = CI->getArgOperand(2); + + // __stpcpy_chk(x,x,...) -> x+strlen(x) +- if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { ++ if (Func == LibFunc_stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) { + Value *StrLen = emitStrLen(Src, B, DL, TLI); + return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr; + } +@@ -2334,14 +2334,14 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI, + Value *Ret = emitMemCpyChk(Dst, Src, LenV, ObjSize, B, DL, TLI); + // If the function was an __stpcpy_chk, and we were able to fold it into + // a __memcpy_chk, we still need to return the correct end pointer. +- if (Ret && Func == LibFunc::stpcpy_chk) ++ if (Ret && Func == LibFunc_stpcpy_chk) + return B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(SizeTTy, Len - 1)); + return Ret; + } + + Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(CallInst *CI, + IRBuilder<> &B, +- LibFunc::Func Func) { ++ LibFunc Func) { + Function *Callee = CI->getCalledFunction(); + StringRef Name = Callee->getName(); + if (isFortifiedCallFoldable(CI, 3, 2, false)) { +@@ -2366,7 +2366,7 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) { + // + // PR23093. + +- LibFunc::Func Func; ++ LibFunc Func; + Function *Callee = CI->getCalledFunction(); + + SmallVector OpBundles; +@@ -2384,17 +2384,17 @@ Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) { + return nullptr; + + switch (Func) { +- case LibFunc::memcpy_chk: ++ case LibFunc_memcpy_chk: + return optimizeMemCpyChk(CI, Builder); +- case LibFunc::memmove_chk: ++ case LibFunc_memmove_chk: + return optimizeMemMoveChk(CI, Builder); +- case LibFunc::memset_chk: ++ case LibFunc_memset_chk: + return optimizeMemSetChk(CI, Builder); +- case LibFunc::stpcpy_chk: +- case LibFunc::strcpy_chk: ++ case LibFunc_stpcpy_chk: ++ case LibFunc_strcpy_chk: + return optimizeStrpCpyChk(CI, Builder, Func); +- case LibFunc::stpncpy_chk: +- case LibFunc::strncpy_chk: ++ case LibFunc_stpncpy_chk: ++ case LibFunc_strncpy_chk: + return optimizeStrpNCpyChk(CI, Builder, Func); + default: + break; From faabdba2ff9b5921e23d47e9dd8b72b8141f57d2 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 7 Mar 2018 18:18:50 +0000 Subject: [PATCH 4/5] add openblas patch to fix build on musl libc --- deps/blas.mk | 8 ++- deps/patches/openblas-musl-PR1257.patch | 65 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 deps/patches/openblas-musl-PR1257.patch diff --git a/deps/blas.mk b/deps/blas.mk index dab61118d0678..dcdf92bd4f765 100644 --- a/deps/blas.mk +++ b/deps/blas.mk @@ -80,7 +80,13 @@ endif # Do not overwrite the "-j" flag OPENBLAS_BUILD_OPTS += MAKE_NB_JOBS=0 -$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted +# Fix build on musl libc, from https://github.com/xianyi/OpenBLAS/pull/1257 +# remove when upgrading past openblas v0.2.20 +$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-musl-PR1257.patch-applied: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted + cd $(BUILDDIR)/$(OPENBLAS_SRC_DIR) && patch -p1 -f < $(SRCDIR)/patches/openblas-musl-PR1257.patch + echo 1 > $@ + +$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-musl-PR1257.patch-applied perl -i -ple 's/^\s*(EXTRALIB\s*\+=\s*-lSystemStubs)\s*$$/# $$1/g' $(dir $<)/Makefile.system echo 1 > $@ diff --git a/deps/patches/openblas-musl-PR1257.patch b/deps/patches/openblas-musl-PR1257.patch new file mode 100644 index 0000000000000..1516e30b9d8bc --- /dev/null +++ b/deps/patches/openblas-musl-PR1257.patch @@ -0,0 +1,65 @@ +From 63cfa32691680505e6b9daf0997755178ddd3144 Mon Sep 17 00:00:00 2001 +From: Martin Kroeker +Date: Mon, 31 Jul 2017 21:02:43 +0200 +Subject: [PATCH] Rework __GLIBC_PREREQ checks to avoid breaking non-glibc + builds + +--- + driver/others/memory.c | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/driver/others/memory.c b/driver/others/memory.c +index b5b58b6fd..661f7c4eb 100644 +--- a/driver/others/memory.c ++++ b/driver/others/memory.c +@@ -155,7 +155,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef DYNAMIC_ARCH + gotoblas_t *gotoblas = NULL; + #endif +- + extern void openblas_warning(int verbose, const char * msg); + + #ifndef SMP +@@ -187,25 +186,24 @@ int i,n; + + #if !defined(__GLIBC_PREREQ) + return nums; +-#endif +-#if !__GLIBC_PREREQ(2, 3) ++#else ++ #if !__GLIBC_PREREQ(2, 3) + return nums; +-#endif ++ #endif + +-#if !__GLIBC_PREREQ(2, 7) ++ #if !__GLIBC_PREREQ(2, 7) + ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp); + if (ret!=0) return nums; + n=0; +-#if !__GLIBC_PREREQ(2, 6) ++ #if !__GLIBC_PREREQ(2, 6) + for (i=0;i Date: Wed, 7 Mar 2018 14:46:29 -0800 Subject: [PATCH 5/5] try to fix circle CI when it's also enabled on a fork --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 86bea5d71509d..7ba3cc49881dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,7 @@ jobs: - run: | # checkout merge commit, set versioning info and Make.user variables git config --global --unset url."ssh://git@github.com".insteadOf && if [ -n "$CIRCLE_PULL_REQUEST" ]; then + git remote set-url origin git@github.com:JuliaLang/julia.git && git fetch origin +refs/pull/$(basename $CIRCLE_PULL_REQUEST)/merge && git checkout -qf FETCH_HEAD; fi &&