Index: include/llvm/Analysis/LoopInfoImpl.h =================================================================== --- include/llvm/Analysis/LoopInfoImpl.h +++ include/llvm/Analysis/LoopInfoImpl.h @@ -572,8 +572,8 @@ template bool compareVectors(std::vector &BB1, std::vector &BB2) { - std::sort(BB1.begin(), BB1.end()); - std::sort(BB2.begin(), BB2.end()); + llvm::sort(BB1.begin(), BB1.end()); + llvm::sort(BB2.begin(), BB2.end()); return BB1 == BB2; } Index: include/llvm/CodeGen/SlotIndexes.h =================================================================== --- include/llvm/CodeGen/SlotIndexes.h +++ include/llvm/CodeGen/SlotIndexes.h @@ -674,7 +674,7 @@ idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb)); renumberIndexes(newItr); - std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); + llvm::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); } /// \brief Free the resources that were required to maintain a SlotIndex. Index: include/llvm/ProfileData/InstrProf.h =================================================================== --- include/llvm/ProfileData/InstrProf.h +++ include/llvm/ProfileData/InstrProf.h @@ -524,9 +524,9 @@ } void InstrProfSymtab::finalizeSymtab() { - std::sort(MD5NameMap.begin(), MD5NameMap.end(), less_first()); - std::sort(MD5FuncMap.begin(), MD5FuncMap.end(), less_first()); - std::sort(AddrToMD5Map.begin(), AddrToMD5Map.end(), less_first()); + llvm::sort(MD5NameMap.begin(), MD5NameMap.end(), less_first()); + llvm::sort(MD5FuncMap.begin(), MD5FuncMap.end(), less_first()); + llvm::sort(AddrToMD5Map.begin(), AddrToMD5Map.end(), less_first()); AddrToMD5Map.erase(std::unique(AddrToMD5Map.begin(), AddrToMD5Map.end()), AddrToMD5Map.end()); } Index: include/llvm/Support/GenericDomTreeConstruction.h =================================================================== --- include/llvm/Support/GenericDomTreeConstruction.h +++ include/llvm/Support/GenericDomTreeConstruction.h @@ -1241,11 +1241,11 @@ Operations[{U.getTo(), U.getFrom()}] = int(i); } - std::sort(Result.begin(), Result.end(), - [&Operations](const UpdateT &A, const UpdateT &B) { - return Operations[{A.getFrom(), A.getTo()}] > - Operations[{B.getFrom(), B.getTo()}]; - }); + llvm::sort(Result.begin(), Result.end(), + [&Operations](const UpdateT &A, const UpdateT &B) { + return Operations[{A.getFrom(), A.getTo()}] > + Operations[{B.getFrom(), B.getTo()}]; + }); } static void ApplyNextUpdate(DomTreeT &DT, BatchUpdateInfo &BUI) { @@ -1430,10 +1430,10 @@ // Make a copy and sort it such that it is possible to check if there are // no gaps between DFS numbers of adjacent children. SmallVector Children(Node->begin(), Node->end()); - std::sort(Children.begin(), Children.end(), - [](const TreeNodePtr Ch1, const TreeNodePtr Ch2) { - return Ch1->getDFSNumIn() < Ch2->getDFSNumIn(); - }); + llvm::sort(Children.begin(), Children.end(), + [](const TreeNodePtr Ch1, const TreeNodePtr Ch2) { + return Ch1->getDFSNumIn() < Ch2->getDFSNumIn(); + }); auto PrintChildrenError = [Node, &Children, PrintNodeAndDFSNums]( const TreeNodePtr FirstCh, const TreeNodePtr SecondCh) { Index: include/llvm/Support/Parallel.h =================================================================== --- include/llvm/Support/Parallel.h +++ include/llvm/Support/Parallel.h @@ -118,7 +118,7 @@ const Comparator &Comp, TaskGroup &TG, size_t Depth) { // Do a sequential sort for small inputs. if (std::distance(Start, End) < detail::MinParallelSize || Depth == 0) { - std::sort(Start, End, Comp); + llvm::sort(Start, End, Comp); return; } @@ -200,7 +200,7 @@ const Comparator &Comp = Comparator()) { static_assert(is_execution_policy::value, "Invalid execution policy!"); - std::sort(Start, End, Comp); + llvm::sort(Start, End, Comp); } template Index: include/llvm/Support/ScopedPrinter.h =================================================================== --- include/llvm/Support/ScopedPrinter.h +++ include/llvm/Support/ScopedPrinter.h @@ -138,7 +138,7 @@ } } - std::sort(SetFlags.begin(), SetFlags.end(), &flagName); + llvm::sort(SetFlags.begin(), SetFlags.end(), &flagName); startLine() << Label << " [ (" << hex(Value) << ")\n"; for (const auto &Flag : SetFlags) { Index: lib/Analysis/BlockFrequencyInfoImpl.cpp =================================================================== --- lib/Analysis/BlockFrequencyInfoImpl.cpp +++ lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -155,9 +155,9 @@ static void combineWeightsBySorting(WeightList &Weights) { // Sort so edges to the same node are adjacent. - std::sort(Weights.begin(), Weights.end(), - [](const Weight &L, - const Weight &R) { return L.TargetNode < R.TargetNode; }); + llvm::sort(Weights.begin(), Weights.end(), + [](const Weight &L, + const Weight &R) { return L.TargetNode < R.TargetNode; }); // Combine adjacent edges. WeightList::iterator O = Weights.begin(); @@ -702,7 +702,7 @@ "Expected irreducible CFG; -loop-info is likely invalid"); if (Headers.size() == InSCC.size()) { // Every block is a header. - std::sort(Headers.begin(), Headers.end()); + llvm::sort(Headers.begin(), Headers.end()); return; } @@ -736,8 +736,8 @@ Others.push_back(Irr.Node); DEBUG(dbgs() << " => other = " << BFI.getBlockName(Irr.Node) << "\n"); } - std::sort(Headers.begin(), Headers.end()); - std::sort(Others.begin(), Others.end()); + llvm::sort(Headers.begin(), Headers.end()); + llvm::sort(Others.begin(), Others.end()); } static void createIrreducibleLoop( Index: lib/Analysis/CFLAndersAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLAndersAliasAnalysis.cpp +++ lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -395,7 +395,7 @@ } // Sort AliasList for faster lookup - std::sort(AliasList.begin(), AliasList.end()); + llvm::sort(AliasList.begin(), AliasList.end()); } } @@ -479,7 +479,7 @@ } // Remove duplicates in ExtRelations - std::sort(ExtRelations.begin(), ExtRelations.end()); + llvm::sort(ExtRelations.begin(), ExtRelations.end()); ExtRelations.erase(std::unique(ExtRelations.begin(), ExtRelations.end()), ExtRelations.end()); } Index: lib/Analysis/CallGraph.cpp =================================================================== --- lib/Analysis/CallGraph.cpp +++ lib/Analysis/CallGraph.cpp @@ -96,8 +96,8 @@ for (const auto &I : *this) Nodes.push_back(I.second.get()); - std::sort(Nodes.begin(), Nodes.end(), - [](CallGraphNode *LHS, CallGraphNode *RHS) { + llvm::sort(Nodes.begin(), Nodes.end(), + [](CallGraphNode *LHS, CallGraphNode *RHS) { if (Function *LF = LHS->getFunction()) if (Function *RF = RHS->getFunction()) return LF->getName() < RF->getName(); Index: lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- lib/Analysis/MemoryDependenceAnalysis.cpp +++ lib/Analysis/MemoryDependenceAnalysis.cpp @@ -805,7 +805,7 @@ DirtyBlocks.push_back(Entry.getBB()); // Sort the cache so that we can do fast binary search lookups below. - std::sort(Cache.begin(), Cache.end()); + llvm::sort(Cache.begin(), Cache.end()); ++NumCacheDirtyNonLocal; // cerr << "CACHED CASE: " << DirtyBlocks.size() << " dirty: " @@ -1068,7 +1068,7 @@ break; default: // Added many values, do a full scale sort. - std::sort(Cache.begin(), Cache.end()); + llvm::sort(Cache.begin(), Cache.end()); break; } } @@ -1638,7 +1638,7 @@ // Re-sort the NonLocalDepInfo. Changing the dirty entry to its // subsequent value may invalidate the sortedness. - std::sort(NLPDI.begin(), NLPDI.end()); + llvm::sort(NLPDI.begin(), NLPDI.end()); } ReverseNonLocalPtrDeps.erase(ReversePtrDepIt); Index: lib/Analysis/MemorySSA.cpp =================================================================== --- lib/Analysis/MemorySSA.cpp +++ lib/Analysis/MemorySSA.cpp @@ -1327,10 +1327,10 @@ SmallVector IDFBlocks; IDFs.calculate(IDFBlocks); - std::sort(IDFBlocks.begin(), IDFBlocks.end(), - [&BBNumbers](const BasicBlock *A, const BasicBlock *B) { - return BBNumbers.lookup(A) < BBNumbers.lookup(B); - }); + llvm::sort(IDFBlocks.begin(), IDFBlocks.end(), + [&BBNumbers](const BasicBlock *A, const BasicBlock *B) { + return BBNumbers.lookup(A) < BBNumbers.lookup(B); + }); // Now place MemoryPhi nodes. for (auto &BB : IDFBlocks) Index: lib/Analysis/ScalarEvolution.cpp =================================================================== --- lib/Analysis/ScalarEvolution.cpp +++ lib/Analysis/ScalarEvolution.cpp @@ -10650,7 +10650,7 @@ Terms.erase(std::unique(Terms.begin(), Terms.end()), Terms.end()); // Put larger terms first. - std::sort(Terms.begin(), Terms.end(), [](const SCEV *LHS, const SCEV *RHS) { + llvm::sort(Terms.begin(), Terms.end(), [](const SCEV *LHS, const SCEV *RHS) { return numberOfTerms(LHS) > numberOfTerms(RHS); }); Index: lib/Analysis/ScalarEvolutionExpander.cpp =================================================================== --- lib/Analysis/ScalarEvolutionExpander.cpp +++ lib/Analysis/ScalarEvolutionExpander.cpp @@ -1862,7 +1862,7 @@ Phis.push_back(&PN); if (TTI) - std::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) { + llvm::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) { // Put pointers at the back and make sure pointer < pointer = false. if (!LHS->getType()->isIntegerTy() || !RHS->getType()->isIntegerTy()) return RHS->getType()->isIntegerTy() && !LHS->getType()->isIntegerTy(); Index: lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- lib/Analysis/TargetLibraryInfo.cpp +++ lib/Analysis/TargetLibraryInfo.cpp @@ -1329,10 +1329,10 @@ void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef Fns) { VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end()); - std::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName); + llvm::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName); ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end()); - std::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName); + llvm::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName); } void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib( Index: lib/Bitcode/Reader/ValueList.cpp =================================================================== --- lib/Bitcode/Reader/ValueList.cpp +++ lib/Bitcode/Reader/ValueList.cpp @@ -144,7 +144,7 @@ void BitcodeReaderValueList::resolveConstantForwardRefs() { // Sort the values by-pointer so that they are efficient to look up with a // binary search. - std::sort(ResolveConstants.begin(), ResolveConstants.end()); + llvm::sort(ResolveConstants.begin(), ResolveConstants.end()); SmallVector NewOps; Index: lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriter.cpp +++ lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3474,7 +3474,7 @@ NameVals.push_back(VE.getValueID(RI.getValue())); // Sort the refs for determinism output, the vector returned by FS->refs() has // been initialized from a DenseSet. - std::sort(NameVals.begin() + SizeBeforeRefs, NameVals.end()); + llvm::sort(NameVals.begin() + SizeBeforeRefs, NameVals.end()); Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals, FSModRefsAbbrev); Index: lib/Bitcode/Writer/ValueEnumerator.cpp =================================================================== --- lib/Bitcode/Writer/ValueEnumerator.cpp +++ lib/Bitcode/Writer/ValueEnumerator.cpp @@ -183,7 +183,7 @@ return; bool IsGlobalValue = OM.isGlobalValue(ID); - std::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) { + llvm::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) { const Use *LU = L.first; const Use *RU = R.first; if (LU == RU) @@ -744,7 +744,7 @@ // and then sort by the original/current ID. Since the IDs are guaranteed to // be unique, the result of std::sort will be deterministic. There's no need // for std::stable_sort. - std::sort(Order.begin(), Order.end(), [this](MDIndex LHS, MDIndex RHS) { + llvm::sort(Order.begin(), Order.end(), [this](MDIndex LHS, MDIndex RHS) { return std::make_tuple(LHS.F, getMetadataTypeOrder(LHS.get(MDs)), LHS.ID) < std::make_tuple(RHS.F, getMetadataTypeOrder(RHS.get(MDs)), RHS.ID); }); Index: lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -2269,10 +2269,10 @@ for (const LocalVariable &L : Locals) if (L.DIVar->isParameter()) Params.push_back(&L); - std::sort(Params.begin(), Params.end(), - [](const LocalVariable *L, const LocalVariable *R) { - return L->DIVar->getArg() < R->DIVar->getArg(); - }); + llvm::sort(Params.begin(), Params.end(), + [](const LocalVariable *L, const LocalVariable *R) { + return L->DIVar->getArg() < R->DIVar->getArg(); + }); for (const LocalVariable *L : Params) emitLocalVariable(*L); Index: lib/CodeGen/AsmPrinter/DebugLocEntry.h =================================================================== --- lib/CodeGen/AsmPrinter/DebugLocEntry.h +++ lib/CodeGen/AsmPrinter/DebugLocEntry.h @@ -138,7 +138,7 @@ // \brief Sort the pieces by offset. // Remove any duplicate entries by dropping all but the first. void sortUniqueValues() { - std::sort(Values.begin(), Values.end()); + llvm::sort(Values.begin(), Values.end()); Values.erase( std::unique( Values.begin(), Values.end(), [](const Value &A, const Value &B) { Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -223,11 +223,11 @@ return A.Expr->isFragment(); }) && "multiple FI expressions without DW_OP_LLVM_fragment"); - std::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(), - [](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool { - return A.Expr->getFragmentInfo()->OffsetInBits < - B.Expr->getFragmentInfo()->OffsetInBits; - }); + llvm::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(), + [](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool { + return A.Expr->getFragmentInfo()->OffsetInBits < + B.Expr->getFragmentInfo()->OffsetInBits; + }); return FrameIndexExprs; } @@ -550,21 +550,22 @@ /// Sort and unique GVEs by comparing their fragment offset. static SmallVectorImpl & sortGlobalExprs(SmallVectorImpl &GVEs) { - std::sort(GVEs.begin(), GVEs.end(), - [](DwarfCompileUnit::GlobalExpr A, DwarfCompileUnit::GlobalExpr B) { - // Sort order: first null exprs, then exprs without fragment - // info, then sort by fragment offset in bits. - // FIXME: Come up with a more comprehensive comparator so - // the sorting isn't non-deterministic, and so the following - // std::unique call works correctly. - if (!A.Expr || !B.Expr) - return !!B.Expr; - auto FragmentA = A.Expr->getFragmentInfo(); - auto FragmentB = B.Expr->getFragmentInfo(); - if (!FragmentA || !FragmentB) - return !!FragmentB; - return FragmentA->OffsetInBits < FragmentB->OffsetInBits; - }); + llvm::sort(GVEs.begin(), GVEs.end(), + [](DwarfCompileUnit::GlobalExpr A, + DwarfCompileUnit::GlobalExpr B) { + // Sort order: first null exprs, then exprs without fragment + // info, then sort by fragment offset in bits. + // FIXME: Come up with a more comprehensive comparator so + // the sorting isn't non-deterministic, and so the following + // std::unique call works correctly. + if (!A.Expr || !B.Expr) + return !!B.Expr; + auto FragmentA = A.Expr->getFragmentInfo(); + auto FragmentB = B.Expr->getFragmentInfo(); + if (!FragmentA || !FragmentB) + return !!FragmentB; + return FragmentA->OffsetInBits < FragmentB->OffsetInBits; + }); GVEs.erase(std::unique(GVEs.begin(), GVEs.end(), [](DwarfCompileUnit::GlobalExpr A, DwarfCompileUnit::GlobalExpr B) { @@ -1829,10 +1830,10 @@ } // Sort the CU list (again, to ensure consistent output order). - std::sort(CUs.begin(), CUs.end(), - [](const DwarfCompileUnit *A, const DwarfCompileUnit *B) { - return A->getUniqueID() < B->getUniqueID(); - }); + llvm::sort(CUs.begin(), CUs.end(), + [](const DwarfCompileUnit *A, const DwarfCompileUnit *B) { + return A->getUniqueID() < B->getUniqueID(); + }); // Emit an arange table for each CU we used. for (DwarfCompileUnit *CU : CUs) { Index: lib/CodeGen/AsmPrinter/EHStreamer.cpp =================================================================== --- lib/CodeGen/AsmPrinter/EHStreamer.cpp +++ lib/CodeGen/AsmPrinter/EHStreamer.cpp @@ -359,9 +359,9 @@ LandingPads.push_back(&PadInfos[i]); // Order landing pads lexicographically by type id. - std::sort(LandingPads.begin(), LandingPads.end(), - [](const LandingPadInfo *L, - const LandingPadInfo *R) { return L->TypeIds < R->TypeIds; }); + llvm::sort(LandingPads.begin(), LandingPads.end(), + [](const LandingPadInfo *L, + const LandingPadInfo *R) { return L->TypeIds < R->TypeIds; }); // Compute the actions table and gather the first action index for each // landing pad site. Index: lib/CodeGen/GlobalISel/LegalizerInfo.cpp =================================================================== --- lib/CodeGen/GlobalISel/LegalizerInfo.cpp +++ lib/CodeGen/GlobalISel/LegalizerInfo.cpp @@ -148,15 +148,16 @@ if (TypeIdx < ScalarSizeChangeStrategies[OpcodeIdx].size() && ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx] != nullptr) S = ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx]; - std::sort(ScalarSpecifiedActions.begin(), ScalarSpecifiedActions.end()); + llvm::sort(ScalarSpecifiedActions.begin(), + ScalarSpecifiedActions.end()); checkPartialSizeAndActionsVector(ScalarSpecifiedActions); setScalarAction(Opcode, TypeIdx, S(ScalarSpecifiedActions)); } // 2. Handle pointer types for (auto PointerSpecifiedActions : AddressSpace2SpecifiedActions) { - std::sort(PointerSpecifiedActions.second.begin(), - PointerSpecifiedActions.second.end()); + llvm::sort(PointerSpecifiedActions.second.begin(), + PointerSpecifiedActions.second.end()); checkPartialSizeAndActionsVector(PointerSpecifiedActions.second); // For pointer types, we assume that there isn't a meaningfull way // to change the number of bits used in the pointer. @@ -168,8 +169,8 @@ // 3. Handle vector types SizeAndActionsVec ElementSizesSeen; for (auto VectorSpecifiedActions : ElemSize2SpecifiedActions) { - std::sort(VectorSpecifiedActions.second.begin(), - VectorSpecifiedActions.second.end()); + llvm::sort(VectorSpecifiedActions.second.begin(), + VectorSpecifiedActions.second.end()); const uint16_t ElementSize = VectorSpecifiedActions.first; ElementSizesSeen.push_back({ElementSize, Legal}); checkPartialSizeAndActionsVector(VectorSpecifiedActions.second); @@ -187,7 +188,7 @@ Opcode, TypeIdx, ElementSize, moreToWiderTypesAndLessToWidest(NumElementsActions)); } - std::sort(ElementSizesSeen.begin(), ElementSizesSeen.end()); + llvm::sort(ElementSizesSeen.begin(), ElementSizesSeen.end()); SizeChangeStrategy VectorElementSizeChangeStrategy = &unsupportedForDifferentSizes; if (TypeIdx < VectorElementSizeChangeStrategies[OpcodeIdx].size() && Index: lib/CodeGen/LocalStackSlotAllocation.cpp =================================================================== --- lib/CodeGen/LocalStackSlotAllocation.cpp +++ lib/CodeGen/LocalStackSlotAllocation.cpp @@ -335,7 +335,7 @@ // Sort the frame references by local offset. // Use frame index as a tie-breaker in case MI's have the same offset. - std::sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end()); + llvm::sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end()); MachineBasicBlock *Entry = &Fn.front(); Index: lib/CodeGen/MachineBasicBlock.cpp =================================================================== --- lib/CodeGen/MachineBasicBlock.cpp +++ lib/CodeGen/MachineBasicBlock.cpp @@ -456,10 +456,10 @@ } void MachineBasicBlock::sortUniqueLiveIns() { - std::sort(LiveIns.begin(), LiveIns.end(), - [](const RegisterMaskPair &LI0, const RegisterMaskPair &LI1) { - return LI0.PhysReg < LI1.PhysReg; - }); + llvm::sort(LiveIns.begin(), LiveIns.end(), + [](const RegisterMaskPair &LI0, const RegisterMaskPair &LI1) { + return LI0.PhysReg < LI1.PhysReg; + }); // Liveins are sorted by physreg now we can merge their lanemasks. LiveInVector::const_iterator I = LiveIns.begin(); LiveInVector::const_iterator J; Index: lib/CodeGen/MachinePipeliner.cpp =================================================================== --- lib/CodeGen/MachinePipeliner.cpp +++ lib/CodeGen/MachinePipeliner.cpp @@ -918,7 +918,7 @@ } }); - std::sort(NodeSets.begin(), NodeSets.end(), std::greater()); + llvm::sort(NodeSets.begin(), NodeSets.end(), std::greater()); groupRemainingNodes(NodeSets); @@ -1808,7 +1808,8 @@ RecRPTracker.closeBottom(); std::vector SUnits(NS.begin(), NS.end()); - std::sort(SUnits.begin(), SUnits.end(), [](const SUnit *A, const SUnit *B) { + llvm::sort(SUnits.begin(), SUnits.end(), + [](const SUnit *A, const SUnit *B) { return A->NodeNum > B->NodeNum; }); @@ -3915,7 +3916,7 @@ }; // sort, so that we can perform a binary search - std::sort(Indices.begin(), Indices.end(), CompareKey); + llvm::sort(Indices.begin(), Indices.end(), CompareKey); bool Valid = true; // for each SUnit in the NodeOrder, check whether Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -1562,7 +1562,7 @@ if (MemOpRecords.size() < 2) return; - std::sort(MemOpRecords.begin(), MemOpRecords.end()); + llvm::sort(MemOpRecords.begin(), MemOpRecords.end()); unsigned ClusterLength = 1; for (unsigned Idx = 0, End = MemOpRecords.size(); Idx < (End - 1); ++Idx) { SUnit *SUa = MemOpRecords[Idx].SU; Index: lib/CodeGen/ReachingDefAnalysis.cpp =================================================================== --- lib/CodeGen/ReachingDefAnalysis.cpp +++ lib/CodeGen/ReachingDefAnalysis.cpp @@ -157,7 +157,7 @@ // Sorting all reaching defs found for a ceartin reg unit in a given BB. for (MBBDefsInfo &MBBDefs : MBBReachingDefs) { for (MBBRegUnitDefs &RegUnitDefs : MBBDefs) - std::sort(RegUnitDefs.begin(), RegUnitDefs.end()); + llvm::sort(RegUnitDefs.begin(), RegUnitDefs.end()); } return false; Index: lib/CodeGen/RegisterUsageInfo.cpp =================================================================== --- lib/CodeGen/RegisterUsageInfo.cpp +++ lib/CodeGen/RegisterUsageInfo.cpp @@ -83,7 +83,7 @@ FPRMPairVector.push_back(&RegMask); // sort the vector to print analysis in alphabatic order of function name. - std::sort( + llvm::sort( FPRMPairVector.begin(), FPRMPairVector.end(), [](const FuncPtrRegMaskPair *A, const FuncPtrRegMaskPair *B) -> bool { return A->first->getName() < B->first->getName(); Index: lib/CodeGen/ScheduleDAGInstrs.cpp =================================================================== --- lib/CodeGen/ScheduleDAGInstrs.cpp +++ lib/CodeGen/ScheduleDAGInstrs.cpp @@ -992,7 +992,7 @@ for (auto &I : loads) for (auto *SU : I.second) NodeNums.push_back(SU->NodeNum); - std::sort(NodeNums.begin(), NodeNums.end()); + llvm::sort(NodeNums.begin(), NodeNums.end()); // The N last elements in NodeNums will be removed, and the SU with // the lowest NodeNum of them will become the new BarrierChain to Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12200,8 +12200,8 @@ // Sort the slices so that elements that are likely to be next to each // other in memory are next to each other in the list. - std::sort(LoadedSlices.begin(), LoadedSlices.end(), - [](const LoadedSlice &LHS, const LoadedSlice &RHS) { + llvm::sort(LoadedSlices.begin(), LoadedSlices.end(), + [](const LoadedSlice &LHS, const LoadedSlice &RHS) { assert(LHS.Origin == RHS.Origin && "Different bases not implemented."); return LHS.getOffsetFromBase() < RHS.getOffsetFromBase(); }); @@ -13152,10 +13152,10 @@ // Sort the memory operands according to their distance from the // base pointer. - std::sort(StoreNodes.begin(), StoreNodes.end(), - [](MemOpLink LHS, MemOpLink RHS) { - return LHS.OffsetFromBase < RHS.OffsetFromBase; - }); + llvm::sort(StoreNodes.begin(), StoreNodes.end(), + [](MemOpLink LHS, MemOpLink RHS) { + return LHS.OffsetFromBase < RHS.OffsetFromBase; + }); // Store Merge attempts to merge the lowest stores. This generally // works out as if successful, as the remaining stores are checked Index: lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -243,7 +243,7 @@ return; // Sort them in increasing order. - std::sort(Offsets.begin(), Offsets.end()); + llvm::sort(Offsets.begin(), Offsets.end()); // Check if the loads are close enough. SmallVector Loads; Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7640,7 +7640,7 @@ } // Sort the uses, so that all the uses from a given User are together. - std::sort(Uses.begin(), Uses.end()); + llvm::sort(Uses.begin(), Uses.end()); for (unsigned UseIndex = 0, UseIndexEnd = Uses.size(); UseIndex != UseIndexEnd; ) { Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2489,8 +2489,8 @@ assert(CC.Low == CC.High && "Input clusters must be single-case"); #endif - std::sort(Clusters.begin(), Clusters.end(), - [](const CaseCluster &a, const CaseCluster &b) { + llvm::sort(Clusters.begin(), Clusters.end(), + [](const CaseCluster &a, const CaseCluster &b) { return a.Low->getValue().slt(b.Low->getValue()); }); @@ -6079,10 +6079,10 @@ GA->getGlobal(), getCurSDLoc(), Val.getValueType(), GA->getOffset())}); } - std::sort(Targets.begin(), Targets.end(), - [](const BranchFunnelTarget &T1, const BranchFunnelTarget &T2) { - return T1.Offset < T2.Offset; - }); + llvm::sort(Targets.begin(), Targets.end(), + [](const BranchFunnelTarget &T1, const BranchFunnelTarget &T2) { + return T1.Offset < T2.Offset; + }); for (auto &T : Targets) { Ops.push_back(DAG.getTargetConstant(T.Offset, getCurSDLoc(), MVT::i32)); @@ -9427,7 +9427,7 @@ } BitTestInfo BTI; - std::sort(CBV.begin(), CBV.end(), [](const CaseBits &a, const CaseBits &b) { + llvm::sort(CBV.begin(), CBV.end(), [](const CaseBits &a, const CaseBits &b) { // Sort by probability first, number of bits second, bit mask third. if (a.ExtraProb != b.ExtraProb) return a.ExtraProb > b.ExtraProb; @@ -9626,8 +9626,8 @@ // checked first. However, two clusters can have the same probability in // which case their relative ordering is non-deterministic. So we use Low // as a tie-breaker as clusters are guaranteed to never overlap. - std::sort(W.FirstCluster, W.LastCluster + 1, - [](const CaseCluster &a, const CaseCluster &b) { + llvm::sort(W.FirstCluster, W.LastCluster + 1, + [](const CaseCluster &a, const CaseCluster &b) { return a.Prob != b.Prob ? a.Prob > b.Prob : a.Low->getValue().slt(b.Low->getValue()); Index: lib/CodeGen/SlotIndexes.cpp =================================================================== --- lib/CodeGen/SlotIndexes.cpp +++ lib/CodeGen/SlotIndexes.cpp @@ -94,7 +94,7 @@ } // Sort the Idx2MBBMap - std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); + llvm::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); DEBUG(mf->print(dbgs(), this)); Index: lib/CodeGen/StackColoring.cpp =================================================================== --- lib/CodeGen/StackColoring.cpp +++ lib/CodeGen/StackColoring.cpp @@ -1224,7 +1224,7 @@ }); for (auto &s : LiveStarts) - std::sort(s.begin(), s.end()); + llvm::sort(s.begin(), s.end()); bool Changed = true; while (Changed) { Index: lib/CodeGen/StackMaps.cpp =================================================================== --- lib/CodeGen/StackMaps.cpp +++ lib/CodeGen/StackMaps.cpp @@ -268,11 +268,11 @@ // in the list. Merge entries that refer to the same dwarf register and use // the maximum size that needs to be spilled. - std::sort(LiveOuts.begin(), LiveOuts.end(), - [](const LiveOutReg &LHS, const LiveOutReg &RHS) { - // Only sort by the dwarf register number. - return LHS.DwarfRegNum < RHS.DwarfRegNum; - }); + llvm::sort(LiveOuts.begin(), LiveOuts.end(), + [](const LiveOutReg &LHS, const LiveOutReg &RHS) { + // Only sort by the dwarf register number. + return LHS.DwarfRegNum < RHS.DwarfRegNum; + }); for (auto I = LiveOuts.begin(), E = LiveOuts.end(); I != E; ++I) { for (auto II = std::next(I); II != E; ++II) { Index: lib/CodeGen/StackSlotColoring.cpp =================================================================== --- lib/CodeGen/StackSlotColoring.cpp +++ lib/CodeGen/StackSlotColoring.cpp @@ -209,8 +209,8 @@ Intervals.reserve(LS->getNumIntervals()); for (auto &I : *LS) Intervals.push_back(&I); - std::sort(Intervals.begin(), Intervals.end(), - [](Pair *LHS, Pair *RHS) { return LHS->first < RHS->first; }); + llvm::sort(Intervals.begin(), Intervals.end(), + [](Pair *LHS, Pair *RHS) { return LHS->first < RHS->first; }); // Gather all spill slots into a list. DEBUG(dbgs() << "Spill slot intervals:\n"); Index: lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp =================================================================== --- lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp +++ lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp @@ -79,7 +79,7 @@ for (const auto &M : Mappings) Ids.push_back(&M); - std::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) { + llvm::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) { return Strings.getStringId(L1->getKey()) < Strings.getStringId(L2->getKey()); }); Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -108,12 +108,12 @@ // Sort the contributions so that any invalid ones are placed at // the start of the contributions vector. This way they are reported // first. - std::sort(Contributions.begin(), Contributions.end(), - [](const Optional &L, - const Optional &R) { - if (L && R) return L->Base < R->Base; - return R.hasValue(); - }); + llvm::sort(Contributions.begin(), Contributions.end(), + [](const Optional &L, + const Optional &R) { + if (L && R) return L->Base < R->Base; + return R.hasValue(); + }); // Uniquify contributions, as it is possible that units (specifically // type units in dwo or dwp files) share contributions. We don't want Index: lib/DebugInfo/DWARF/DWARFDebugAranges.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -80,7 +80,7 @@ void DWARFDebugAranges::construct() { std::multiset ValidCUs; // Maintain the set of CUs describing // a current address range. - std::sort(Endpoints.begin(), Endpoints.end()); + llvm::sort(Endpoints.begin(), Endpoints.end()); uint64_t PrevAddress = -1ULL; for (const auto &E : Endpoints) { if (PrevAddress < E.Address && !ValidCUs.empty()) { Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -829,7 +829,7 @@ // Sort all sequences so that address lookup will work faster. if (!Sequences.empty()) { - std::sort(Sequences.begin(), Sequences.end(), Sequence::orderByLowPC); + llvm::sort(Sequences.begin(), Sequences.end(), Sequence::orderByLowPC); // Note: actually, instruction address ranges of sequences should not // overlap (in shared objects and executables). If they do, the address // lookup would still work, though, but result would be ambiguous. Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -195,7 +195,7 @@ !isa(V) && !isa(V) && !isa(V); if (auto *BA = dyn_cast(V)) ID = OM.lookup(BA->getBasicBlock()).first; - std::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) { + llvm::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) { const Use *LU = L.first; const Use *RU = R.first; if (LU == RU) Index: lib/IR/Attributes.cpp =================================================================== --- lib/IR/Attributes.cpp +++ lib/IR/Attributes.cpp @@ -650,7 +650,7 @@ FoldingSetNodeID ID; SmallVector SortedAttrs(Attrs.begin(), Attrs.end()); - std::sort(SortedAttrs.begin(), SortedAttrs.end()); + llvm::sort(SortedAttrs.begin(), SortedAttrs.end()); for (Attribute Attr : SortedAttrs) Attr.Profile(ID); Index: lib/IR/Metadata.cpp =================================================================== --- lib/IR/Metadata.cpp +++ lib/IR/Metadata.cpp @@ -237,7 +237,7 @@ // Copy out uses since UseMap will get touched below. using UseTy = std::pair>; SmallVector Uses(UseMap.begin(), UseMap.end()); - std::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) { + llvm::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) { return L.second.second < R.second.second; }); for (const auto &Pair : Uses) { @@ -290,7 +290,7 @@ // Copy out uses since UseMap could get touched below. using UseTy = std::pair>; SmallVector Uses(UseMap.begin(), UseMap.end()); - std::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) { + llvm::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) { return L.second.second < R.second.second; }); UseMap.clear(); Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -2254,7 +2254,7 @@ if (isa(BB.front())) { SmallVector Preds(pred_begin(&BB), pred_end(&BB)); SmallVector, 8> Values; - std::sort(Preds.begin(), Preds.end()); + llvm::sort(Preds.begin(), Preds.end()); for (const PHINode &PN : BB.phis()) { // Ensure that PHI nodes have at least one entry! Assert(PN.getNumIncomingValues() != 0, @@ -2272,7 +2272,7 @@ for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) Values.push_back( std::make_pair(PN.getIncomingBlock(i), PN.getIncomingValue(i))); - std::sort(Values.begin(), Values.end()); + llvm::sort(Values.begin(), Values.end()); for (unsigned i = 0, e = Values.size(); i != e; ++i) { // Check to make sure that if there is more than one entry for a Index: lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- lib/LTO/ThinLTOCodeGenerator.cpp +++ lib/LTO/ThinLTOCodeGenerator.cpp @@ -950,12 +950,12 @@ std::vector ModulesOrdering; ModulesOrdering.resize(Modules.size()); std::iota(ModulesOrdering.begin(), ModulesOrdering.end(), 0); - std::sort(ModulesOrdering.begin(), ModulesOrdering.end(), - [&](int LeftIndex, int RightIndex) { - auto LSize = Modules[LeftIndex].getBuffer().size(); - auto RSize = Modules[RightIndex].getBuffer().size(); - return LSize > RSize; - }); + llvm::sort(ModulesOrdering.begin(), ModulesOrdering.end(), + [&](int LeftIndex, int RightIndex) { + auto LSize = Modules[LeftIndex].getBuffer().size(); + auto RSize = Modules[RightIndex].getBuffer().size(); + return LSize > RSize; + }); // Parallel optimizer + codegen { Index: lib/MC/MachObjectWriter.cpp =================================================================== --- lib/MC/MachObjectWriter.cpp +++ lib/MC/MachObjectWriter.cpp @@ -593,8 +593,8 @@ } // External and undefined symbols are required to be in lexicographic order. - std::sort(ExternalSymbolData.begin(), ExternalSymbolData.end()); - std::sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end()); + llvm::sort(ExternalSymbolData.begin(), ExternalSymbolData.end()); + llvm::sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end()); // Set the symbol indices. Index = 0; Index: lib/MC/WinCOFFObjectWriter.cpp =================================================================== --- lib/MC/WinCOFFObjectWriter.cpp +++ lib/MC/WinCOFFObjectWriter.cpp @@ -567,10 +567,10 @@ std::vector Arr; for (auto &Section : Sections) Arr.push_back(Section.get()); - std::sort(Arr.begin(), Arr.end(), - [](const COFFSection *A, const COFFSection *B) { - return A->Number < B->Number; - }); + llvm::sort(Arr.begin(), Arr.end(), + [](const COFFSection *A, const COFFSection *B) { + return A->Number < B->Number; + }); for (auto &Section : Arr) { if (Section->Number == -1) Index: lib/ProfileData/Coverage/CoverageMapping.cpp =================================================================== --- lib/ProfileData/Coverage/CoverageMapping.cpp +++ lib/ProfileData/Coverage/CoverageMapping.cpp @@ -83,7 +83,7 @@ return Counter::getZero(); // Group the terms by counter ID. - std::sort(Terms.begin(), Terms.end(), [](const Term &LHS, const Term &RHS) { + llvm::sort(Terms.begin(), Terms.end(), [](const Term &LHS, const Term &RHS) { return LHS.CounterID < RHS.CounterID; }); @@ -457,8 +457,8 @@ /// Sort a nested sequence of regions from a single file. static void sortNestedRegions(MutableArrayRef Regions) { - std::sort(Regions.begin(), Regions.end(), [](const CountedRegion &LHS, - const CountedRegion &RHS) { + llvm::sort(Regions.begin(), Regions.end(), [](const CountedRegion &LHS, + const CountedRegion &RHS) { if (LHS.startLoc() != RHS.startLoc()) return LHS.startLoc() < RHS.startLoc(); if (LHS.endLoc() != RHS.endLoc()) @@ -555,7 +555,7 @@ for (const auto &Function : getCoveredFunctions()) Filenames.insert(Filenames.end(), Function.Filenames.begin(), Function.Filenames.end()); - std::sort(Filenames.begin(), Filenames.end()); + llvm::sort(Filenames.begin(), Filenames.end()); auto Last = std::unique(Filenames.begin(), Filenames.end()); Filenames.erase(Last, Filenames.end()); return Filenames; Index: lib/ProfileData/GCOV.cpp =================================================================== --- lib/ProfileData/GCOV.cpp +++ lib/ProfileData/GCOV.cpp @@ -592,7 +592,7 @@ SmallVector Filenames; for (const auto &LI : LineInfo) Filenames.push_back(LI.first()); - std::sort(Filenames.begin(), Filenames.end()); + llvm::sort(Filenames.begin(), Filenames.end()); for (StringRef Filename : Filenames) { auto AllLines = LineConsumer(Filename); Index: lib/ProfileData/ProfileSummaryBuilder.cpp =================================================================== --- lib/ProfileData/ProfileSummaryBuilder.cpp +++ lib/ProfileData/ProfileSummaryBuilder.cpp @@ -58,7 +58,7 @@ void ProfileSummaryBuilder::computeDetailedSummary() { if (DetailedSummaryCutoffs.empty()) return; - std::sort(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end()); + llvm::sort(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end()); auto Iter = CountFrequencies.begin(); const auto End = CountFrequencies.end(); Index: lib/Support/SourceMgr.cpp =================================================================== --- lib/Support/SourceMgr.cpp +++ lib/Support/SourceMgr.cpp @@ -247,7 +247,7 @@ : SM(&sm), Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Kind(Kind), Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()), FixIts(Hints.begin(), Hints.end()) { - std::sort(FixIts.begin(), FixIts.end()); + llvm::sort(FixIts.begin(), FixIts.end()); } static void buildFixItLine(std::string &CaretLine, std::string &FixItLine, Index: lib/Support/Timer.cpp =================================================================== --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -284,7 +284,7 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) { // Sort the timers in descending order by amount of time taken. - std::sort(TimersToPrint.begin(), TimersToPrint.end()); + llvm::sort(TimersToPrint.begin(), TimersToPrint.end()); TimeRecord Total; for (const PrintRecord &Record : TimersToPrint) Index: lib/TableGen/Record.cpp =================================================================== --- lib/TableGen/Record.cpp +++ lib/TableGen/Record.cpp @@ -157,10 +157,10 @@ SmallVector Classes(UnsortedClasses.begin(), UnsortedClasses.end()); - std::sort(Classes.begin(), Classes.end(), - [](Record *LHS, Record *RHS) { - return LHS->getNameInitAsString() < RHS->getNameInitAsString(); - }); + llvm::sort(Classes.begin(), Classes.end(), + [](Record *LHS, Record *RHS) { + return LHS->getNameInitAsString() < RHS->getNameInitAsString(); + }); FoldingSetNodeID ID; ProfileRecordRecTy(ID, Classes); Index: lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp =================================================================== --- lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp +++ lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp @@ -375,9 +375,9 @@ // Now we have a set of sets, order them by start address so // we can iterate over them sequentially. - std::sort(V.begin(), V.end(), - [](const std::vector &A, - const std::vector &B) { + llvm::sort(V.begin(), V.end(), + [](const std::vector &A, + const std::vector &B) { return A.front()->startsBefore(B.front()); }); @@ -451,7 +451,7 @@ // change them to! // Final tie-break with instruction order so pass output is stable (i.e. not // dependent on malloc'd pointer values). - std::sort(GV.begin(), GV.end(), [](const Chain *G1, const Chain *G2) { + llvm::sort(GV.begin(), GV.end(), [](const Chain *G1, const Chain *G2) { if (G1->size() != G2->size()) return G1->size() > G2->size(); if (G1->requiresFixup() != G2->requiresFixup()) Index: lib/Target/AMDGPU/GCNIterativeScheduler.cpp =================================================================== --- lib/Target/AMDGPU/GCNIterativeScheduler.cpp +++ lib/Target/AMDGPU/GCNIterativeScheduler.cpp @@ -433,7 +433,7 @@ // Sort recorded regions by pressure - highest at the front void GCNIterativeScheduler::sortRegionsByPressure(unsigned TargetOcc) { const auto &ST = MF.getSubtarget(); - std::sort(Regions.begin(), Regions.end(), + llvm::sort(Regions.begin(), Regions.end(), [&ST, TargetOcc](const Region *R1, const Region *R2) { return R2->MaxPressure.less(ST, R1->MaxPressure, TargetOcc); }); Index: lib/Target/ARM/ARMBaseInstrInfo.cpp =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.cpp +++ lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1407,12 +1407,12 @@ SmallVector ScratchRegs; for(unsigned I = 5; I < MI->getNumOperands(); ++I) ScratchRegs.push_back(MI->getOperand(I).getReg()); - std::sort(ScratchRegs.begin(), ScratchRegs.end(), - [&TRI](const unsigned &Reg1, - const unsigned &Reg2) -> bool { - return TRI.getEncodingValue(Reg1) < - TRI.getEncodingValue(Reg2); - }); + llvm::sort(ScratchRegs.begin(), ScratchRegs.end(), + [&TRI](const unsigned &Reg1, + const unsigned &Reg2) -> bool { + return TRI.getEncodingValue(Reg1) < + TRI.getEncodingValue(Reg2); + }); for (const auto &Reg : ScratchRegs) { LDM.addReg(Reg, RegState::Define); Index: lib/Target/ARM/ARMFrameLowering.cpp =================================================================== --- lib/Target/ARM/ARMFrameLowering.cpp +++ lib/Target/ARM/ARMFrameLowering.cpp @@ -994,8 +994,8 @@ if (Regs.empty()) continue; - std::sort(Regs.begin(), Regs.end(), [&](const RegAndKill &LHS, - const RegAndKill &RHS) { + llvm::sort(Regs.begin(), Regs.end(), [&](const RegAndKill &LHS, + const RegAndKill &RHS) { return TRI.getEncodingValue(LHS.first) < TRI.getEncodingValue(RHS.first); }); @@ -1091,7 +1091,7 @@ if (Regs.empty()) continue; - std::sort(Regs.begin(), Regs.end(), [&](unsigned LHS, unsigned RHS) { + llvm::sort(Regs.begin(), Regs.end(), [&](unsigned LHS, unsigned RHS) { return TRI.getEncodingValue(LHS) < TRI.getEncodingValue(RHS); }); Index: lib/Target/ARM/ARMLoadStoreOptimizer.cpp =================================================================== --- lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -1834,7 +1834,7 @@ auto LessThan = [](const MergeCandidate* M0, const MergeCandidate *M1) { return M0->InsertPos < M1->InsertPos; }; - std::sort(Candidates.begin(), Candidates.end(), LessThan); + llvm::sort(Candidates.begin(), Candidates.end(), LessThan); // Go through list of candidates and merge. bool Changed = false; @@ -2172,13 +2172,13 @@ bool RetVal = false; // Sort by offset (in reverse order). - std::sort(Ops.begin(), Ops.end(), - [](const MachineInstr *LHS, const MachineInstr *RHS) { - int LOffset = getMemoryOpOffset(*LHS); - int ROffset = getMemoryOpOffset(*RHS); - assert(LHS == RHS || LOffset != ROffset); - return LOffset > ROffset; - }); + llvm::sort(Ops.begin(), Ops.end(), + [](const MachineInstr *LHS, const MachineInstr *RHS) { + int LOffset = getMemoryOpOffset(*LHS); + int ROffset = getMemoryOpOffset(*RHS); + assert(LHS == RHS || LOffset != ROffset); + return LOffset > ROffset; + }); // The loads / stores of the same base are in order. Scan them from first to // last and check for the following: Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -1068,7 +1068,7 @@ if (Contents.empty()) return; - std::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag); + llvm::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag); ARMELFStreamer &Streamer = getStreamer(); Index: lib/Target/Hexagon/HexagonBlockRanges.cpp =================================================================== --- lib/Target/Hexagon/HexagonBlockRanges.cpp +++ lib/Target/Hexagon/HexagonBlockRanges.cpp @@ -85,7 +85,7 @@ if (empty()) return; - std::sort(begin(), end()); + llvm::sort(begin(), end()); iterator Iter = begin(); while (Iter != end()-1) { Index: lib/Target/Hexagon/HexagonConstExtenders.cpp =================================================================== --- lib/Target/Hexagon/HexagonConstExtenders.cpp +++ lib/Target/Hexagon/HexagonConstExtenders.cpp @@ -1881,7 +1881,7 @@ AssignmentMap IMap; collect(MF); - std::sort(Extenders.begin(), Extenders.end(), + llvm::sort(Extenders.begin(), Extenders.end(), [](const ExtDesc &A, const ExtDesc &B) { return ExtValue(A) < ExtValue(B); }); Index: lib/Target/Hexagon/HexagonGenInsert.cpp =================================================================== --- lib/Target/Hexagon/HexagonGenInsert.cpp +++ lib/Target/Hexagon/HexagonGenInsert.cpp @@ -632,7 +632,7 @@ SortableVectorType VRs; for (RegisterOrdering::iterator I = RB.begin(), E = RB.end(); I != E; ++I) VRs.push_back(I->first); - std::sort(VRs.begin(), VRs.end(), LexCmp); + llvm::sort(VRs.begin(), VRs.end(), LexCmp); // Transfer the results to the outgoing register ordering. for (unsigned i = 0, n = VRs.size(); i < n; ++i) RO.insert(std::make_pair(VRs[i], i)); Index: lib/Target/Hexagon/HexagonStoreWidening.cpp =================================================================== --- lib/Target/Hexagon/HexagonStoreWidening.cpp +++ lib/Target/Hexagon/HexagonStoreWidening.cpp @@ -576,7 +576,7 @@ }; for (auto &G : SGs) { assert(G.size() > 1 && "Store group with fewer than 2 elements"); - std::sort(G.begin(), G.end(), Less); + llvm::sort(G.begin(), G.end(), Less); Changed |= processStoreGroup(G); } Index: lib/Target/Hexagon/RDFDeadCode.cpp =================================================================== --- lib/Target/Hexagon/RDFDeadCode.cpp +++ lib/Target/Hexagon/RDFDeadCode.cpp @@ -214,7 +214,7 @@ return false; return A.Id < B.Id; }; - std::sort(DRNs.begin(), DRNs.end(), UsesFirst); + llvm::sort(DRNs.begin(), DRNs.end(), UsesFirst); if (trace()) dbgs() << "Removing dead ref nodes:\n"; Index: lib/Target/Hexagon/RDFGraph.cpp =================================================================== --- lib/Target/Hexagon/RDFGraph.cpp +++ lib/Target/Hexagon/RDFGraph.cpp @@ -1471,7 +1471,7 @@ // and add a def for each S in the closure. // Sort the refs so that the phis will be created in a deterministic order. - std::sort(MaxRefs.begin(), MaxRefs.end()); + llvm::sort(MaxRefs.begin(), MaxRefs.end()); // Remove duplicates. auto NewEnd = std::unique(MaxRefs.begin(), MaxRefs.end()); MaxRefs.erase(NewEnd, MaxRefs.end()); Index: lib/Target/Hexagon/RDFLiveness.cpp =================================================================== --- lib/Target/Hexagon/RDFLiveness.cpp +++ lib/Target/Hexagon/RDFLiveness.cpp @@ -207,7 +207,7 @@ }; std::vector Tmp(Owners.begin(), Owners.end()); - std::sort(Tmp.begin(), Tmp.end(), Less); + llvm::sort(Tmp.begin(), Tmp.end(), Less); // The vector is a list of instructions, so that defs coming from // the same instruction don't need to be artificially ordered. @@ -813,7 +813,7 @@ std::vector LV; for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I) LV.push_back(RegisterRef(I->PhysReg, I->LaneMask)); - std::sort(LV.begin(), LV.end()); + llvm::sort(LV.begin(), LV.end()); dbgs() << printMBBReference(B) << "\t rec = {"; for (auto I : LV) dbgs() << ' ' << Print(I, DFG); @@ -824,7 +824,7 @@ const RegisterAggr &LG = LiveMap[&B]; for (auto I = LG.rr_begin(), E = LG.rr_end(); I != E; ++I) LV.push_back(*I); - std::sort(LV.begin(), LV.end()); + llvm::sort(LV.begin(), LV.end()); dbgs() << "\tcomp = {"; for (auto I : LV) dbgs() << ' ' << Print(I, DFG); Index: lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -436,10 +436,10 @@ return; // Sort relocations by the address they are applied to. - std::sort(Relocs.begin(), Relocs.end(), - [](const ELFRelocationEntry &A, const ELFRelocationEntry &B) { - return A.Offset < B.Offset; - }); + llvm::sort(Relocs.begin(), Relocs.end(), + [](const ELFRelocationEntry &A, const ELFRelocationEntry &B) { + return A.Offset < B.Offset; + }); std::list Sorted; std::list Remainder; Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -1297,7 +1297,7 @@ for (auto &I : ValueRots) { ValueRotsVec.push_back(I.second); } - std::sort(ValueRotsVec.begin(), ValueRotsVec.end()); + llvm::sort(ValueRotsVec.begin(), ValueRotsVec.end()); } // In 64-bit mode, rlwinm and friends have a rotation operator that Index: lib/Target/WebAssembly/WebAssemblyRegColoring.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -115,16 +115,16 @@ // registers), by weight next, and then by position. // TODO: Investigate more intelligent sorting heuristics. For starters, we // should try to coalesce adjacent live intervals before non-adjacent ones. - std::sort(SortedIntervals.begin(), SortedIntervals.end(), - [MRI](LiveInterval *LHS, LiveInterval *RHS) { - if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg)) - return MRI->isLiveIn(LHS->reg); - if (LHS->weight != RHS->weight) - return LHS->weight > RHS->weight; - if (LHS->empty() || RHS->empty()) - return !LHS->empty() && RHS->empty(); - return *LHS < *RHS; - }); + llvm::sort(SortedIntervals.begin(), SortedIntervals.end(), + [MRI](LiveInterval *LHS, LiveInterval *RHS) { + if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg)) + return MRI->isLiveIn(LHS->reg); + if (LHS->weight != RHS->weight) + return LHS->weight > RHS->weight; + if (LHS->empty() || RHS->empty()) + return !LHS->empty() && RHS->empty(); + return *LHS < *RHS; + }); DEBUG(dbgs() << "Coloring register intervals:\n"); SmallVector SlotMapping(SortedIntervals.size(), -1u); Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -11540,11 +11540,11 @@ SmallVector LoInputs; copy_if(LoMask, std::back_inserter(LoInputs), [](int M) { return M >= 0; }); - std::sort(LoInputs.begin(), LoInputs.end()); + llvm::sort(LoInputs.begin(), LoInputs.end()); LoInputs.erase(std::unique(LoInputs.begin(), LoInputs.end()), LoInputs.end()); SmallVector HiInputs; copy_if(HiMask, std::back_inserter(HiInputs), [](int M) { return M >= 0; }); - std::sort(HiInputs.begin(), HiInputs.end()); + llvm::sort(HiInputs.begin(), HiInputs.end()); HiInputs.erase(std::unique(HiInputs.begin(), HiInputs.end()), HiInputs.end()); int NumLToL = std::lower_bound(LoInputs.begin(), LoInputs.end(), 4) - LoInputs.begin(); @@ -12347,12 +12347,12 @@ SmallVector LoInputs; copy_if(Mask, std::back_inserter(LoInputs), [](int M) { return M >= 0 && M < 8; }); - std::sort(LoInputs.begin(), LoInputs.end()); + llvm::sort(LoInputs.begin(), LoInputs.end()); LoInputs.erase(std::unique(LoInputs.begin(), LoInputs.end()), LoInputs.end()); SmallVector HiInputs; copy_if(Mask, std::back_inserter(HiInputs), [](int M) { return M >= 8; }); - std::sort(HiInputs.begin(), HiInputs.end()); + llvm::sort(HiInputs.begin(), HiInputs.end()); HiInputs.erase(std::unique(HiInputs.begin(), HiInputs.end()), HiInputs.end()); Index: lib/Target/XCore/XCoreFrameLowering.cpp =================================================================== --- lib/Target/XCore/XCoreFrameLowering.cpp +++ lib/Target/XCore/XCoreFrameLowering.cpp @@ -151,7 +151,7 @@ Offset, FramePtr)); } - std::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset); + llvm::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset); } /// Creates an ordered list of EH info register 'spills'. @@ -170,7 +170,7 @@ SpillList.push_back( StackSlotInfo(EHSlot[0], MFI.getObjectOffset(EHSlot[1]), TL->getExceptionSelectorRegister(PersonalityFn))); - std::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset); + llvm::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset); } static MachineMemOperand *getFrameIndexMMO(MachineBasicBlock &MBB, Index: lib/Target/XCore/XCoreLowerThreadLocal.cpp =================================================================== --- lib/Target/XCore/XCoreLowerThreadLocal.cpp +++ lib/Target/XCore/XCoreLowerThreadLocal.cpp @@ -129,7 +129,7 @@ static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) { do { SmallVector WUsers(CE->user_begin(), CE->user_end()); - std::sort(WUsers.begin(), WUsers.end()); + llvm::sort(WUsers.begin(), WUsers.end()); WUsers.erase(std::unique(WUsers.begin(), WUsers.end()), WUsers.end()); while (!WUsers.empty()) if (WeakTrackingVH WU = WUsers.pop_back_val()) { Index: lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- lib/Transforms/Coroutines/CoroFrame.cpp +++ lib/Transforms/Coroutines/CoroFrame.cpp @@ -48,7 +48,7 @@ BlockToIndexMapping(Function &F) { for (BasicBlock &BB : F) V.push_back(&BB); - std::sort(V.begin(), V.end()); + llvm::sort(V.begin(), V.end()); } size_t blockToIndex(BasicBlock *BB) const { Index: lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- lib/Transforms/IPO/LowerTypeTests.cpp +++ lib/Transforms/IPO/LowerTypeTests.cpp @@ -1871,11 +1871,11 @@ } Sets.emplace_back(I, MaxIndex); } - std::sort(Sets.begin(), Sets.end(), - [](const std::pair &S1, - const std::pair &S2) { - return S1.second < S2.second; - }); + llvm::sort(Sets.begin(), Sets.end(), + [](const std::pair &S1, + const std::pair &S2) { + return S1.second < S2.second; + }); // For each disjoint set we found... for (const auto &S : Sets) { @@ -1896,7 +1896,7 @@ // Order type identifiers by global index for determinism. This ordering is // stable as there is a one-to-one mapping between metadata and indices. - std::sort(TypeIds.begin(), TypeIds.end(), [&](Metadata *M1, Metadata *M2) { + llvm::sort(TypeIds.begin(), TypeIds.end(), [&](Metadata *M1, Metadata *M2) { return TypeIdInfo[M1].Index < TypeIdInfo[M2].Index; }); Index: lib/Transforms/IPO/SampleProfile.cpp =================================================================== --- lib/Transforms/IPO/SampleProfile.cpp +++ lib/Transforms/IPO/SampleProfile.cpp @@ -679,10 +679,10 @@ Sum += NameFS.second.getEntrySamples(); R.push_back(&NameFS.second); } - std::sort(R.begin(), R.end(), - [](const FunctionSamples *L, const FunctionSamples *R) { - return L->getEntrySamples() > R->getEntrySamples(); - }); + llvm::sort(R.begin(), R.end(), + [](const FunctionSamples *L, const FunctionSamples *R) { + return L->getEntrySamples() > R->getEntrySamples(); + }); } return R; } @@ -1170,13 +1170,13 @@ SmallVector R; for (auto I = M.begin(); I != M.end(); ++I) R.push_back({Function::getGUID(I->getKey()), I->getValue()}); - std::sort(R.begin(), R.end(), - [](const InstrProfValueData &L, const InstrProfValueData &R) { - if (L.Count == R.Count) - return L.Value > R.Value; - else - return L.Count > R.Count; - }); + llvm::sort(R.begin(), R.end(), + [](const InstrProfValueData &L, const InstrProfValueData &R) { + if (L.Count == R.Count) + return L.Value > R.Value; + else + return L.Count > R.Count; + }); return R; } Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -272,7 +272,7 @@ write(Len); write(Number); - std::sort( + llvm::sort( SortedLinesByFile.begin(), SortedLinesByFile.end(), [](StringMapEntry *LHS, StringMapEntry *RHS) { return LHS->getKey() < RHS->getKey(); Index: lib/Transforms/Instrumentation/SanitizerCoverage.cpp =================================================================== --- lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -659,11 +659,11 @@ C = ConstantExpr::getCast(CastInst::ZExt, It.getCaseValue(), Int64Ty); Initializers.push_back(C); } - std::sort(Initializers.begin() + 2, Initializers.end(), - [](const Constant *A, const Constant *B) { - return cast(A)->getLimitedValue() < - cast(B)->getLimitedValue(); - }); + llvm::sort(Initializers.begin() + 2, Initializers.end(), + [](const Constant *A, const Constant *B) { + return cast(A)->getLimitedValue() < + cast(B)->getLimitedValue(); + }); ArrayType *ArrayOfInt64Ty = ArrayType::get(Int64Ty, Initializers.size()); GlobalVariable *GV = new GlobalVariable( *CurModule, ArrayOfInt64Ty, false, GlobalVariable::InternalLinkage, Index: lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- lib/Transforms/Scalar/ConstantHoisting.cpp +++ lib/Transforms/Scalar/ConstantHoisting.cpp @@ -571,8 +571,8 @@ /// rematerialized with an add from a common base constant. void ConstantHoistingPass::findBaseConstants() { // Sort the constants by value and type. This invalidates the mapping! - std::sort(ConstCandVec.begin(), ConstCandVec.end(), - [](const ConstantCandidate &LHS, const ConstantCandidate &RHS) { + llvm::sort(ConstCandVec.begin(), ConstCandVec.end(), + [](const ConstantCandidate &LHS, const ConstantCandidate &RHS) { if (LHS.ConstInt->getType() != RHS.ConstInt->getType()) return LHS.ConstInt->getType()->getBitWidth() < RHS.ConstInt->getType()->getBitWidth(); Index: lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- lib/Transforms/Scalar/GVNHoist.cpp +++ lib/Transforms/Scalar/GVNHoist.cpp @@ -748,11 +748,11 @@ // TODO: Remove fully-redundant expressions. // Get instruction from the Map, assume that all the Instructions // with same VNs have same rank (this is an approximation). - std::sort(Ranks.begin(), Ranks.end(), - [this, &Map](const VNType &r1, const VNType &r2) { - return (rank(*Map.lookup(r1).begin()) < - rank(*Map.lookup(r2).begin())); - }); + llvm::sort(Ranks.begin(), Ranks.end(), + [this, &Map](const VNType &r1, const VNType &r2) { + return (rank(*Map.lookup(r1).begin()) < + rank(*Map.lookup(r2).begin())); + }); // - Sort VNs according to their rank, and start with lowest ranked VN // - Take a VN and for each instruction with same VN Index: lib/Transforms/Scalar/GVNSink.cpp =================================================================== --- lib/Transforms/Scalar/GVNSink.cpp +++ lib/Transforms/Scalar/GVNSink.cpp @@ -239,7 +239,7 @@ SmallVector, 4> Ops; for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) Ops.push_back({PN->getIncomingBlock(I), PN->getIncomingValue(I)}); - std::sort(Ops.begin(), Ops.end()); + llvm::sort(Ops.begin(), Ops.end()); for (auto &P : Ops) { Blocks.push_back(P.first); Values.push_back(P.second); @@ -361,7 +361,7 @@ for (auto &U : I->uses()) op_push_back(U.getUser()); - std::sort(op_begin(), op_end()); + llvm::sort(op_begin(), op_end()); } void setMemoryUseOrder(unsigned MUO) { MemoryUseOrder = MUO; } @@ -761,7 +761,7 @@ } if (Preds.size() < 2) return 0; - std::sort(Preds.begin(), Preds.end()); + llvm::sort(Preds.begin(), Preds.end()); unsigned NumOrigPreds = Preds.size(); // We can only sink instructions through unconditional branches. Index: lib/Transforms/Scalar/GuardWidening.cpp =================================================================== --- lib/Transforms/Scalar/GuardWidening.cpp +++ lib/Transforms/Scalar/GuardWidening.cpp @@ -581,9 +581,9 @@ // CurrentChecks.size() will typically be 3 here, but so far there has been // no need to hard-code that fact. - std::sort(CurrentChecks.begin(), CurrentChecks.end(), - [&](const GuardWideningImpl::RangeCheck &LHS, - const GuardWideningImpl::RangeCheck &RHS) { + llvm::sort(CurrentChecks.begin(), CurrentChecks.end(), + [&](const GuardWideningImpl::RangeCheck &LHS, + const GuardWideningImpl::RangeCheck &RHS) { return LHS.getOffsetValue().slt(RHS.getOffsetValue()); }); Index: lib/Transforms/Scalar/LoopSink.cpp =================================================================== --- lib/Transforms/Scalar/LoopSink.cpp +++ lib/Transforms/Scalar/LoopSink.cpp @@ -200,10 +200,10 @@ SmallVector SortedBBsToSinkInto; SortedBBsToSinkInto.insert(SortedBBsToSinkInto.begin(), BBsToSinkInto.begin(), BBsToSinkInto.end()); - std::sort(SortedBBsToSinkInto.begin(), SortedBBsToSinkInto.end(), - [&](BasicBlock *A, BasicBlock *B) { - return *LoopBlockNumber.find(A) < *LoopBlockNumber.find(B); - }); + llvm::sort(SortedBBsToSinkInto.begin(), SortedBBsToSinkInto.end(), + [&](BasicBlock *A, BasicBlock *B) { + return *LoopBlockNumber.find(A) < *LoopBlockNumber.find(B); + }); BasicBlock *MoveBB = *SortedBBsToSinkInto.begin(); // FIXME: Optimize the efficiency for cloned value replacement. The current Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp =================================================================== --- lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1457,7 +1457,7 @@ SmallVector Key = F.BaseRegs; if (F.ScaledReg) Key.push_back(F.ScaledReg); // Unstable sort by host order ok, because this is only used for uniquifying. - std::sort(Key.begin(), Key.end()); + llvm::sort(Key.begin(), Key.end()); return Uniquifier.count(Key); } @@ -1481,7 +1481,7 @@ SmallVector Key = F.BaseRegs; if (F.ScaledReg) Key.push_back(F.ScaledReg); // Unstable sort by host order ok, because this is only used for uniquifying. - std::sort(Key.begin(), Key.end()); + llvm::sort(Key.begin(), Key.end()); if (!Uniquifier.insert(Key).second) return false; @@ -4162,7 +4162,7 @@ Key.push_back(F.ScaledReg); // Unstable sort by host order ok, because this is only used for // uniquifying. - std::sort(Key.begin(), Key.end()); + llvm::sort(Key.begin(), Key.end()); std::pair P = BestFormulae.insert(std::make_pair(Key, FIdx)); Index: lib/Transforms/Scalar/MergeICmps.cpp =================================================================== --- lib/Transforms/Scalar/MergeICmps.cpp +++ lib/Transforms/Scalar/MergeICmps.cpp @@ -341,10 +341,10 @@ #endif // MERGEICMPS_DOT_ON // Reorder blocks by LHS. We can do that without changing the // semantics because we are only accessing dereferencable memory. - std::sort(Comparisons_.begin(), Comparisons_.end(), - [](const BCECmpBlock &a, const BCECmpBlock &b) { - return a.Lhs() < b.Lhs(); - }); + llvm::sort(Comparisons_.begin(), Comparisons_.end(), + [](const BCECmpBlock &a, const BCECmpBlock &b) { + return a.Lhs() < b.Lhs(); + }); #ifdef MERGEICMPS_DOT_ON errs() << "AFTER REORDERING:\n\n"; dump(); Index: lib/Transforms/Scalar/NewGVN.cpp =================================================================== --- lib/Transforms/Scalar/NewGVN.cpp +++ lib/Transforms/Scalar/NewGVN.cpp @@ -958,7 +958,8 @@ // order. The BlockInstRange numbers are generated in an RPO walk of the basic // blocks. void NewGVN::sortPHIOps(MutableArrayRef Ops) const { - std::sort(Ops.begin(), Ops.end(), [&](const ValPair &P1, const ValPair &P2) { + llvm::sort(Ops.begin(), Ops.end(), + [&](const ValPair &P1, const ValPair &P2) { return BlockInstRange.lookup(P1.second).first < BlockInstRange.lookup(P2.second).first; }); @@ -3423,10 +3424,10 @@ for (auto &B : RPOT) { auto *Node = DT->getNode(B); if (Node->getChildren().size() > 1) - std::sort(Node->begin(), Node->end(), - [&](const DomTreeNode *A, const DomTreeNode *B) { - return RPOOrdering[A] < RPOOrdering[B]; - }); + llvm::sort(Node->begin(), Node->end(), + [&](const DomTreeNode *A, const DomTreeNode *B) { + return RPOOrdering[A] < RPOOrdering[B]; + }); } // Now a standard depth first ordering of the domtree is equivalent to RPO. @@ -3948,7 +3949,7 @@ convertClassToDFSOrdered(*CC, DFSOrderedSet, UseCounts, ProbablyDead); // Sort the whole thing. - std::sort(DFSOrderedSet.begin(), DFSOrderedSet.end()); + llvm::sort(DFSOrderedSet.begin(), DFSOrderedSet.end()); for (auto &VD : DFSOrderedSet) { int MemberDFSIn = VD.DFSIn; int MemberDFSOut = VD.DFSOut; @@ -4110,7 +4111,7 @@ // If we have possible dead stores to look at, try to eliminate them. if (CC->getStoreCount() > 0) { convertClassToLoadsAndStores(*CC, PossibleDeadStores); - std::sort(PossibleDeadStores.begin(), PossibleDeadStores.end()); + llvm::sort(PossibleDeadStores.begin(), PossibleDeadStores.end()); ValueDFSStack EliminationStack; for (auto &VD : PossibleDeadStores) { int MemberDFSIn = VD.DFSIn; Index: lib/Transforms/Scalar/PlaceSafepoints.cpp =================================================================== --- lib/Transforms/Scalar/PlaceSafepoints.cpp +++ lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -522,7 +522,7 @@ }; // We need the order of list to be stable so that naming ends up stable // when we split edges. This makes test cases much easier to write. - std::sort(PollLocations.begin(), PollLocations.end(), OrderByBBName); + llvm::sort(PollLocations.begin(), PollLocations.end(), OrderByBBName); // We can sometimes end up with duplicate poll locations. This happens if // a single loop is visited more than once. The fact this happens seems Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp =================================================================== --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1823,7 +1823,7 @@ } } - std::sort(Uses.begin(), Uses.end()); + llvm::sort(Uses.begin(), Uses.end()); auto Last = std::unique(Uses.begin(), Uses.end()); Uses.erase(Last, Uses.end()); Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -273,7 +273,7 @@ int OldSize = Slices.size(); Slices.append(NewSlices.begin(), NewSlices.end()); auto SliceI = Slices.begin() + OldSize; - std::sort(SliceI, Slices.end()); + llvm::sort(SliceI, Slices.end()); std::inplace_merge(Slices.begin(), SliceI, Slices.end()); } @@ -1057,7 +1057,7 @@ // Sort the uses. This arranges for the offsets to be in ascending order, // and the sizes to be in descending order. - std::sort(Slices.begin(), Slices.end()); + llvm::sort(Slices.begin(), Slices.end()); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) @@ -1891,7 +1891,7 @@ "All non-integer types eliminated!"); return RHSTy->getNumElements() < LHSTy->getNumElements(); }; - std::sort(CandidateTys.begin(), CandidateTys.end(), RankVectorTypes); + llvm::sort(CandidateTys.begin(), CandidateTys.end(), RankVectorTypes); CandidateTys.erase( std::unique(CandidateTys.begin(), CandidateTys.end(), RankVectorTypes), CandidateTys.end()); @@ -4137,7 +4137,7 @@ } if (!IsSorted) - std::sort(AS.begin(), AS.end()); + llvm::sort(AS.begin(), AS.end()); /// Describes the allocas introduced by rewritePartition in order to migrate /// the debug info. Index: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp =================================================================== --- lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -1128,11 +1128,12 @@ // matter as we're just trying to build up the map from inside-out; we use // the map in a more stably ordered way below. auto OrderedClonedExitsInLoops = ClonedExitsInLoops; - std::sort(OrderedClonedExitsInLoops.begin(), OrderedClonedExitsInLoops.end(), - [&](BasicBlock *LHS, BasicBlock *RHS) { - return ExitLoopMap.lookup(LHS)->getLoopDepth() < - ExitLoopMap.lookup(RHS)->getLoopDepth(); - }); + llvm::sort(OrderedClonedExitsInLoops.begin(), + OrderedClonedExitsInLoops.end(), + [&](BasicBlock *LHS, BasicBlock *RHS) { + return ExitLoopMap.lookup(LHS)->getLoopDepth() < + ExitLoopMap.lookup(RHS)->getLoopDepth(); + }); // Populate the existing ExitLoopMap with everything reachable from each // exit, starting from the inner most exit. Index: lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp =================================================================== --- lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp +++ lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp @@ -161,7 +161,7 @@ void ImportedFunctionsInliningStatistics::calculateRealInlines() { // Removing duplicated Callers. - std::sort(NonImportedCallers.begin(), NonImportedCallers.end()); + llvm::sort(NonImportedCallers.begin(), NonImportedCallers.end()); NonImportedCallers.erase( std::unique(NonImportedCallers.begin(), NonImportedCallers.end()), NonImportedCallers.end()); @@ -190,13 +190,14 @@ for (const NodesMapTy::value_type& Node : NodesMap) SortedNodes.push_back(&Node); - std::sort( + llvm::sort( SortedNodes.begin(), SortedNodes.end(), [&](const SortedNodesTy::value_type &Lhs, const SortedNodesTy::value_type &Rhs) { if (Lhs->second->NumberOfInlines != Rhs->second->NumberOfInlines) return Lhs->second->NumberOfInlines > Rhs->second->NumberOfInlines; - if (Lhs->second->NumberOfRealInlines != Rhs->second->NumberOfRealInlines) + if (Lhs->second->NumberOfRealInlines != + Rhs->second->NumberOfRealInlines) return Lhs->second->NumberOfRealInlines > Rhs->second->NumberOfRealInlines; return Lhs->first() < Rhs->first(); Index: lib/Transforms/Utils/LowerSwitch.cpp =================================================================== --- lib/Transforms/Utils/LowerSwitch.cpp +++ lib/Transforms/Utils/LowerSwitch.cpp @@ -382,7 +382,7 @@ Cases.push_back(CaseRange(Case.getCaseValue(), Case.getCaseValue(), Case.getCaseSuccessor())); - std::sort(Cases.begin(), Cases.end(), CaseCmp()); + llvm::sort(Cases.begin(), Cases.end(), CaseCmp()); // Merge case into clusters if (Cases.size() >= 2) { Index: lib/Transforms/Utils/PredicateInfo.cpp =================================================================== --- lib/Transforms/Utils/PredicateInfo.cpp +++ lib/Transforms/Utils/PredicateInfo.cpp @@ -553,7 +553,7 @@ auto Comparator = [&](const Value *A, const Value *B) { return valueComesBefore(OI, A, B); }; - std::sort(OpsToRename.begin(), OpsToRename.end(), Comparator); + llvm::sort(OpsToRename.begin(), OpsToRename.end(), Comparator); ValueDFS_Compare Compare(OI); // Compute liveness, and rename in O(uses) per Op. for (auto *Op : OpsToRename) { Index: lib/Transforms/Utils/PromoteMemoryToRegister.cpp =================================================================== --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -475,7 +475,7 @@ // Sort the stores by their index, making it efficient to do a lookup with a // binary search. - std::sort(StoresByIndex.begin(), StoresByIndex.end(), less_first()); + llvm::sort(StoresByIndex.begin(), StoresByIndex.end(), less_first()); // Walk all of the loads from this alloca, replacing them with the nearest // store above them, if any. @@ -631,10 +631,10 @@ SmallVector PHIBlocks; IDF.calculate(PHIBlocks); if (PHIBlocks.size() > 1) - std::sort(PHIBlocks.begin(), PHIBlocks.end(), - [this](BasicBlock *A, BasicBlock *B) { - return BBNumbers.lookup(A) < BBNumbers.lookup(B); - }); + llvm::sort(PHIBlocks.begin(), PHIBlocks.end(), + [this](BasicBlock *A, BasicBlock *B) { + return BBNumbers.lookup(A) < BBNumbers.lookup(B); + }); unsigned CurrentVersion = 0; for (BasicBlock *BB : PHIBlocks) @@ -740,7 +740,7 @@ // Ok, now we know that all of the PHI nodes are missing entries for some // basic blocks. Start by sorting the incoming predecessors for efficient // access. - std::sort(Preds.begin(), Preds.end()); + llvm::sort(Preds.begin(), Preds.end()); // Now we loop through all BB's which have entries in SomePHI and remove // them from the Preds list. Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -5487,7 +5487,7 @@ SmallVector Values; for (auto &C : SI->cases()) Values.push_back(C.getCaseValue()->getValue().getSExtValue()); - std::sort(Values.begin(), Values.end()); + llvm::sort(Values.begin(), Values.end()); // If the switch is already dense, there's nothing useful to do here. if (isSwitchDense(Values)) Index: lib/Transforms/Utils/SplitModule.cpp =================================================================== --- lib/Transforms/Utils/SplitModule.cpp +++ lib/Transforms/Utils/SplitModule.cpp @@ -180,12 +180,14 @@ std::make_pair(std::distance(GVtoClusterMap.member_begin(I), GVtoClusterMap.member_end()), I)); - std::sort(Sets.begin(), Sets.end(), [](const SortType &a, const SortType &b) { - if (a.first == b.first) - return a.second->getData()->getName() > b.second->getData()->getName(); - else - return a.first > b.first; - }); + llvm::sort(Sets.begin(), Sets.end(), + [](const SortType &a, const SortType &b) { + if (a.first == b.first) + return a.second->getData()->getName() > + b.second->getData()->getName(); + else + return a.first > b.first; + }); for (auto &I : Sets) { unsigned CurrentClusterID = BalancinQueue.top().first; Index: tools/dsymutil/DebugMap.cpp =================================================================== --- tools/dsymutil/DebugMap.cpp +++ tools/dsymutil/DebugMap.cpp @@ -62,9 +62,10 @@ Entries.reserve(Symbols.getNumItems()); for (const auto &Sym : make_range(Symbols.begin(), Symbols.end())) Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue())); - std::sort( - Entries.begin(), Entries.end(), - [](const Entry &LHS, const Entry &RHS) { return LHS.first < RHS.first; }); + llvm::sort(Entries.begin(), Entries.end(), + [](const Entry &LHS, const Entry &RHS) { + return LHS.first < RHS.first; + }); for (const auto &Sym : Entries) { if (Sym.second.ObjectAddress) OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress)); Index: tools/dsymutil/DwarfLinker.cpp =================================================================== --- tools/dsymutil/DwarfLinker.cpp +++ tools/dsymutil/DwarfLinker.cpp @@ -1065,7 +1065,7 @@ // The object addresses where sorted, but again, the linked // addresses might end up in a different order. - std::sort(Ranges.begin(), Ranges.end()); + llvm::sort(Ranges.begin(), Ranges.end()); if (!Ranges.empty()) { MS->SwitchSection(MC->getObjectFileInfo()->getDwarfARangesSection()); @@ -2356,7 +2356,7 @@ // the file, this allows us to just keep an index in the relocation // array that we advance during our walk, rather than resorting to // some associative container. See DwarfLinker::NextValidReloc. - std::sort(ValidRelocs.begin(), ValidRelocs.end()); + llvm::sort(ValidRelocs.begin(), ValidRelocs.end()); return true; } Index: tools/dsymutil/NonRelocatableStringpool.cpp =================================================================== --- tools/dsymutil/NonRelocatableStringpool.cpp +++ tools/dsymutil/NonRelocatableStringpool.cpp @@ -39,7 +39,7 @@ Result.reserve(Strings.size()); for (const auto &E : Strings) Result.emplace_back(E); - std::sort( + llvm::sort( Result.begin(), Result.end(), [](const DwarfStringPoolEntryRef A, const DwarfStringPoolEntryRef B) { return A.getIndex() < B.getIndex(); Index: tools/llvm-config/llvm-config.cpp =================================================================== --- tools/llvm-config/llvm-config.cpp +++ tools/llvm-config/llvm-config.cpp @@ -522,7 +522,7 @@ if (DyLibExists && !sys::fs::exists(path)) { Components = GetAllDyLibComponents(IsInDevelopmentTree, true, DirSep); - std::sort(Components.begin(), Components.end()); + llvm::sort(Components.begin(), Components.end()); break; } } Index: tools/llvm-mca/InstrBuilder.cpp =================================================================== --- tools/llvm-mca/InstrBuilder.cpp +++ tools/llvm-mca/InstrBuilder.cpp @@ -44,16 +44,16 @@ // Sort elements by mask popcount, so that we prioritize resource units over // resource groups, and smaller groups over larger groups. - std::sort(Worklist.begin(), Worklist.end(), - [](const ResourcePlusCycles &A, const ResourcePlusCycles &B) { - unsigned popcntA = countPopulation(A.first); - unsigned popcntB = countPopulation(B.first); - if (popcntA < popcntB) - return true; - if (popcntA > popcntB) - return false; - return A.first < B.first; - }); + llvm::sort(Worklist.begin(), Worklist.end(), + [](const ResourcePlusCycles &A, const ResourcePlusCycles &B) { + unsigned popcntA = countPopulation(A.first); + unsigned popcntB = countPopulation(B.first); + if (popcntA < popcntB) + return true; + if (popcntA > popcntB) + return false; + return A.first < B.first; + }); uint64_t UsedResourceUnits = 0; Index: tools/llvm-nm/llvm-nm.cpp =================================================================== --- tools/llvm-nm/llvm-nm.cpp +++ tools/llvm-nm/llvm-nm.cpp @@ -697,7 +697,7 @@ if (ReverseSort) Cmp = [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); }; - std::sort(SymbolList.begin(), SymbolList.end(), Cmp); + llvm::sort(SymbolList.begin(), SymbolList.end(), Cmp); } if (!PrintFileName) { Index: tools/llvm-objdump/COFFDump.cpp =================================================================== --- tools/llvm-objdump/COFFDump.cpp +++ tools/llvm-objdump/COFFDump.cpp @@ -453,7 +453,7 @@ Rels.push_back(Reloc); // Sort relocations by address. - std::sort(Rels.begin(), Rels.end(), RelocAddressLess); + llvm::sort(Rels.begin(), Rels.end(), RelocAddressLess); ArrayRef Contents; error(Obj->getSectionContents(Pdata, Contents)); Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -6875,7 +6875,7 @@ BaseSegmentAddress); // Sort the symbols by address, just in case they didn't come in that way. - std::sort(Symbols.begin(), Symbols.end(), SymbolSorter()); + llvm::sort(Symbols.begin(), Symbols.end(), SymbolSorter()); // Build a data in code table that is sorted on by the address of each entry. uint64_t BaseAddress = 0; Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -1362,8 +1362,8 @@ } } - std::sort(DataMappingSymsAddr.begin(), DataMappingSymsAddr.end()); - std::sort(TextMappingSymsAddr.begin(), TextMappingSymsAddr.end()); + llvm::sort(DataMappingSymsAddr.begin(), DataMappingSymsAddr.end()); + llvm::sort(TextMappingSymsAddr.begin(), TextMappingSymsAddr.end()); if (Obj->isELF() && Obj->getArch() == Triple::amdgcn) { // AMDGPU disassembler uses symbolizer for printing labels @@ -1388,7 +1388,7 @@ } // Sort relocations by address. - std::sort(Rels.begin(), Rels.end(), RelocAddressLess); + llvm::sort(Rels.begin(), Rels.end(), RelocAddressLess); StringRef SegmentName = ""; if (const MachOObjectFile *MachO = dyn_cast(Obj)) { Index: tools/llvm-pdbutil/DumpOutputStyle.cpp =================================================================== --- tools/llvm-pdbutil/DumpOutputStyle.cpp +++ tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -869,7 +869,7 @@ "String"); std::vector SortedIDs(IS->name_ids().begin(), IS->name_ids().end()); - std::sort(SortedIDs.begin(), SortedIDs.end()); + llvm::sort(SortedIDs.begin(), SortedIDs.end()); for (uint32_t I : SortedIDs) { auto ES = IS->getStringForID(I); llvm::SmallString<32> Str; Index: tools/llvm-pdbutil/PrettyTypeDumper.cpp =================================================================== --- tools/llvm-pdbutil/PrettyTypeDumper.cpp +++ tools/llvm-pdbutil/PrettyTypeDumper.cpp @@ -128,7 +128,7 @@ } if (Comp) - std::sort(Filtered.begin(), Filtered.end(), Comp); + llvm::sort(Filtered.begin(), Filtered.end(), Comp); return Filtered; } Index: tools/llvm-pdbutil/llvm-pdbutil.cpp =================================================================== --- tools/llvm-pdbutil/llvm-pdbutil.cpp +++ tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -944,8 +944,8 @@ std::vector> Funcs; while (auto Func = Functions->getNext()) Funcs.push_back(std::move(Func)); - std::sort(Funcs.begin(), Funcs.end(), - opts::pretty::compareFunctionSymbols); + llvm::sort(Funcs.begin(), Funcs.end(), + opts::pretty::compareFunctionSymbols); for (const auto &Func : Funcs) { Printer.NewLine(); Dumper.start(*Func, FunctionDumper::PointerType::None); @@ -963,8 +963,8 @@ std::vector> Datas; while (auto Var = Vars->getNext()) Datas.push_back(std::move(Var)); - std::sort(Datas.begin(), Datas.end(), - opts::pretty::compareDataSymbols); + llvm::sort(Datas.begin(), Datas.end(), + opts::pretty::compareDataSymbols); for (const auto &Var : Datas) Dumper.start(*Var); } Index: tools/llvm-readobj/COFFDumper.cpp =================================================================== --- tools/llvm-readobj/COFFDumper.cpp +++ tools/llvm-readobj/COFFDumper.cpp @@ -607,8 +607,8 @@ RelocMap[Section].push_back(Reloc); // Sort relocations by address. - std::sort(RelocMap[Section].begin(), RelocMap[Section].end(), - relocAddressLess); + llvm::sort(RelocMap[Section].begin(), RelocMap[Section].end(), + relocAddressLess); } } Index: tools/llvm-xray/xray-account.cc =================================================================== --- tools/llvm-xray/xray-account.cc +++ tools/llvm-xray/xray-account.cc @@ -282,79 +282,79 @@ // Sort the data according to user-provided flags. switch (AccountSortOutput) { case SortField::FUNCID: - std::sort(Results.begin(), Results.end(), - [](const TupleType &L, const TupleType &R) { - if (AccountSortOrder == SortDirection::ASCENDING) - return std::get<0>(L) < std::get<0>(R); - if (AccountSortOrder == SortDirection::DESCENDING) - return std::get<0>(L) > std::get<0>(R); - llvm_unreachable("Unknown sort direction"); - }); + llvm::sort(Results.begin(), Results.end(), + [](const TupleType &L, const TupleType &R) { + if (AccountSortOrder == SortDirection::ASCENDING) + return std::get<0>(L) < std::get<0>(R); + if (AccountSortOrder == SortDirection::DESCENDING) + return std::get<0>(L) > std::get<0>(R); + llvm_unreachable("Unknown sort direction"); + }); break; case SortField::COUNT: - std::sort(Results.begin(), Results.end(), - [](const TupleType &L, const TupleType &R) { - if (AccountSortOrder == SortDirection::ASCENDING) - return std::get<1>(L) < std::get<1>(R); - if (AccountSortOrder == SortDirection::DESCENDING) - return std::get<1>(L) > std::get<1>(R); - llvm_unreachable("Unknown sort direction"); - }); + llvm::sort(Results.begin(), Results.end(), + [](const TupleType &L, const TupleType &R) { + if (AccountSortOrder == SortDirection::ASCENDING) + return std::get<1>(L) < std::get<1>(R); + if (AccountSortOrder == SortDirection::DESCENDING) + return std::get<1>(L) > std::get<1>(R); + llvm_unreachable("Unknown sort direction"); + }); break; default: // Here we need to look into the ResultRow for the rest of the data that // we want to sort by. - std::sort(Results.begin(), Results.end(), - [&](const TupleType &L, const TupleType &R) { - auto &LR = std::get<2>(L); - auto &RR = std::get<2>(R); - switch (AccountSortOutput) { - case SortField::COUNT: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Count < RR.Count; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Count > RR.Count; - llvm_unreachable("Unknown sort direction"); - case SortField::MIN: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Min < RR.Min; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Min > RR.Min; - llvm_unreachable("Unknown sort direction"); - case SortField::MED: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Median < RR.Median; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Median > RR.Median; - llvm_unreachable("Unknown sort direction"); - case SortField::PCT90: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Pct90 < RR.Pct90; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Pct90 > RR.Pct90; - llvm_unreachable("Unknown sort direction"); - case SortField::PCT99: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Pct99 < RR.Pct99; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Pct99 > RR.Pct99; - llvm_unreachable("Unknown sort direction"); - case SortField::MAX: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Max < RR.Max; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Max > RR.Max; - llvm_unreachable("Unknown sort direction"); - case SortField::SUM: - if (AccountSortOrder == SortDirection::ASCENDING) - return LR.Sum < RR.Sum; - if (AccountSortOrder == SortDirection::DESCENDING) - return LR.Sum > RR.Sum; - llvm_unreachable("Unknown sort direction"); - default: - llvm_unreachable("Unsupported sort order"); - } - }); + llvm::sort(Results.begin(), Results.end(), + [&](const TupleType &L, const TupleType &R) { + auto &LR = std::get<2>(L); + auto &RR = std::get<2>(R); + switch (AccountSortOutput) { + case SortField::COUNT: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Count < RR.Count; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Count > RR.Count; + llvm_unreachable("Unknown sort direction"); + case SortField::MIN: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Min < RR.Min; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Min > RR.Min; + llvm_unreachable("Unknown sort direction"); + case SortField::MED: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Median < RR.Median; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Median > RR.Median; + llvm_unreachable("Unknown sort direction"); + case SortField::PCT90: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Pct90 < RR.Pct90; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Pct90 > RR.Pct90; + llvm_unreachable("Unknown sort direction"); + case SortField::PCT99: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Pct99 < RR.Pct99; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Pct99 > RR.Pct99; + llvm_unreachable("Unknown sort direction"); + case SortField::MAX: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Max < RR.Max; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Max > RR.Max; + llvm_unreachable("Unknown sort direction"); + case SortField::SUM: + if (AccountSortOrder == SortDirection::ASCENDING) + return LR.Sum < RR.Sum; + if (AccountSortOrder == SortDirection::DESCENDING) + return LR.Sum > RR.Sum; + llvm_unreachable("Unknown sort direction"); + default: + llvm_unreachable("Unsupported sort order"); + } + }); break; } Index: tools/yaml2obj/yaml2macho.cpp =================================================================== --- tools/yaml2obj/yaml2macho.cpp +++ tools/yaml2obj/yaml2macho.cpp @@ -417,10 +417,10 @@ } } - std::sort(WriteQueue.begin(), WriteQueue.end(), - [](const writeOperation &a, const writeOperation &b) { - return a.first < b.first; - }); + llvm::sort(WriteQueue.begin(), WriteQueue.end(), + [](const writeOperation &a, const writeOperation &b) { + return a.first < b.first; + }); for (auto writeOp : WriteQueue) { ZeroToOffset(OS, writeOp.first); Index: unittests/ADT/STLExtrasTest.cpp =================================================================== --- unittests/ADT/STLExtrasTest.cpp +++ unittests/ADT/STLExtrasTest.cpp @@ -302,8 +302,8 @@ ASSERT_EQ(V.begin() + 4, I); // Sort the two halves as partition may have messed with the order. - std::sort(V.begin(), I); - std::sort(I, V.end()); + llvm::sort(V.begin(), I); + llvm::sort(I, V.end()); EXPECT_EQ(2, V[0]); EXPECT_EQ(4, V[1]); Index: unittests/ADT/SmallPtrSetTest.cpp =================================================================== --- unittests/ADT/SmallPtrSetTest.cpp +++ unittests/ADT/SmallPtrSetTest.cpp @@ -299,7 +299,7 @@ // Sort. We should hit the first element just once and the final element N // times. - std::sort(std::begin(Found), std::end(Found)); + llvm::sort(std::begin(Found), std::end(Found)); for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F) EXPECT_EQ(F - Found + 1, *F); } Index: unittests/ADT/StringMapTest.cpp =================================================================== --- unittests/ADT/StringMapTest.cpp +++ unittests/ADT/StringMapTest.cpp @@ -279,7 +279,7 @@ Map["D"] = 3; auto Keys = to_vector<4>(Map.keys()); - std::sort(Keys.begin(), Keys.end()); + llvm::sort(Keys.begin(), Keys.end()); SmallVector Expected = {"A", "B", "C", "D"}; EXPECT_EQ(Expected, Keys); @@ -293,7 +293,7 @@ Set.insert("D"); auto Keys = to_vector<4>(Set.keys()); - std::sort(Keys.begin(), Keys.end()); + llvm::sort(Keys.begin(), Keys.end()); SmallVector Expected = {"A", "B", "C", "D"}; EXPECT_EQ(Expected, Keys); Index: unittests/Analysis/LazyCallGraphTest.cpp =================================================================== --- unittests/Analysis/LazyCallGraphTest.cpp +++ unittests/Analysis/LazyCallGraphTest.cpp @@ -264,7 +264,7 @@ for (LazyCallGraph::Edge &E : A1.populate()) Nodes.push_back(E.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ("a2", Nodes[0]); EXPECT_EQ("b2", Nodes[1]); EXPECT_EQ("c3", Nodes[2]); @@ -279,7 +279,7 @@ for (LazyCallGraph::Edge &E : B1.populate()) Nodes.push_back(E.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ("b2", Nodes[0]); EXPECT_EQ("d3", Nodes[1]); Nodes.clear(); @@ -293,7 +293,7 @@ for (LazyCallGraph::Edge &E : C1.populate()) Nodes.push_back(E.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ("c2", Nodes[0]); EXPECT_EQ("d2", Nodes[1]); Nodes.clear(); @@ -323,7 +323,7 @@ ASSERT_EQ(1, D.size()); for (LazyCallGraph::Node &N : *D.begin()) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("d1", Nodes[0]); EXPECT_EQ("d2", Nodes[1]); @@ -339,7 +339,7 @@ ASSERT_EQ(1, C.size()); for (LazyCallGraph::Node &N : *C.begin()) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("c1", Nodes[0]); EXPECT_EQ("c2", Nodes[1]); @@ -355,7 +355,7 @@ ASSERT_EQ(1, B.size()); for (LazyCallGraph::Node &N : *B.begin()) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("b1", Nodes[0]); EXPECT_EQ("b2", Nodes[1]); @@ -373,7 +373,7 @@ ASSERT_EQ(1, A.size()); for (LazyCallGraph::Node &N : *A.begin()) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("a1", Nodes[0]); EXPECT_EQ("a2", Nodes[1]); @@ -477,7 +477,7 @@ LazyCallGraph::SCC &D = *J++; for (LazyCallGraph::Node &N : D) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("d1", Nodes[0]); EXPECT_EQ("d2", Nodes[1]); @@ -487,7 +487,7 @@ LazyCallGraph::SCC &B = *J++; for (LazyCallGraph::Node &N : B) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("b1", Nodes[0]); EXPECT_EQ("b2", Nodes[1]); @@ -497,7 +497,7 @@ LazyCallGraph::SCC &C = *J++; for (LazyCallGraph::Node &N : C) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("c1", Nodes[0]); EXPECT_EQ("c2", Nodes[1]); @@ -507,7 +507,7 @@ LazyCallGraph::SCC &A = *J++; for (LazyCallGraph::Node &N : A) Nodes.push_back(N.getFunction().getName()); - std::sort(Nodes.begin(), Nodes.end()); + llvm::sort(Nodes.begin(), Nodes.end()); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("a1", Nodes[0]); EXPECT_EQ("a2", Nodes[1]); Index: unittests/ProfileData/InstrProfTest.cpp =================================================================== --- unittests/ProfileData/InstrProfTest.cpp +++ unittests/ProfileData/InstrProfTest.cpp @@ -712,7 +712,7 @@ }; std::unique_ptr VD_0( Record.getValueForSite(IPVK_IndirectCallTarget, 0)); - std::sort(&VD_0[0], &VD_0[5], Cmp); + llvm::sort(&VD_0[0], &VD_0[5], Cmp); ASSERT_EQ(StringRef((const char *)VD_0[0].Value, 7), StringRef("callee2")); ASSERT_EQ(1000U, VD_0[0].Count); ASSERT_EQ(StringRef((const char *)VD_0[1].Value, 7), StringRef("callee3")); @@ -726,7 +726,7 @@ std::unique_ptr VD_1( Record.getValueForSite(IPVK_IndirectCallTarget, 1)); - std::sort(&VD_1[0], &VD_1[4], Cmp); + llvm::sort(&VD_1[0], &VD_1[4], Cmp); ASSERT_EQ(StringRef((const char *)VD_1[0].Value, 7), StringRef("callee2")); ASSERT_EQ(2500U, VD_1[0].Count); ASSERT_EQ(StringRef((const char *)VD_1[1].Value, 7), StringRef("callee1")); @@ -738,7 +738,7 @@ std::unique_ptr VD_2( Record.getValueForSite(IPVK_IndirectCallTarget, 2)); - std::sort(&VD_2[0], &VD_2[3], Cmp); + llvm::sort(&VD_2[0], &VD_2[3], Cmp); ASSERT_EQ(StringRef((const char *)VD_2[0].Value, 7), StringRef("callee4")); ASSERT_EQ(5500U, VD_2[0].Count); ASSERT_EQ(StringRef((const char *)VD_2[1].Value, 7), StringRef("callee3")); @@ -748,7 +748,7 @@ std::unique_ptr VD_3( Record.getValueForSite(IPVK_IndirectCallTarget, 3)); - std::sort(&VD_3[0], &VD_3[2], Cmp); + llvm::sort(&VD_3[0], &VD_3[2], Cmp); ASSERT_EQ(StringRef((const char *)VD_3[0].Value, 7), StringRef("callee3")); ASSERT_EQ(2000U, VD_3[0].Count); ASSERT_EQ(StringRef((const char *)VD_3[1].Value, 7), StringRef("callee2")); @@ -782,7 +782,7 @@ }; std::unique_ptr VD_0( Record.getValueForSite(IPVK_IndirectCallTarget, 0)); - std::sort(&VD_0[0], &VD_0[5], Cmp); + llvm::sort(&VD_0[0], &VD_0[5], Cmp); ASSERT_EQ(VD_0[0].Value, 0x2000ULL); ASSERT_EQ(1000U, VD_0[0].Count); ASSERT_EQ(VD_0[1].Value, 0x3000ULL); Index: unittests/Support/Path.cpp =================================================================== --- unittests/Support/Path.cpp +++ unittests/Support/Path.cpp @@ -895,7 +895,7 @@ ASSERT_NO_ERROR(ec); visited.push_back(path::filename(i->path())); } - std::sort(visited.begin(), visited.end()); + llvm::sort(visited.begin(), visited.end()); v_t expected = {"a", "b", "c", "d", "e"}; ASSERT_TRUE(visited.size() == expected.size()); ASSERT_TRUE(std::equal(visited.begin(), visited.end(), expected.begin())); @@ -918,7 +918,7 @@ visited.push_back(path::filename(i->path())); } - std::sort(visited.begin(), visited.end()); + llvm::sort(visited.begin(), visited.end()); expected = {"b", "bb", "d", "da", "dd", "ddd", "ddd"}; ASSERT_TRUE(visited.size() == expected.size()); ASSERT_TRUE(std::equal(visited.begin(), visited.end(), expected.begin())); @@ -933,7 +933,7 @@ ASSERT_NO_ERROR(ec); visited.push_back(path::filename(i->path())); } - std::sort(visited.begin(), visited.end()); + llvm::sort(visited.begin(), visited.end()); expected = {"a", "b", "ba", "bb", "bc", "c", "d", "da", "dd", "ddd", "e"}; ASSERT_TRUE(visited.size() == expected.size()); ASSERT_TRUE(std::equal(visited.begin(), visited.end(), expected.begin())); Index: utils/TableGen/CTagsEmitter.cpp =================================================================== --- utils/TableGen/CTagsEmitter.cpp +++ utils/TableGen/CTagsEmitter.cpp @@ -73,7 +73,7 @@ for (const auto &D : Defs) Tags.push_back(Tag(D.first, locate(D.second.get()))); // Emit tags. - std::sort(Tags.begin(), Tags.end()); + llvm::sort(Tags.begin(), Tags.end()); OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n"; OS << "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/\n"; for (const Tag &T : Tags) Index: utils/TableGen/CodeGenDAGPatterns.cpp =================================================================== --- utils/TableGen/CodeGenDAGPatterns.cpp +++ utils/TableGen/CodeGenDAGPatterns.cpp @@ -1305,7 +1305,7 @@ SmallVector PredList; for (const Predicate &P : Predicates) PredList.push_back(&P); - std::sort(PredList.begin(), PredList.end(), deref()); + llvm::sort(PredList.begin(), PredList.end(), deref()); std::string Check; for (unsigned i = 0, e = PredList.size(); i != e; ++i) { @@ -3698,7 +3698,7 @@ } // Sort so that different orders get canonicalized to the same string. - std::sort(Preds.begin(), Preds.end()); + llvm::sort(Preds.begin(), Preds.end()); return Preds; } Index: utils/TableGen/CodeGenRegisters.cpp =================================================================== --- utils/TableGen/CodeGenRegisters.cpp +++ utils/TableGen/CodeGenRegisters.cpp @@ -710,7 +710,7 @@ //===----------------------------------------------------------------------===// static void sortAndUniqueRegisters(CodeGenRegister::Vec &M) { - std::sort(M.begin(), M.end(), deref()); + llvm::sort(M.begin(), M.end(), deref()); M.erase(std::unique(M.begin(), M.end(), deref()), M.end()); } @@ -975,7 +975,7 @@ for (auto &RC : RegClasses) if (SuperRegRCsBV[RC.EnumValue]) SuperRegRCs.emplace_back(&RC); - std::sort(SuperRegRCs.begin(), SuperRegRCs.end(), SizeOrder); + llvm::sort(SuperRegRCs.begin(), SuperRegRCs.end(), SizeOrder); assert(SuperRegRCs.front() == BiggestSuperRegRC && "Biggest class wasn't first"); // Find all the subreg classes and order them by size too. @@ -986,11 +986,11 @@ if (SuperRegClassesBV.any()) SuperRegClasses.push_back(std::make_pair(&RC, SuperRegClassesBV)); } - std::sort(SuperRegClasses.begin(), SuperRegClasses.end(), - [&](const std::pair &A, - const std::pair &B) { - return SizeOrder(A.first, B.first); - }); + llvm::sort(SuperRegClasses.begin(), SuperRegClasses.end(), + [&](const std::pair &A, + const std::pair &B) { + return SizeOrder(A.first, B.first); + }); // Find the biggest subclass and subreg class such that R:subidx is in the // subreg class for all R in subclass. @@ -1048,7 +1048,7 @@ std::vector TmpUnits; for (RegUnitIterator UnitI(Members); UnitI.isValid(); ++UnitI) TmpUnits.push_back(*UnitI); - std::sort(TmpUnits.begin(), TmpUnits.end()); + llvm::sort(TmpUnits.begin(), TmpUnits.end()); std::unique_copy(TmpUnits.begin(), TmpUnits.end(), std::back_inserter(RegUnits)); } @@ -1067,7 +1067,7 @@ // Read in the user-defined (named) sub-register indices. // More indices will be synthesized later. std::vector SRIs = Records.getAllDerivedDefinitions("SubRegIndex"); - std::sort(SRIs.begin(), SRIs.end(), LessRecord()); + llvm::sort(SRIs.begin(), SRIs.end(), LessRecord()); for (unsigned i = 0, e = SRIs.size(); i != e; ++i) getSubRegIdx(SRIs[i]); // Build composite maps from ComposedOf fields. @@ -1076,7 +1076,7 @@ // Read in the register definitions. std::vector Regs = Records.getAllDerivedDefinitions("Register"); - std::sort(Regs.begin(), Regs.end(), LessRecordRegister()); + llvm::sort(Regs.begin(), Regs.end(), LessRecordRegister()); // Assign the enumeration values. for (unsigned i = 0, e = Regs.size(); i != e; ++i) getReg(Regs[i]); @@ -1087,7 +1087,7 @@ for (Record *R : Tups) { std::vector TupRegs = *Sets.expand(R); - std::sort(TupRegs.begin(), TupRegs.end(), LessRecordRegister()); + llvm::sort(TupRegs.begin(), TupRegs.end(), LessRecordRegister()); for (Record *RC : TupRegs) getReg(RC); } Index: utils/TableGen/CodeGenSchedule.cpp =================================================================== --- utils/TableGen/CodeGenSchedule.cpp +++ utils/TableGen/CodeGenSchedule.cpp @@ -203,7 +203,7 @@ /// Gather all processor models. void CodeGenSchedModels::collectProcModels() { RecVec ProcRecords = Records.getAllDerivedDefinitions("Processor"); - std::sort(ProcRecords.begin(), ProcRecords.end(), LessRecordFieldName()); + llvm::sort(ProcRecords.begin(), ProcRecords.end(), LessRecordFieldName()); // Reserve space because we can. Reallocation would be ok. ProcModels.reserve(ProcRecords.size()+1); @@ -322,7 +322,7 @@ // Find all ReadWrites referenced by SchedAlias. AliasDefs needs to be sorted // for the loop below that initializes Alias vectors. RecVec AliasDefs = Records.getAllDerivedDefinitions("SchedAlias"); - std::sort(AliasDefs.begin(), AliasDefs.end(), LessRecord()); + llvm::sort(AliasDefs.begin(), AliasDefs.end(), LessRecord()); for (Record *ADef : AliasDefs) { Record *MatchDef = ADef->getValueAsDef("MatchRW"); Record *AliasDef = ADef->getValueAsDef("AliasRW"); @@ -340,12 +340,12 @@ } // Sort and add the SchedReadWrites directly referenced by instructions or // itinerary resources. Index reads and writes in separate domains. - std::sort(SWDefs.begin(), SWDefs.end(), LessRecord()); + llvm::sort(SWDefs.begin(), SWDefs.end(), LessRecord()); for (Record *SWDef : SWDefs) { assert(!getSchedRWIdx(SWDef, /*IsRead=*/false) && "duplicate SchedWrite"); SchedWrites.emplace_back(SchedWrites.size(), SWDef); } - std::sort(SRDefs.begin(), SRDefs.end(), LessRecord()); + llvm::sort(SRDefs.begin(), SRDefs.end(), LessRecord()); for (Record *SRDef : SRDefs) { assert(!getSchedRWIdx(SRDef, /*IsRead-*/true) && "duplicate SchedWrite"); SchedReads.emplace_back(SchedReads.size(), SRDef); @@ -581,7 +581,7 @@ } // Create classes for InstRW defs. RecVec InstRWDefs = Records.getAllDerivedDefinitions("InstRW"); - std::sort(InstRWDefs.begin(), InstRWDefs.end(), LessRecord()); + llvm::sort(InstRWDefs.begin(), InstRWDefs.end(), LessRecord()); DEBUG(dbgs() << "\n+++ SCHED CLASSES (createInstRWClass) +++\n"); for (Record *RWDef : InstRWDefs) createInstRWClass(RWDef); @@ -883,7 +883,7 @@ // Gather the read/write types for each itinerary class. void CodeGenSchedModels::collectProcItinRW() { RecVec ItinRWDefs = Records.getAllDerivedDefinitions("ItinRW"); - std::sort(ItinRWDefs.begin(), ItinRWDefs.end(), LessRecord()); + llvm::sort(ItinRWDefs.begin(), ItinRWDefs.end(), LessRecord()); for (Record *RWDef : ItinRWDefs) { if (!RWDef->getValueInit("SchedModel")->isComplete()) PrintFatalError(RWDef->getLoc(), "SchedModel is undefined"); @@ -1574,12 +1574,12 @@ } // Finalize each ProcModel by sorting the record arrays. for (CodeGenProcModel &PM : ProcModels) { - std::sort(PM.WriteResDefs.begin(), PM.WriteResDefs.end(), - LessRecord()); - std::sort(PM.ReadAdvanceDefs.begin(), PM.ReadAdvanceDefs.end(), - LessRecord()); - std::sort(PM.ProcResourceDefs.begin(), PM.ProcResourceDefs.end(), - LessRecord()); + llvm::sort(PM.WriteResDefs.begin(), PM.WriteResDefs.end(), + LessRecord()); + llvm::sort(PM.ReadAdvanceDefs.begin(), PM.ReadAdvanceDefs.end(), + LessRecord()); + llvm::sort(PM.ProcResourceDefs.begin(), PM.ProcResourceDefs.end(), + LessRecord()); DEBUG( PM.dump(); dbgs() << "WriteResDefs: "; Index: utils/TableGen/CodeGenTarget.cpp =================================================================== --- utils/TableGen/CodeGenTarget.cpp +++ utils/TableGen/CodeGenTarget.cpp @@ -278,7 +278,7 @@ void CodeGenTarget::ReadRegAltNameIndices() const { RegAltNameIndices = Records.getAllDerivedDefinitions("RegAltNameIndex"); - std::sort(RegAltNameIndices.begin(), RegAltNameIndices.end(), LessRecord()); + llvm::sort(RegAltNameIndices.begin(), RegAltNameIndices.end(), LessRecord()); } /// getRegisterByName - If there is a register with the specific AsmName, @@ -303,7 +303,7 @@ } // Remove duplicates. - std::sort(Result.begin(), Result.end()); + llvm::sort(Result.begin(), Result.end()); Result.erase(std::unique(Result.begin(), Result.end()), Result.end()); return Result; } @@ -314,7 +314,7 @@ LegalValueTypes.insert(LegalValueTypes.end(), RC.VTs.begin(), RC.VTs.end()); // Remove duplicates. - std::sort(LegalValueTypes.begin(), LegalValueTypes.end()); + llvm::sort(LegalValueTypes.begin(), LegalValueTypes.end()); LegalValueTypes.erase(std::unique(LegalValueTypes.begin(), LegalValueTypes.end()), LegalValueTypes.end()); @@ -382,8 +382,9 @@ // All of the instructions are now in random order based on the map iteration. // Sort them by name. - std::sort(InstrsByEnum.begin() + EndOfPredefines, InstrsByEnum.end(), - [](const CodeGenInstruction *Rec1, const CodeGenInstruction *Rec2) { + llvm::sort(InstrsByEnum.begin() + EndOfPredefines, InstrsByEnum.end(), + [](const CodeGenInstruction *Rec1, + const CodeGenInstruction *Rec2) { return Rec1->TheDef->getName() < Rec2->TheDef->getName(); }); } @@ -507,11 +508,11 @@ if (isTarget == TargetOnly) Intrinsics.push_back(CodeGenIntrinsic(Defs[I])); } - std::sort(Intrinsics.begin(), Intrinsics.end(), - [](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) { - return std::tie(LHS.TargetPrefix, LHS.Name) < - std::tie(RHS.TargetPrefix, RHS.Name); - }); + llvm::sort(Intrinsics.begin(), Intrinsics.end(), + [](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) { + return std::tie(LHS.TargetPrefix, LHS.Name) < + std::tie(RHS.TargetPrefix, RHS.Name); + }); Targets.push_back({"", 0, 0}); for (size_t I = 0, E = Intrinsics.size(); I < E; ++I) if (Intrinsics[I].TargetPrefix != Targets.back().Name) { @@ -699,6 +700,6 @@ Properties = parseSDPatternOperatorProperties(R); // Sort the argument attributes for later benefit. - std::sort(ArgumentAttributes.begin(), ArgumentAttributes.end()); + llvm::sort(ArgumentAttributes.begin(), ArgumentAttributes.end()); } Index: utils/TableGen/DAGISelEmitter.cpp =================================================================== --- utils/TableGen/DAGISelEmitter.cpp +++ utils/TableGen/DAGISelEmitter.cpp @@ -153,7 +153,7 @@ // We want to process the matches in order of minimal cost. Sort the patterns // so the least cost one is at the start. - std::sort(Patterns.begin(), Patterns.end(), PatternSortingPredicate(CGP)); + llvm::sort(Patterns.begin(), Patterns.end(), PatternSortingPredicate(CGP)); // Convert each variant of each pattern into a Matcher. Index: utils/TableGen/FastISelEmitter.cpp =================================================================== --- utils/TableGen/FastISelEmitter.cpp +++ utils/TableGen/FastISelEmitter.cpp @@ -811,7 +811,7 @@ = SignaturesWithConstantForms.find(Operands); if (MI != SignaturesWithConstantForms.end()) { // Unique any duplicates out of the list. - std::sort(MI->second.begin(), MI->second.end()); + llvm::sort(MI->second.begin(), MI->second.end()); MI->second.erase(std::unique(MI->second.begin(), MI->second.end()), MI->second.end()); Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -148,7 +148,7 @@ const LLT &get() const { return Ty; } - /// This ordering is used for std::unique() and std::sort(). There's no + /// This ordering is used for std::unique() and llvm::sort(). There's no /// particular logic behind the order but either A < B or B < A must be /// true if A != B. bool operator<(const LLTCodeGen &Other) const { @@ -2207,7 +2207,7 @@ std::vector MergeInsnIDs; for (const auto &IDMatcherPair : Rule.defined_insn_vars()) MergeInsnIDs.push_back(IDMatcherPair.second); - std::sort(MergeInsnIDs.begin(), MergeInsnIDs.end()); + llvm::sort(MergeInsnIDs.begin(), MergeInsnIDs.end()); for (const auto &MergeInsnID : MergeInsnIDs) Table << MatchTable::IntValue(MergeInsnID); Table << MatchTable::NamedValue("GIU_MergeMemOperands_EndOfList") @@ -2435,7 +2435,7 @@ InsnIDs.push_back(Pair.second); } - std::sort(InsnIDs.begin(), InsnIDs.end()); + llvm::sort(InsnIDs.begin(), InsnIDs.end()); for (const auto &InsnID : InsnIDs) { // Reject the difficult cases until we have a more accurate check. @@ -3732,11 +3732,11 @@ std::vector ComplexPredicates = RK.getAllDerivedDefinitions("GIComplexOperandMatcher"); - std::sort(ComplexPredicates.begin(), ComplexPredicates.end(), orderByName); + llvm::sort(ComplexPredicates.begin(), ComplexPredicates.end(), orderByName); std::vector CustomRendererFns = RK.getAllDerivedDefinitions("GICustomOperandRenderer"); - std::sort(CustomRendererFns.begin(), CustomRendererFns.end(), orderByName); + llvm::sort(CustomRendererFns.begin(), CustomRendererFns.end(), orderByName); unsigned MaxTemporaries = 0; for (const auto &Rule : Rules) @@ -3812,7 +3812,7 @@ std::vector TypeObjects; for (const auto &Ty : LLTOperandMatcher::KnownTypes) TypeObjects.push_back(Ty); - std::sort(TypeObjects.begin(), TypeObjects.end()); + llvm::sort(TypeObjects.begin(), TypeObjects.end()); OS << "// LLT Objects.\n" << "enum {\n"; for (const auto &TypeObject : TypeObjects) { @@ -3834,7 +3834,7 @@ std::vector> FeatureBitsets; for (auto &Rule : Rules) FeatureBitsets.push_back(Rule.getRequiredFeatures()); - std::sort( + llvm::sort( FeatureBitsets.begin(), FeatureBitsets.end(), [&](const std::vector &A, const std::vector &B) { if (A.size() < B.size()) Index: utils/TableGen/InfoByHwMode.cpp =================================================================== --- utils/TableGen/InfoByHwMode.cpp +++ utils/TableGen/InfoByHwMode.cpp @@ -84,7 +84,7 @@ std::vector Pairs; for (const auto &P : Map) Pairs.push_back(&P); - std::sort(Pairs.begin(), Pairs.end(), deref>()); + llvm::sort(Pairs.begin(), Pairs.end(), deref>()); OS << '{'; for (unsigned i = 0, e = Pairs.size(); i != e; ++i) { @@ -176,7 +176,7 @@ std::vector Pairs; for (const auto &P : Map) Pairs.push_back(&P); - std::sort(Pairs.begin(), Pairs.end(), deref>()); + llvm::sort(Pairs.begin(), Pairs.end(), deref>()); OS << '{'; for (unsigned i = 0, e = Pairs.size(); i != e; ++i) { Index: utils/TableGen/RegisterInfoEmitter.cpp =================================================================== --- utils/TableGen/RegisterInfoEmitter.cpp +++ utils/TableGen/RegisterInfoEmitter.cpp @@ -296,7 +296,7 @@ PSetE = PSetIDs.end(); PSetI != PSetE; ++PSetI) { PSets[i].push_back(RegBank.getRegPressureSet(*PSetI).Order); } - std::sort(PSets[i].begin(), PSets[i].end()); + llvm::sort(PSets[i].begin(), PSets[i].end()); PSetsSeqs.add(PSets[i]); } Index: utils/TableGen/SubtargetEmitter.cpp =================================================================== --- utils/TableGen/SubtargetEmitter.cpp +++ utils/TableGen/SubtargetEmitter.cpp @@ -130,7 +130,7 @@ // Get all records of class and sort std::vector DefList = Records.getAllDerivedDefinitions("SubtargetFeature"); - std::sort(DefList.begin(), DefList.end(), LessRecord()); + llvm::sort(DefList.begin(), DefList.end(), LessRecord()); unsigned N = DefList.size(); if (N == 0) @@ -169,7 +169,7 @@ if (FeatureList.empty()) return 0; - std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); + llvm::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); // Begin feature table OS << "// Sorted (by key) array of values for CPU features.\n" @@ -220,7 +220,7 @@ // Gather and sort processor information std::vector ProcessorList = Records.getAllDerivedDefinitions("Processor"); - std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); + llvm::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); // Begin processor table OS << "// Sorted (by key) array of values for CPU subtype.\n" @@ -991,7 +991,7 @@ WriteIDs.push_back(SchedModels.getSchedRWIdx(VW, /*IsRead=*/false)); } } - std::sort(WriteIDs.begin(), WriteIDs.end()); + llvm::sort(WriteIDs.begin(), WriteIDs.end()); for(unsigned W : WriteIDs) { MCReadAdvanceEntry RAEntry; RAEntry.UseIdx = UseIdx; @@ -1009,8 +1009,8 @@ // compression. // // WritePrecRes entries are sorted by ProcResIdx. - std::sort(WriteProcResources.begin(), WriteProcResources.end(), - LessWriteProcResources()); + llvm::sort(WriteProcResources.begin(), WriteProcResources.end(), + LessWriteProcResources()); SCDesc.NumWriteProcResEntries = WriteProcResources.size(); std::vector::iterator WPRPos = @@ -1215,7 +1215,7 @@ // Gather and sort processor information std::vector ProcessorList = Records.getAllDerivedDefinitions("Processor"); - std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); + llvm::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); // Begin processor table OS << "\n"; @@ -1280,7 +1280,7 @@ << " const TargetSchedModel *SchedModel) const {\n"; std::vector Prologs = Records.getAllDerivedDefinitions("PredicateProlog"); - std::sort(Prologs.begin(), Prologs.end(), LessRecord()); + llvm::sort(Prologs.begin(), Prologs.end(), LessRecord()); for (Record *P : Prologs) { OS << P->getValueAsString("Code") << '\n'; } @@ -1364,7 +1364,7 @@ unsigned NumProcs) { std::vector Features = Records.getAllDerivedDefinitions("SubtargetFeature"); - std::sort(Features.begin(), Features.end(), LessRecord()); + llvm::sort(Features.begin(), Features.end(), LessRecord()); OS << "// ParseSubtargetFeatures - Parses features string setting specified\n" << "// subtarget options.\n" Index: utils/unittest/googlemock/include/gmock/gmock-matchers.h =================================================================== --- utils/unittest/googlemock/include/gmock/gmock-matchers.h +++ utils/unittest/googlemock/include/gmock/gmock-matchers.h @@ -2654,7 +2654,7 @@ LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); ::std::vector sorted_container(lhs_stl_container.begin(), lhs_stl_container.end()); - ::std::sort( + ::llvm::sort( sorted_container.begin(), sorted_container.end(), comparator_); if (!listener->IsInterested()) {