[Mlir-commits] [mlir] 337c937 - Apply clang-tidy fixes for performance-move-const-arg to MLIR (NFC)

Mehdi Amini llvmlistbot at llvm.org
Sun Jan 2 14:38:15 PST 2022


Author: Mehdi Amini
Date: 2022-01-02T22:36:56Z
New Revision: 337c937ddb94a3fd1257af482cb14c02abbda709

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

LOG: Apply clang-tidy fixes for performance-move-const-arg to MLIR (NFC)

Added: 
    

Modified: 
    mlir/lib/Analysis/PresburgerSet.cpp
    mlir/lib/Bindings/Python/IRAffine.cpp
    mlir/lib/Bindings/Python/IRCore.cpp
    mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
    mlir/lib/Reducer/ReductionNode.cpp
    mlir/lib/Reducer/ReductionTreePass.cpp
    mlir/lib/Support/Timing.cpp
    mlir/lib/Target/Cpp/TranslateToCpp.cpp
    mlir/unittests/TableGen/OpBuildGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/PresburgerSet.cpp b/mlir/lib/Analysis/PresburgerSet.cpp
index 84be397a221d7..22ea7a3a7eeca 100644
--- a/mlir/lib/Analysis/PresburgerSet.cpp
+++ b/mlir/lib/Analysis/PresburgerSet.cpp
@@ -117,9 +117,9 @@ PresburgerSet PresburgerSet::intersect(const PresburgerSet &set) const {
     for (const FlatAffineConstraints &csB : set.flatAffineConstraints) {
       FlatAffineConstraints csACopy = csA, csBCopy = csB;
       csACopy.mergeLocalIds(csBCopy);
-      csACopy.append(std::move(csBCopy));
+      csACopy.append(csBCopy);
       if (!csACopy.isEmpty())
-        result.unionFACInPlace(std::move(csACopy));
+        result.unionFACInPlace(csACopy);
     }
   }
   return result;

diff  --git a/mlir/lib/Bindings/Python/IRAffine.cpp b/mlir/lib/Bindings/Python/IRAffine.cpp
index 16c7ca335ac3e..0da936e85bc38 100644
--- a/mlir/lib/Bindings/Python/IRAffine.cpp
+++ b/mlir/lib/Bindings/Python/IRAffine.cpp
@@ -696,8 +696,7 @@ void mlir::python::populateIRAffine(py::module &m) {
              DefaultingPyMlirContext context) {
             SmallVector<MlirAffineExpr> affineExprs;
             pyListToVector<PyAffineExpr, MlirAffineExpr>(
-                std::move(exprs), affineExprs,
-                "attempting to create an AffineMap");
+                exprs, affineExprs, "attempting to create an AffineMap");
             MlirAffineMap map =
                 mlirAffineMapGet(context->get(), dimCount, symbolCount,
                                  affineExprs.size(), affineExprs.data());

diff  --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index be2abcdd501f5..b9d31b27b6bce 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1357,13 +1357,12 @@ PyOpView::buildGeneric(const py::object &cls, py::list resultTypeList,
   }
 
   // Delegate to create.
-  return PyOperation::create(std::move(name),
+  return PyOperation::create(name,
                              /*results=*/std::move(resultTypes),
                              /*operands=*/std::move(operands),
                              /*attributes=*/std::move(attributes),
                              /*successors=*/std::move(successors),
-                             /*regions=*/*regions, location,
-                             std::move(maybeIp));
+                             /*regions=*/*regions, location, maybeIp);
 }
 
 PyOpView::PyOpView(const py::object &operationObject)
@@ -1705,7 +1704,7 @@ void PySymbolTable::walkSymbolTables(PyOperationBase &from,
   if (userData.gotException) {
     std::string message("Exception raised in callback: ");
     message.append(userData.exceptionWhat);
-    throw std::runtime_error(std::move(message));
+    throw std::runtime_error(message);
   }
 }
 

diff  --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
index c325bfb424569..43c57a8e6033a 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -271,7 +271,7 @@ static void getConstraintPredicates(pdl::ApplyNativeConstraintOp op,
   Position *pos = *std::max_element(allPositions.begin(), allPositions.end(),
                                     comparePosDepth);
   PredicateBuilder::Predicate pred =
-      builder.getConstraint(op.name(), std::move(allPositions), parameters);
+      builder.getConstraint(op.name(), allPositions, parameters);
   predList.emplace_back(pos, pred);
 }
 

