diff --git a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp index 84556fbefbc9f..72a05ffe97ac0 100644 --- a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp +++ b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp @@ -497,8 +497,8 @@ coalesceTileLiveRanges(DenseMap &initialLiveRanges) { // Sort the new live ranges by starting point (ready for tile allocation). auto coalescedLiveRanges = uniqueLiveRanges.takeVector(); - std::sort(coalescedLiveRanges.begin(), coalescedLiveRanges.end(), - [](LiveRange *a, LiveRange *b) { return *a < *b; }); + llvm::sort(coalescedLiveRanges, + [](LiveRange *a, LiveRange *b) { return *a < *b; }); return std::move(coalescedLiveRanges); } @@ -824,8 +824,8 @@ LogicalResult mlir::arm_sme::allocateSMETiles(FunctionOpInterface function, [&](LiveRange const &liveRange) { return !liveRange.empty(); }); auto initialRanges = llvm::to_vector(llvm::map_range( nonEmpty, [](LiveRange const &liveRange) { return &liveRange; })); - std::sort(initialRanges.begin(), initialRanges.end(), - [](LiveRange const *a, LiveRange const *b) { return *a < *b; }); + llvm::sort(initialRanges, + [](LiveRange const *a, LiveRange const *b) { return *a < *b; }); llvm::errs() << "\n========== Initial Live Ranges:\n"; dumpLiveRanges(operationToIndexMap, initialRanges, function); } diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp index 51dfd84d9ac60..eed7a56fff8af 100644 --- a/mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp @@ -177,8 +177,7 @@ void DeallocationState::getMemrefsToRetain( // liveOut has non-deterministic order because it was constructed by iterating // over a hash-set. SmallVector retainedByLiveness(liveOut.begin(), liveOut.end()); - std::sort(retainedByLiveness.begin(), retainedByLiveness.end(), - ValueComparator()); + llvm::sort(retainedByLiveness, ValueComparator()); toRetain.append(retainedByLiveness); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/DecomposeGenericByUnfoldingPermutation.cpp b/mlir/lib/Dialect/Linalg/Transforms/DecomposeGenericByUnfoldingPermutation.cpp index ae8cb94661c76..daeae2c9d947d 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/DecomposeGenericByUnfoldingPermutation.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/DecomposeGenericByUnfoldingPermutation.cpp @@ -103,7 +103,7 @@ computeTransposeBroadcast(AffineMap &map) { // If dims are not monotonically increasing then transpose is present. SmallVector sortedResMap(minorResult); - std::sort(sortedResMap.begin(), sortedResMap.end()); + llvm::sort(sortedResMap); bool hasTranspose = !std::equal(minorResult.begin(), minorResult.end(), sortedResMap.begin(), sortedResMap.end()); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp index 86c13d03c7ec6..b94091cfa5f58 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp @@ -31,11 +31,10 @@ static bool isMaterializing(Value val) { /// Sorts the dependent loops such that it is ordered in the same sequence in /// which loops will be generated. static void sortDependentLoops(std::vector &target) { - std::sort(target.begin(), target.end(), - [](const LoopCoeffPair &l, const LoopCoeffPair &r) { - assert(std::addressof(l) == std::addressof(r) || l != r); - return l.first < r.first; - }); + llvm::sort(target, [](const LoopCoeffPair &l, const LoopCoeffPair &r) { + assert(std::addressof(l) == std::addressof(r) || l != r); + return l.first < r.first; + }); } //===----------------------------------------------------------------------===// // Code generation environment constructor and general methods diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp index ffa06bc0e2071..57291064eba22 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp @@ -459,26 +459,25 @@ void sparse_tensor::foreachInSparseConstant( } // Sorts the sparse element attribute based on coordinates. - std::sort(elems.begin(), elems.end(), - [order](const ElementAttr &lhs, const ElementAttr &rhs) { - if (std::addressof(lhs) == std::addressof(rhs)) - return false; - - auto lhsCoords = llvm::map_to_vector( - lhs.first, [](IntegerAttr i) { return i.getInt(); }); - auto rhsCoords = llvm::map_to_vector( - rhs.first, [](IntegerAttr i) { return i.getInt(); }); - - SmallVector lhsLvlCrds = order.compose(lhsCoords); - SmallVector rhsLvlCrds = order.compose(rhsCoords); - // Sort the element based on the lvl coordinates. - for (Level l = 0; l < order.getNumResults(); l++) { - if (lhsLvlCrds[l] == rhsLvlCrds[l]) - continue; - return lhsLvlCrds[l] < rhsLvlCrds[l]; - } - llvm_unreachable("no equal coordinate in sparse element attr"); - }); + llvm::sort(elems, [order](const ElementAttr &lhs, const ElementAttr &rhs) { + if (std::addressof(lhs) == std::addressof(rhs)) + return false; + + auto lhsCoords = llvm::map_to_vector( + lhs.first, [](IntegerAttr i) { return i.getInt(); }); + auto rhsCoords = llvm::map_to_vector( + rhs.first, [](IntegerAttr i) { return i.getInt(); }); + + SmallVector lhsLvlCrds = order.compose(lhsCoords); + SmallVector rhsLvlCrds = order.compose(rhsCoords); + // Sort the element based on the lvl coordinates. + for (Level l = 0; l < order.getNumResults(); l++) { + if (lhsLvlCrds[l] == rhsLvlCrds[l]) + continue; + return lhsLvlCrds[l] < rhsLvlCrds[l]; + } + llvm_unreachable("no equal coordinate in sparse element attr"); + }); SmallVector cvs; cvs.reserve(dimRank); diff --git a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp index fcb736aa031f3..fac836ebd7a36 100644 --- a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp +++ b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp @@ -237,8 +237,8 @@ getValuesSortedByKeyImpl(ArrayRef keys, ArrayRef values, return SmallVector{values}; assert(keys.size() == values.size() && "unexpected mismatching sizes"); auto indices = llvm::to_vector(llvm::seq(0, values.size())); - std::sort(indices.begin(), indices.end(), - [&](int64_t i, int64_t j) { return compare(keys[i], keys[j]); }); + llvm::sort(indices, + [&](int64_t i, int64_t j) { return compare(keys[i], keys[j]); }); SmallVector res; res.reserve(values.size()); for (int64_t i = 0, e = indices.size(); i < e; ++i) diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index 8d1fbcdb19a9d..e0e9b5f54042a 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -689,7 +689,7 @@ LogicalResult OpToOpPassAdaptor::tryMergeInto(MLIRContext *ctx, } return false; // lhs(op-agnostic) > rhs(op-specific) }; - std::sort(rhs.mgrs.begin(), rhs.mgrs.end(), compareFn); + llvm::sort(rhs.mgrs, compareFn); return success(); } diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp index 077f9d1ea2b13..f2b269e3a4542 100644 --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -583,15 +583,14 @@ static bool emitDialectDoc(const RecordKeeper &records, raw_ostream &os) { // sections. // TODO: The sorting order could be revised, currently attempting to sort of // keep in alphabetical order. - std::sort(dialectOps.begin(), dialectOps.end(), - [](const OpDocGroup &lhs, const OpDocGroup &rhs) { - auto getDesc = [](const OpDocGroup &arg) -> StringRef { - if (!arg.summary.empty()) - return arg.summary; - return arg.ops.front().getDef().getValueAsString("opName"); - }; - return getDesc(lhs).compare_insensitive(getDesc(rhs)) < 0; - }); + llvm::sort(dialectOps, [](const OpDocGroup &lhs, const OpDocGroup &rhs) { + auto getDesc = [](const OpDocGroup &arg) -> StringRef { + if (!arg.summary.empty()) + return arg.summary; + return arg.ops.front().getDef().getValueAsString("opName"); + }; + return getDesc(lhs).compare_insensitive(getDesc(rhs)) < 0; + }); os << "\n"; emitDialectDoc(*dialect, records.getInputFilename(), dialectAttrs,