diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp @@ -418,7 +418,7 @@ continue; // Update terminator `successor` block to `refCountingBlock`. - for (auto pair : llvm::enumerate(terminator->getSuccessors())) + for (const auto &pair : llvm::enumerate(terminator->getSuccessors())) if (pair.value() == successor) terminator->setSuccessor(refCountingBlock, pair.index()); } diff --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp --- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp +++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp @@ -134,7 +134,7 @@ auto offsets = delinearize(strides, i); SmallVector extracted(expandedOperands.size()); - for (auto tuple : llvm::enumerate(expandedOperands)) + for (const auto &tuple : llvm::enumerate(expandedOperands)) extracted[tuple.index()] = builder.create(tuple.value(), offsets); diff --git a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp b/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp @@ -67,7 +67,7 @@ // Convert function arguments using the provided TypeConverter. TypeConverter::SignatureConversion conversion(functionType.getNumInputs()); - for (auto argType : llvm::enumerate(functionType.getInputs())) { + for (const auto &argType : llvm::enumerate(functionType.getInputs())) { SmallVector decomposedTypes; if (failed(typeConverter->convertType(argType.value(), decomposedTypes))) return failure(); diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp --- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp @@ -1812,7 +1812,7 @@ if (resultKnowledge.size() != yieldOp.getNumOperands()) return failure(); - for (auto it : llvm::enumerate(yieldOp.getOperands())) { + for (const auto &it : llvm::enumerate(yieldOp.getOperands())) { int32_t index = it.index(); auto meet = ValueKnowledge::meet( resultKnowledge[index], @@ -1857,7 +1857,7 @@ if (resultKnowledge.size() != yieldOp.getNumOperands()) return failure(); - for (auto it : llvm::enumerate(yieldOp.getOperands())) { + for (const auto &it : llvm::enumerate(yieldOp.getOperands())) { int32_t index = it.index(); if (auto meet = ValueKnowledge::meet( resultKnowledge[index], diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp @@ -132,7 +132,7 @@ } for (auto yieldOp : yieldOps) { - for (auto it : llvm::enumerate(yieldOp.getOperands())) { + for (const auto &it : llvm::enumerate(yieldOp.getOperands())) { auto newKnowledge = ValueKnowledge::getKnowledgeFromType(it.value().getType()); yieldTypeInfo[it.index()] = diff --git a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp --- a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp +++ b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp @@ -253,7 +253,7 @@ return true; unsigned nDims = reassociation[0].getNumDims(); unsigned nextExpectedDim = 0; - for (auto it : llvm::enumerate(reassociation)) { + for (const auto &it : llvm::enumerate(reassociation)) { auto m = it.value(); if (m.getNumDims() != nDims || m.getNumSymbols() != 0) { if (invalidIndex) diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -182,7 +182,7 @@ if (failed(shapedOp.reifyReturnTypeShapes(b, op->getOperands(), shapes)) || !llvm::hasSingleElement(shapes)) return; - for (auto it : llvm::enumerate(shapes)) { + for (const auto &it : llvm::enumerate(shapes)) { op->emitRemark() << "value " << it.index() << ": " << it.value().getDefiningOp(); } diff --git a/mlir/test/lib/IR/TestPrintDefUse.cpp b/mlir/test/lib/IR/TestPrintDefUse.cpp --- a/mlir/test/lib/IR/TestPrintDefUse.cpp +++ b/mlir/test/lib/IR/TestPrintDefUse.cpp @@ -41,7 +41,7 @@ // Print information about the user of each of the result. llvm::outs() << "Has " << op->getNumResults() << " results:\n"; - for (auto indexedResult : llvm::enumerate(op->getResults())) { + for (const auto &indexedResult : llvm::enumerate(op->getResults())) { Value result = indexedResult.value(); llvm::outs() << " - Result " << indexedResult.index(); if (result.use_empty()) { diff --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp --- a/mlir/test/lib/IR/TestSlicing.cpp +++ b/mlir/test/lib/IR/TestSlicing.cpp @@ -33,7 +33,7 @@ builder.create(loc, clonedFuncOpName, parentFuncOp.getType()); BlockAndValueMapping mapper; builder.setInsertionPointToEnd(clonedFuncOp.addEntryBlock()); - for (auto arg : enumerate(parentFuncOp.getArguments())) + for (const auto &arg : enumerate(parentFuncOp.getArguments())) mapper.map(arg.value(), clonedFuncOp.getArgument(arg.index())); SetVector slice; getBackwardSlice(op, &slice); diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -361,7 +361,7 @@ static Optional findTensorDefArgIndex(StringRef name, SmallVectorImpl &args) { - for (auto it : llvm::enumerate(args)) { + for (const auto &it : llvm::enumerate(args)) { if (it.value().name == name) return it.index(); } @@ -382,7 +382,7 @@ return std::string("helper.getFloat64Type()"); // Search all argument types. - for (auto it : llvm::enumerate(args)) { + for (const auto &it : llvm::enumerate(args)) { if (it.value().typeVar == typeVar) return llvm::formatv("block.getArgument({0}).getType()", it.index()) .str(); diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -561,7 +561,7 @@ MethodParameter("const KeyTy &", "tblgenKey")); if (!def.hasStorageCustomConstructor()) { auto &body = construct->body().indent(); - for (auto it : llvm::enumerate(params)) { + for (const auto &it : llvm::enumerate(params)) { body << formatv("auto {0} = std::get<{1}>(tblgenKey);\n", it.value().getName(), it.index()); } diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp @@ -660,7 +660,7 @@ /// Collect all of the attribute's or type's parameters. SmallVector> vars; /// Ensure that none of the parameters have already been captured. - for (auto it : llvm::enumerate(def.getParameters())) { + for (const auto &it : llvm::enumerate(def.getParameters())) { if (seenParams.test(it.index())) { return emitError("`params` captures duplicate parameter: " + it.value().getName()); diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp --- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp @@ -65,7 +65,7 @@ const char *listName) { auto results = record.getValueAsListOfDefs(listName); IndicesTy overloadedOps(results.size()); - for (auto r : llvm::enumerate(results)) { + for (const auto &r : llvm::enumerate(results)) { llvm::MVT::SimpleValueType vt = getValueType(r.value()); switch (vt) { case llvm::MVT::iAny: diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -2265,7 +2265,7 @@ body << " {\n unsigned index = 0; (void)index;\n"; - for (auto staticValue : llvm::enumerate(values)) { + for (const auto &staticValue : llvm::enumerate(values)) { const NamedTypeConstraint &value = staticValue.value(); bool hasPredicate = value.hasPredicate(); @@ -2330,7 +2330,7 @@ return; body << " {\n unsigned index = 0; (void)index;\n"; - for (auto it : llvm::enumerate(regions)) { + for (const auto &it : llvm::enumerate(regions)) { const auto ®ion = it.value(); if (canSkip(region)) continue; diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -235,7 +235,7 @@ os << "\nSyntax:\n\n```\n!" << def.getDialect().getName() << "." << def.getMnemonic() << "<\n"; - for (auto it : llvm::enumerate(parameters)) { + for (const auto &it : llvm::enumerate(parameters)) { const AttrOrTypeParameter ¶m = it.value(); os << " " << param.getSyntax(); if (it.index() < (parameters.size() - 1)) diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp --- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp +++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp @@ -916,7 +916,7 @@ /// Emits named accessors to regions. static void emitRegionAccessors(const Operator &op, raw_ostream &os) { - for (auto en : llvm::enumerate(op.getRegions())) { + for (const auto &en : llvm::enumerate(op.getRegions())) { const NamedRegion ®ion = en.value(); if (region.name.empty()) continue;