diff  --git a/mlir/lib/Reducer/ReductionNode.cpp b/mlir/lib/Reducer/ReductionNode.cpp
index 83892be4d4f54..1555bce333252 100644
--- a/mlir/lib/Reducer/ReductionNode.cpp
+++ b/mlir/lib/Reducer/ReductionNode.cpp
@@ -53,8 +53,7 @@ ArrayRef<ReductionNode *> ReductionNode::generateNewVariants() {
   int oldNumVariant = getVariants().size();
 
   auto createNewNode = [this](std::vector<Range> ranges) {
-    return new (allocator.Allocate())
-        ReductionNode(this, std::move(ranges), allocator);
+    return new (allocator.Allocate()) ReductionNode(this, ranges, allocator);
   };
 
   // If we haven't created new variant, then we can create varients by removing

diff  --git a/mlir/lib/Reducer/ReductionTreePass.cpp b/mlir/lib/Reducer/ReductionTreePass.cpp
index a1308f9362555..05f0f749166ed 100644
--- a/mlir/lib/Reducer/ReductionTreePass.cpp
+++ b/mlir/lib/Reducer/ReductionTreePass.cpp
@@ -92,7 +92,7 @@ static LogicalResult findOptimal(ModuleOp module, Region &region,
       {0, std::distance(region.op_begin(), region.op_end())}};
 
   ReductionNode *root = allocator.Allocate();
-  new (root) ReductionNode(nullptr, std::move(ranges), allocator);
+  new (root) ReductionNode(nullptr, ranges, allocator);
   // Duplicate the module for root node and locate the region in the copy.
   if (failed(root->initialize(module, region)))
     llvm_unreachable("unexpected initialization failure");

diff  --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index 7277e48595822..5732710f36c37 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -196,9 +196,9 @@ class TimerImpl {
   TimerImpl *nest(const void *id, function_ref<std::string()> nameBuilder) {
     auto tid = llvm::get_threadid();
     if (tid == threadId)
-      return nestTail(children[id], std::move(nameBuilder));
+      return nestTail(children[id], nameBuilder);
     std::unique_lock<std::mutex> lock(asyncMutex);
-    return nestTail(asyncChildren[tid][id], std::move(nameBuilder));
+    return nestTail(asyncChildren[tid][id], nameBuilder);
   }
 
   /// Tail-called from `nest()`.
@@ -524,7 +524,7 @@ void DefaultTimingManager::stopTimer(void *handle) {
 
 void *DefaultTimingManager::nestTimer(void *handle, const void *id,
                                       function_ref<std::string()> nameBuilder) {
-  return static_cast<TimerImpl *>(handle)->nest(id, std::move(nameBuilder));
+  return static_cast<TimerImpl *>(handle)->nest(id, nameBuilder);
 }
 
 void DefaultTimingManager::hideTimer(void *handle) {

diff  --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index 473c9ad7f1711..a51bf16e3c8ae 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -736,8 +736,7 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
   }
   if (auto dense = attr.dyn_cast<DenseFPElementsAttr>()) {
     os << '{';
-    interleaveComma(dense, os,
-                    [&](APFloat val) { printFloat(std::move(val)); });
+    interleaveComma(dense, os, [&](APFloat val) { printFloat(val); });
     os << '}';
     return success();
   }
@@ -760,7 +759,7 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
                          .dyn_cast<IntegerType>()) {
       os << '{';
       interleaveComma(dense, os, [&](APInt val) {
-        printInt(std::move(val), shouldMapToUnsigned(iType.getSignedness()));
+        printInt(val, shouldMapToUnsigned(iType.getSignedness()));
       });
       os << '}';
       return success();
@@ -770,8 +769,7 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
                          .getElementType()
                          .dyn_cast<IndexType>()) {
       os << '{';
-      interleaveComma(dense, os,
-                      [&](APInt val) { printInt(std::move(val), false); });
+      interleaveComma(dense, os, [&](APInt val) { printInt(val, false); });
       os << '}';
       return success();
     }

diff  --git a/mlir/unittests/TableGen/OpBuildGen.cpp b/mlir/unittests/TableGen/OpBuildGen.cpp
index 3b6f48936cc7a..9b985e32062e5 100644
--- a/mlir/unittests/TableGen/OpBuildGen.cpp
+++ b/mlir/unittests/TableGen/OpBuildGen.cpp
@@ -140,24 +140,24 @@ TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgAndResult) {
   // Test collective args, collective results method, building a unary op.
   auto op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
                                                    ValueRange{*cstI32});
-  verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
+  verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
 
   // Test collective args, collective results method, building a unary op with
   // named attributes.
   op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
                                               ValueRange{*cstI32}, attrs);
