Use llvm::sort instead of std::sort where possible

llvm::sort is beneficial even when we use the iterator-based overload,
since it can optionally shuffle the elements (to detect
non-determinism). However llvm::sort is not usable everywhere, for
example, in compiler-rt.

Reviewed By: nhaehnle

Differential Revision: https://reviews.llvm.org/D130406
This commit is contained in:
Dmitri Gribenko 2022-07-23 15:14:14 +02:00
parent e82880e6b8
commit aba43035bd
31 changed files with 127 additions and 120 deletions

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "IncludeFixerContext.h"
#include <algorithm>
#include "llvm/ADT/STLExtras.h"
namespace clang {
namespace include_fixer {
@ -84,7 +84,7 @@ IncludeFixerContext::IncludeFixerContext(
// QuerySymbolInfos may contain replicated elements. Because CorrectTypo
// callback doesn't always work as we expected. In somecases, it will be
// triggered at the same position or unidentified symbol multiple times.
std::sort(QuerySymbolInfos.begin(), QuerySymbolInfos.end(),
llvm::sort(QuerySymbolInfos,
[&](const QuerySymbolInfo &A, const QuerySymbolInfo &B) {
return std::make_pair(A.Range.getOffset(), A.Range.getLength()) <
std::make_pair(B.Range.getOffset(), B.Range.getLength());

View File

@ -21,8 +21,8 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Refactoring.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include <algorithm>
#include <string>
namespace clang {
@ -206,8 +206,7 @@ static void reorderFieldsInConstructor(
return NewFieldsPositions[LHS->getMember()->getFieldIndex()] <
NewFieldsPositions[RHS->getMember()->getFieldIndex()];
};
std::sort(std::begin(NewWrittenInitializersOrder),
std::end(NewWrittenInitializersOrder), ByFieldNewPosition);
llvm::sort(NewWrittenInitializersOrder, ByFieldNewPosition);
assert(OldWrittenInitializersOrder.size() ==
NewWrittenInitializersOrder.size());
for (unsigned i = 0, e = NewWrittenInitializersOrder.size(); i < e; ++i)

View File

@ -14,6 +14,7 @@
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Analysis/CFG.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/STLExtras.h"
#include "../utils/ExprSequence.h"
@ -228,8 +229,7 @@ void UseAfterMoveFinder::getUsesAndReinits(
}
// Sort the uses by their occurrence in the source code.
std::sort(Uses->begin(), Uses->end(),
[](const DeclRefExpr *D1, const DeclRefExpr *D2) {
llvm::sort(*Uses, [](const DeclRefExpr *D1, const DeclRefExpr *D2) {
return D1->getExprLoc() < D2->getExprLoc();
});
}

View File

@ -10,6 +10,7 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/STLExtras.h"
#include <map>
@ -125,16 +126,16 @@ void IncludeOrderPPCallbacks::EndOfMainFile() {
// Sort the includes. We first sort by priority, then lexicographically.
for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI)
std::sort(IncludeIndices.begin() + Blocks[BI],
llvm::sort(IncludeIndices.begin() + Blocks[BI],
IncludeIndices.begin() + Blocks[BI + 1],
[&FileDirectives](unsigned LHSI, unsigned RHSI) {
IncludeDirective &LHS = FileDirectives[LHSI];
IncludeDirective &RHS = FileDirectives[RHSI];
int PriorityLHS =
getPriority(LHS.Filename, LHS.IsAngled, LHS.IsMainModule);
int PriorityRHS =
getPriority(RHS.Filename, RHS.IsAngled, RHS.IsMainModule);
int PriorityLHS = getPriority(LHS.Filename, LHS.IsAngled,
LHS.IsMainModule);
int PriorityRHS = getPriority(RHS.Filename, RHS.IsAngled,
RHS.IsMainModule);
return std::tie(PriorityLHS, LHS.Filename) <
std::tie(PriorityRHS, RHS.Filename);

View File

@ -5,13 +5,13 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
using namespace llvm;
int main(int argc, char *argv[]) {
@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
Entries.emplace_back(CodePoint, To);
}
std::sort(Entries.begin(), Entries.end());
llvm::sort(Entries);
unsigned LargestValue =
std::max_element(Entries.begin(), Entries.end(),

View File

@ -9,8 +9,8 @@
#include "InconsistentDeclarationParameterNameCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <functional>
using namespace clang::ast_matchers;
@ -158,7 +158,7 @@ findInconsistentDeclarations(const FunctionDecl *OriginalDeclaration,
// Sort in order of appearance in translation unit to generate clear
// diagnostics.
std::sort(InconsistentDeclarations.begin(), InconsistentDeclarations.end(),
llvm::sort(InconsistentDeclarations,
[&SM](const InconsistentDeclarationInfo &Info1,
const InconsistentDeclarationInfo &Info2) {
return SM.isBeforeInTranslationUnit(Info1.DeclarationLocation,

View File

@ -35,6 +35,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
@ -475,7 +476,7 @@ collectAccessibleScopes(Sema &Sem, const DeclarationNameInfo &Typo, Scope *S,
Sem.LookupVisibleDecls(S, LookupKind, Collector,
/*IncludeGlobalScope=*/false,
/*LoadExternal=*/false);
std::sort(Scopes.begin(), Scopes.end());
llvm::sort(Scopes);
Scopes.erase(std::unique(Scopes.begin(), Scopes.end()), Scopes.end());
return Scopes;
}

View File

@ -10,6 +10,7 @@
#include "clang-pseudo/grammar/LRGraph.h"
#include "clang-pseudo/grammar/LRTable.h"
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include <cstdint>
@ -60,7 +61,7 @@ LRTable LRTable::Builder::build() && {
continue;
Table.Reduces.insert(Table.Reduces.end(), It->second.begin(),
It->second.end());
std::sort(Table.Reduces.begin() + Table.ReduceOffset.back(),
llvm::sort(Table.Reduces.begin() + Table.ReduceOffset.back(),
Table.Reduces.end());
}
Table.ReduceOffset.push_back(Table.Reduces.size());

View File

@ -35,7 +35,7 @@
#include "llvm/IR/Type.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm> // std::sort
#include <algorithm>
using namespace clang;
using namespace CodeGen;

View File

@ -12,6 +12,7 @@
#include "clang/Tooling/Transformer/RangeSelector.h"
#include "clang/Tooling/Transformer/RewriteRule.h"
#include "clang/Tooling/Transformer/Stencil.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "gmock/gmock.h"
@ -1617,8 +1618,7 @@ TEST_F(TransformerTest, MultipleFiles) {
"clang-tool", std::make_shared<PCHContainerOperations>(),
{{"input.h", Header}}));
std::sort(Changes.begin(), Changes.end(),
[](const AtomicChange &L, const AtomicChange &R) {
llvm::sort(Changes, [](const AtomicChange &L, const AtomicChange &R) {
return L.getFilePath() < R.getFilePath();
});

View File

@ -13,6 +13,7 @@
#include "Symbols.h"
#include "Writer.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/COFF.h"
#include "llvm/Support/Debug.h"
@ -815,7 +816,7 @@ void RVATableChunk::writeTo(uint8_t *buf) const {
size_t cnt = 0;
for (const ChunkAndOffset &co : syms)
begin[cnt++] = co.inputChunk->getRVA() + co.offset;
std::sort(begin, begin + cnt);
llvm::sort(begin, begin + cnt);
assert(std::unique(begin, begin + cnt) == begin + cnt &&
"RVA tables should be de-duplicated");
}

View File

@ -21,6 +21,7 @@
#include "COFFLinkerContext.h"
#include "Chunks.h"
#include "SymbolTable.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Object/COFF.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Path.h"
@ -150,8 +151,7 @@ binImports(const std::vector<DefinedImportData *> &imports) {
for (auto &kv : m) {
// Sort symbols by name for each group.
std::vector<DefinedImportData *> &syms = kv.second;
std::sort(syms.begin(), syms.end(),
[](DefinedImportData *a, DefinedImportData *b) {
llvm::sort(syms, [](DefinedImportData *a, DefinedImportData *b) {
return a->getName() < b->getName();
});
v.push_back(std::move(syms));

View File

@ -18,6 +18,7 @@
#include "lld/Common/ErrorHandler.h"
#include "lld/Common/Memory.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/COFF.h"
@ -694,8 +695,7 @@ void fixupExports() {
config->exports = std::move(v);
// Sort by name.
std::sort(config->exports.begin(), config->exports.end(),
[](const Export &a, const Export &b) {
llvm::sort(config->exports, [](const Export &a, const Export &b) {
return a.exportName < b.exportName;
});
}

View File

@ -29,6 +29,7 @@
#include "lld/Common/DWARF.h"
#include "lld/Common/Strings.h"
#include "lld/Common/Version.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/Dwarf.h"
@ -1703,7 +1704,7 @@ void RelocationBaseSection::computeRels() {
parallelSort(relocs.begin(), nonRelative,
[&](auto &a, auto &b) { return a.r_offset < b.r_offset; });
// Non-relative relocations are few, so don't bother with parallelSort.
std::sort(nonRelative, relocs.end(), [&](auto &a, auto &b) {
llvm::sort(nonRelative, relocs.end(), [&](auto &a, auto &b) {
return std::tie(a.r_sym, a.r_offset) < std::tie(b.r_sym, b.r_offset);
});
}
@ -2039,7 +2040,7 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize() {
std::unique_ptr<uint64_t[]> offsets(new uint64_t[relocs.size()]);
for (auto it : llvm::enumerate(relocs))
offsets[it.index()] = it.value().getOffset();
std::sort(offsets.get(), offsets.get() + relocs.size());
llvm::sort(offsets.get(), offsets.get() + relocs.size());
// For each leading relocation, find following ones that can be folded
// as a bitmap and fold them.

View File

@ -802,7 +802,7 @@ void ValueEnumerator::organizeMetadata() {
// - by function, then
// - by isa<MDString>
// 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
// be unique, the result of llvm::sort will be deterministic. There's no need
// for std::stable_sort.
llvm::sort(Order, [this](MDIndex LHS, MDIndex RHS) {
return std::make_tuple(LHS.F, getMetadataTypeOrder(LHS.get(MDs)), LHS.ID) <

View File

@ -3709,8 +3709,7 @@ Optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIsImpl(
for (auto &PHI : CreatedPHIs)
SortedPHIs.push_back(PHI);
std::sort(
SortedPHIs.begin(), SortedPHIs.end(), [&](LDVSSAPhi *A, LDVSSAPhi *B) {
llvm::sort(SortedPHIs, [&](LDVSSAPhi *A, LDVSSAPhi *B) {
return BBToOrder[&A->getParent()->BB] < BBToOrder[&B->getParent()->BB];
});

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCPseudoProbe.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
@ -519,7 +520,7 @@ void MCPseudoProbeDecoder::printProbesForAllAddresses(raw_ostream &OS) {
std::vector<uint64_t> Addresses;
for (auto Entry : Address2ProbesMap)
Addresses.push_back(Entry.first);
std::sort(Addresses.begin(), Addresses.end());
llvm::sort(Addresses);
for (auto K : Addresses) {
OS << "Address:\t";
OS << K;

View File

@ -13,6 +13,7 @@
#include "DXILBitcodeWriter.h"
#include "DXILValueEnumerator.h"
#include "PointerTypeAnalysis.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitcodeCommon.h"
#include "llvm/Bitcode/BitcodeReader.h"
@ -2580,8 +2581,7 @@ void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
SortedTable.push_back(VI.second->getValueName());
}
// The keys are unique, so there shouldn't be stability issues.
std::sort(SortedTable.begin(), SortedTable.end(),
[](const ValueName *A, const ValueName *B) {
llvm::sort(SortedTable, [](const ValueName *A, const ValueName *B) {
return A->first() < B->first();
});

View File

@ -809,7 +809,7 @@ void ValueEnumerator::organizeMetadata() {
// - by function, then
// - by isa<MDString>
// 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
// be unique, the result of llvm::sort will be deterministic. There's no need
// for std::stable_sort.
llvm::sort(Order, [this](MDIndex LHS, MDIndex RHS) {
return std::make_tuple(LHS.F, getMetadataTypeOrder(LHS.get(MDs)), LHS.ID) <

View File

@ -27,7 +27,7 @@
#include "llvm/IR/Function.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm> // std::sort
#include <algorithm>
using namespace llvm;

View File

@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"
#include <string>
@ -78,7 +79,7 @@ TEST(SmallSetTest, IteratorInt) {
std::vector<int> V(s1.begin(), s1.end());
// Make sure the elements are in the expected order.
std::sort(V.begin(), V.end());
llvm::sort(V);
for (int i = 0; i < 3; i++)
EXPECT_EQ(i, V[i]);
@ -89,7 +90,7 @@ TEST(SmallSetTest, IteratorInt) {
V.assign(s1.begin(), s1.end());
// Make sure the elements are in the expected order.
std::sort(V.begin(), V.end());
llvm::sort(V);
for (int i = 0; i < 6; i++)
EXPECT_EQ(i, V[i]);
}
@ -104,7 +105,7 @@ TEST(SmallSetTest, IteratorString) {
s1.insert("str 1");
std::vector<std::string> V(s1.begin(), s1.end());
std::sort(V.begin(), V.end());
llvm::sort(V);
EXPECT_EQ(2u, s1.size());
EXPECT_EQ("str 1", V[0]);
EXPECT_EQ("str 2", V[1]);
@ -115,7 +116,7 @@ TEST(SmallSetTest, IteratorString) {
V.assign(s1.begin(), s1.end());
// Make sure the elements are in the expected order.
std::sort(V.begin(), V.end());
llvm::sort(V);
EXPECT_EQ(4u, s1.size());
EXPECT_EQ("str 0", V[0]);
EXPECT_EQ("str 1", V[1]);

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/MIRParser/MIRParser.h"
#include "llvm/CodeGen/MIRPrinter.h"
#include "llvm/CodeGen/MachineFunction.h"
@ -271,8 +272,8 @@ body: |
for (auto &MD : MDList)
Collected.push_back(MD.second);
std::sort(Generated.begin(), Generated.end());
std::sort(Collected.begin(), Collected.end());
llvm::sort(Generated);
llvm::sort(Collected);
EXPECT_EQ(Collected, Generated);
// FileCheck the output from MIR printer.
@ -421,8 +422,8 @@ body: |
for (auto &MD : MDList)
Collected.push_back(MD.second);
std::sort(Generated.begin(), Generated.end());
std::sort(Collected.begin(), Collected.end());
llvm::sort(Generated);
llvm::sort(Collected);
EXPECT_EQ(Collected, Generated);
// FileCheck the output from MIR printer.
@ -520,8 +521,8 @@ body: |
for (auto &MD : MDList)
Collected.push_back(MD.second);
std::sort(Generated.begin(), Generated.end());
std::sort(Collected.begin(), Collected.end());
llvm::sort(Generated);
llvm::sort(Collected);
EXPECT_EQ(Collected, Generated);
// FileCheck the output from MIR printer.

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Alignment.h"
#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"
#include <vector>
@ -179,7 +180,7 @@ TEST(AlignmentTest, offsetToAlignment) {
TEST(AlignmentTest, AlignComparisons) {
std::vector<uint64_t> ValidAlignments = getValidAlignments();
std::sort(ValidAlignments.begin(), ValidAlignments.end());
llvm::sort(ValidAlignments);
for (size_t I = 1; I < ValidAlignments.size(); ++I) {
assert(I >= 1);
const Align A(ValidAlignments[I - 1]);

View File

@ -122,8 +122,7 @@ static std::string buildCategoryStr(StringSet<> &Cetegorys) {
static void emitDXILEnums(std::vector<DXILOperationData> &DXILOps,
raw_ostream &OS) {
// Sort by Category + OpName.
std::sort(DXILOps.begin(), DXILOps.end(),
[](DXILOperationData &A, DXILOperationData &B) {
llvm::sort(DXILOps, [](DXILOperationData &A, DXILOperationData &B) {
// Group by Category first.
if (A.Category == B.Category)
// Inside same Category, order by OpName.
@ -160,8 +159,7 @@ static void emitDXILEnums(std::vector<DXILOperationData> &DXILOps,
std::make_pair(It.getKey().str(), buildCategoryStr(It.second)));
}
// Sort by Category + ClassName.
std::sort(ClassVec.begin(), ClassVec.end(),
[](std::pair<std::string, std::string> &A,
llvm::sort(ClassVec, [](std::pair<std::string, std::string> &A,
std::pair<std::string, std::string> &B) {
StringRef ClassA = A.first;
StringRef CategoryA = A.second;
@ -266,8 +264,7 @@ static std::string getDXILOpClassName(StringRef DXILOpClass) {
static void emitDXILOperationTable(std::vector<DXILOperationData> &DXILOps,
raw_ostream &OS) {
// Sort by DXILOpID.
std::sort(DXILOps.begin(), DXILOps.end(),
[](DXILOperationData &A, DXILOperationData &B) {
llvm::sort(DXILOps, [](DXILOperationData &A, DXILOperationData &B) {
return A.DXILOpID < B.DXILOpID;
});

View File

@ -681,7 +681,7 @@ void GenerateFlangClausesParser(const DirectiveLanguage &DirLang,
std::vector<Record *> Clauses = DirLang.getClauses();
// Sort clauses in reverse alphabetical order so with clauses with same
// beginning, the longer option is tried before.
std::sort(Clauses.begin(), Clauses.end(), compareClauseName);
llvm::sort(Clauses, compareClauseName);
IfDefScope Scope("GEN_FLANG_CLAUSES_PARSER", OS);
OS << "\n";
unsigned index = 0;

View File

@ -15,6 +15,7 @@
#include "CodeGenIntrinsics.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
@ -650,8 +651,9 @@ void SearchableTableEmitter::collectTableEntries(
SearchIndex Idx;
std::copy(Table.Fields.begin(), Table.Fields.end(),
std::back_inserter(Idx.Fields));
std::sort(Table.Entries.begin(), Table.Entries.end(),
[&](Record *LHS, Record *RHS) { return compareBy(LHS, RHS, Idx); });
llvm::sort(Table.Entries, [&](Record *LHS, Record *RHS) {
return compareBy(LHS, RHS, Idx);
});
}
void SearchableTableEmitter::run(raw_ostream &OS) {

View File

@ -121,8 +121,9 @@ public:
std::pair<std::string, std::vector<uint8_t>> serialize() {
std::set<std::string> Names = this->getNameFragments();
std::vector<std::string> Sorted(Names.begin(), Names.end());
std::sort(Sorted.begin(), Sorted.end(),
[](const auto &a, const auto &b) { return a.size() > b.size(); });
llvm::sort(Sorted, [](const auto &a, const auto &b) {
return a.size() > b.size();
});
std::string Dict(Letters.begin(), Letters.end());
Dict.reserve(50000);
for (const std::string &Name : Sorted) {

View File

@ -15,6 +15,7 @@
#include "mlir/IR/Operation.h"
#include "mlir/IR/Region.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/raw_ostream.h"
@ -288,8 +289,7 @@ void Liveness::print(raw_ostream &os) const {
auto printValueRefs = [&](const ValueSetT &values) {
std::vector<Value> orderedValues(values.begin(), values.end());
std::sort(orderedValues.begin(), orderedValues.end(),
[&](Value left, Value right) {
llvm::sort(orderedValues, [&](Value left, Value right) {
return valueIds[left] < valueIds[right];
});
for (Value value : orderedValues)
@ -317,8 +317,7 @@ void Liveness::print(raw_ostream &os) const {
printValueRef(result);
os << ":";
auto liveOperations = resolveLiveness(result);
std::sort(liveOperations.begin(), liveOperations.end(),
[&](Operation *left, Operation *right) {
llvm::sort(liveOperations, [&](Operation *left, Operation *right) {
return operationIds[left] < operationIds[right];
});
for (Operation *operation : liveOperations) {

View File

@ -26,6 +26,7 @@
#include "mlir/Transforms/Passes.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
@ -683,7 +684,7 @@ static void getProducerCandidates(unsigned dstId, MemRefDependenceGraph *mdg,
srcIdCandidates.push_back(srcNode->id);
}
std::sort(srcIdCandidates.begin(), srcIdCandidates.end());
llvm::sort(srcIdCandidates);
srcIdCandidates.erase(
std::unique(srcIdCandidates.begin(), srcIdCandidates.end()),
srcIdCandidates.end());

View File

@ -673,7 +673,7 @@ void mlir::collapseParallelLoops(
// Presort combined dimensions.
auto sortedDimensions = llvm::to_vector<3>(combinedDimensions);
for (auto &dims : sortedDimensions)
std::sort(dims.begin(), dims.end());
llvm::sort(dims);
// Normalize ParallelOp's iteration pattern.
SmallVector<Value, 3> normalizedLowerBounds, normalizedSteps,

View File

@ -1073,7 +1073,7 @@ static AffineExpr getSemiAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
// Constructing the simplified semi-affine sum of product/division/mod
// expression from the flattened form in the desired sorted order of indices
// of the various individual product/division/mod expressions.
std::sort(indices.begin(), indices.end());
llvm::sort(indices);
for (const std::pair<unsigned, unsigned> index : indices) {
assert(indexToExprMap.lookup(index) &&
"cannot find key in `indexToExprMap` map");