[Mlir-commits] [mlir] f55ed88 - [mlir] Use x.empty() instead of llvm::empty(x) (NFC)

Kazu Hirata llvmlistbot at llvm.org
Sun Sep 18 10:53:59 PDT 2022


Author: Kazu Hirata
Date: 2022-09-18T10:53:49-07:00
New Revision: f55ed88936f3cdf0e9c0ac9c52761dd199b6ab2b

URL: https://github.com/llvm/llvm-project/commit/f55ed88936f3cdf0e9c0ac9c52761dd199b6ab2b
DIFF: https://github.com/llvm/llvm-project/commit/f55ed88936f3cdf0e9c0ac9c52761dd199b6ab2b.diff

LOG: [mlir] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

Added: 
    

Modified: 
    mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
    mlir/lib/IR/Block.cpp
    mlir/lib/IR/Operation.cpp
    mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
    mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
    mlir/lib/Transforms/Utils/DialectConversion.cpp
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
index a1e8e31d9a923..731e0e66b8938 100644
--- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
+++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
@@ -46,7 +46,7 @@ using namespace mlir::vector;
 static Value buildMinMaxReductionSeq(Location loc,
                                      arith::CmpIPredicate predicate,
                                      ValueRange values, OpBuilder &builder) {
-  assert(!llvm::empty(values) && "empty min/max chain");
+  assert(!values.empty() && "empty min/max chain");
 
   auto valueIt = values.begin();
   Value value = *valueIt++;

diff  --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index cedbe19d8f0ed..dc4ec1458bd95 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -173,7 +173,7 @@ BlockArgument Block::insertArgument(unsigned index, Type type, Location loc) {
 /// Insert one value to the given position of the argument list. The existing
 /// arguments are shifted. The block is expected not to have predecessors.
 BlockArgument Block::insertArgument(args_iterator it, Type type, Location loc) {
-  assert(llvm::empty(getPredecessors()) &&
+  assert(getPredecessors().empty() &&
          "cannot insert arguments to blocks with predecessors");
   return insertArgument(it->getArgNumber(), type, loc);
 }

diff  --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 886b5bb58c925..219f1e21f379f 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -1154,14 +1154,14 @@ impl::foldCastInterfaceOp(Operation *op, ArrayRef<Attribute> attrOperands,
 LogicalResult impl::verifyCastInterfaceOp(
     Operation *op, function_ref<bool(TypeRange, TypeRange)> areCastCompatible) {
   auto resultTypes = op->getResultTypes();
-  if (llvm::empty(resultTypes))
+  if (resultTypes.empty())
     return op->emitOpError()
            << "expected at least one result for cast operation";
 
   auto operandTypes = op->getOperandTypes();
   if (!areCastCompatible(operandTypes, resultTypes)) {
     InFlightDiagnostic diag = op->emitOpError("operand type");
-    if (llvm::empty(operandTypes))
+    if (operandTypes.empty())
       diag << "s []";
     else if (llvm::size(operandTypes) == 1)
       diag << " " << *operandTypes.begin();

diff  --git a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
index 7988150bcba56..765782519ffd4 100644
--- a/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
+++ b/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp
@@ -18,7 +18,7 @@ using namespace mlir;
 
 static LogicalResult convertPDLToPDLInterp(ModuleOp pdlModule) {
   // Skip the conversion if the module doesn't contain pdl.
-  if (llvm::empty(pdlModule.getOps<pdl::PatternOp>()))
+  if (pdlModule.getOps<pdl::PatternOp>().empty())
     return success();
 
   // Simplify the provided PDL module. Note that we can't use the canonicalizer

diff  --git a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
index 2be71b67f5292..3b08f5413c9ae 100644
--- a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
+++ b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
@@ -37,7 +37,7 @@ class NodePrinter {
             std::enable_if_t<!std::is_convertible<RangeT, const Node *>::value>
                 * = nullptr>
   void printChildren(RangeT &&range) {
-    if (llvm::empty(range))
+    if (range.empty())
       return;
 
     // Print the first N-1 elements with a prefix of "|-".
@@ -59,7 +59,7 @@ class NodePrinter {
   /// the given label.
   template <typename RangeT>
   void printChildren(StringRef label, RangeT &&range) {
-    if (llvm::empty(range))
+    if (range.empty())
       return;
     elementIndentStack.reserve(elementIndentStack.size() + 1);
     llvm::SaveAndRestore<bool> lastElement(elementIndentStack.back(), true);

diff  --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index f2184d20d1a69..ccbfc78d70905 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -34,7 +34,7 @@ computeConversionSet(iterator_range<Region::iterator> region,
                      Location regionLoc,
                      SmallVectorImpl<Operation *> &toConvert,
                      ConversionTarget *target = nullptr) {
-  if (llvm::empty(region))
+  if (region.empty())
     return success();
 
   // Traverse starting from the entry block.

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index f9a5c8506d96d..ef0f0940d4b8d 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2839,7 +2839,7 @@ void OpEmitter::genOpAsmInterface() {
   auto &body = method->body();
   for (int i = 0; i != numResults; ++i) {
     body << "  auto resultGroup" << i << " = getODSResults(" << i << ");\n"
-         << "  if (!llvm::empty(resultGroup" << i << "))\n"
+         << "  if (!resultGroup" << i << ".empty())\n"
          << "    setNameFn(*resultGroup" << i << ".begin(), \""
          << resultNames[i] << "\");\n";
   }


        


More information about the Mlir-commits mailing list