diff --git a/llvm/lib/Support/TargetRegistry.cpp b/llvm/lib/Support/TargetRegistry.cpp index 6e0e223ba700..8d91a53c2264 100644 --- a/llvm/lib/Support/TargetRegistry.cpp +++ b/llvm/lib/Support/TargetRegistry.cpp @@ -127,6 +127,11 @@ const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) { return TheTarget; } +static int TargetArraySortFn(const std::pair *LHS, + const std::pair *RHS) { + return LHS->first.compare(RHS->first); +} + void TargetRegistry::printRegisteredTargetsForVersion() { std::vector > Targets; size_t Width = 0; @@ -136,11 +141,7 @@ void TargetRegistry::printRegisteredTargetsForVersion() { Targets.push_back(std::make_pair(I->getName(), &*I)); Width = std::max(Width, Targets.back().first.size()); } - array_pod_sort(Targets.begin(), Targets.end(), - [](const std::pair *LHS, - const std::pair *RHS) { - return LHS->first.compare(RHS->first); - }); + array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn); raw_ostream &OS = outs(); OS << " Registered Targets:\n"; diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 1ba9ac176889..0f97160eb6ac 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -2860,6 +2860,10 @@ bool GlobalOpt::OptimizeGlobalCtorsList(GlobalVariable *&GCL) { return true; } +static int compareNames(Constant *const *A, Constant *const *B) { + return (*A)->getName().compare((*B)->getName()); +} + static void setUsedInitializer(GlobalVariable &V, SmallPtrSet Init) { if (Init.empty()) { @@ -2878,10 +2882,7 @@ static void setUsedInitializer(GlobalVariable &V, UsedArray.push_back(Cast); } // Sort to get deterministic order. - array_pod_sort(UsedArray.begin(), UsedArray.end(), - [](Constant *const *A, Constant *const *B) { - return (*A)->getName().compare((*B)->getName()); - }); + array_pod_sort(UsedArray.begin(), UsedArray.end(), compareNames); ArrayType *ATy = ArrayType::get(Int8PtrTy, UsedArray.size()); Module *M = V.getParent();