-  verifyOp(std::move(op), {i32Ty}, {*cstI32}, attrs);
+  verifyOp(op, {i32Ty}, {*cstI32}, attrs);
 
   // Test collective args, collective results method, building a binary op.
   op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
                                               ValueRange{*cstI32, *cstF32});
-  verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32, *cstF32}, noAttrs);
+  verifyOp(op, {i32Ty, f32Ty}, {*cstI32, *cstF32}, noAttrs);
 
   // Test collective args, collective results method, building a binary op with
   // named attributes.
   op = builder.create<test::TableGenBuildOp1>(
       loc, TypeRange{i32Ty, f32Ty}, ValueRange{*cstI32, *cstF32}, attrs);
-  verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32, *cstF32}, attrs);
+  verifyOp(op, {i32Ty, f32Ty}, {*cstI32, *cstF32}, attrs);
 }
 
 /// Test build methods for an Op with a single varadic arg and a non-variadic
@@ -166,22 +166,22 @@ TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
   // Test separate arg, separate param build method.
   auto op =
       builder.create<test::TableGenBuildOp1>(loc, i32Ty, ValueRange{*cstI32});
-  verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
+  verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
 
   // Test collective params build method, no attributes.
   op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
                                               ValueRange{*cstI32});
-  verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
+  verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
 
   // Test collective params build method no attributes, 2 inputs.
   op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
                                               ValueRange{*cstI32, *cstF32});
-  verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstF32}, noAttrs);
+  verifyOp(op, {i32Ty}, {*cstI32, *cstF32}, noAttrs);
 
   // Test collective params build method, non-empty attributes.
   op = builder.create<test::TableGenBuildOp1>(
       loc, TypeRange{i32Ty}, ValueRange{*cstI32, *cstF32}, attrs);
-  verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstF32}, attrs);
+  verifyOp(op, {i32Ty}, {*cstI32, *cstF32}, attrs);
 }
 
 /// Test build methods for an Op with a single varadic arg and multiple variadic
@@ -191,17 +191,17 @@ TEST_F(OpBuildGenTest,
   // Test separate arg, separate param build method.
   auto op = builder.create<test::TableGenBuildOp3>(
       loc, TypeRange{i32Ty}, TypeRange{f32Ty}, ValueRange{*cstI32});
-  verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, noAttrs);
+  verifyOp(op, {i32Ty, f32Ty}, {*cstI32}, noAttrs);
 
   // Test collective params build method, no attributes.
   op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
                                               ValueRange{*cstI32});
-  verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, noAttrs);
+  verifyOp(op, {i32Ty, f32Ty}, {*cstI32}, noAttrs);
 
   // Test collective params build method, with attributes.
   op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
                                               ValueRange{*cstI32}, attrs);
-  verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, attrs);
+  verifyOp(op, {i32Ty, f32Ty}, {*cstI32}, attrs);
 }
 
 // The next 2 tests test supression of ambiguous build methods for ops that
@@ -223,7 +223,7 @@ TEST_F(OpBuildGenTest, BuildMethodsRegionsAndInferredType) {
   auto op = builder.create<test::TableGenBuildOp6>(
       loc, ValueRange{*cstI32, *cstF32}, /*attributes=*/noAttrs);
   ASSERT_EQ(op->getNumRegions(), 1u);
-  verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstF32}, noAttrs);
+  verifyOp(op, {i32Ty}, {*cstI32, *cstF32}, noAttrs);
 }
 
 } // namespace mlir


        


More information about the Mlir-commits mailing list