diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp --- a/llvm/lib/ObjectYAML/DWARFYAML.cpp +++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp @@ -59,7 +59,7 @@ DWARFYAML::Data::getAbbrevTableInfoByID(uint64_t ID) const { if (AbbrevTableInfoMap.empty()) { uint64_t AbbrevTableOffset = 0; - for (auto &AbbrevTable : enumerate(DebugAbbrev)) { + for (auto &&AbbrevTable : enumerate(DebugAbbrev)) { // If the abbrev table's ID isn't specified, we use the index as its ID. uint64_t AbbrevTableID = AbbrevTable.value().ID.value_or(AbbrevTable.index()); diff --git a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp --- a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp +++ b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp @@ -236,7 +236,7 @@ Obj.Header.StreamDirectoryRVA = File.allocateArray(ArrayRef(StreamDirectory)); Obj.Header.NumberOfStreams = StreamDirectory.size(); - for (auto &Stream : enumerate(Obj.Streams)) + for (auto &&Stream : enumerate(Obj.Streams)) StreamDirectory[Stream.index()] = layout(File, *Stream.value()); File.writeTo(Out); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3953,7 +3953,7 @@ return std::get<1>(X) < std::get<1>(Y); }); int InitialOffset = std::get<1>(Vec[0]); - AnyConsecutive |= all_of(enumerate(Vec), [InitialOffset](auto &P) { + AnyConsecutive |= all_of(enumerate(Vec), [InitialOffset](auto &&P) { return std::get<1>(P.value()) == int(P.index()) + InitialOffset; }); } diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp --- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp @@ -101,7 +101,7 @@ continue; std::set ArgIndexesToKeep; - for (auto &Arg : enumerate(F->args())) + for (auto &&Arg : enumerate(F->args())) if (ArgsToKeep.count(&Arg.value())) ArgIndexesToKeep.insert(Arg.index()); diff --git a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp --- a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp +++ b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp @@ -280,7 +280,7 @@ // 2, 4, 7 EXPECT_EQ(3u, TestState->Callbacks.count()); - for (auto &I : enumerate(IndicesToVisit)) + for (auto &&I : enumerate(IndicesToVisit)) EXPECT_TRUE(ValidateVisitedRecord(I.index(), I.value())); } @@ -341,7 +341,7 @@ // 5, 7 EXPECT_EQ(2u, TestState->Callbacks.count()); - for (auto &I : enumerate(IndicesToVisit)) + for (auto &&I : enumerate(IndicesToVisit)) EXPECT_TRUE(ValidateVisitedRecord(I.index(), I.value())); } diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp --- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp @@ -191,7 +191,7 @@ dyn_cast(predecessor->getTerminator())) { SuccessorOperands operands = branch.getSuccessorOperands(it.getSuccessorIndex()); - for (auto &it : llvm::enumerate(argLattices)) { + for (auto &&it : llvm::enumerate(argLattices)) { if (Value operand = operands[it.index()]) { join(it.value(), *getLatticeElementFor(block, operand)); } else { diff --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp --- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp +++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp @@ -98,7 +98,7 @@ } // Assign the entry numbers based on the sort order. - for (auto &entry : llvm::enumerate(range)) + for (auto &&entry : llvm::enumerate(range)) entry.value()->number = entry.index(); } @@ -132,7 +132,7 @@ // found, given that the number of dialects on average is small enough to fit // within a singly byte (128). If we ever have real world use cases that have // a huge number of dialects, this could be made more intelligent. - for (auto &it : llvm::enumerate(dialects)) + for (auto &&it : llvm::enumerate(dialects)) it.value().second->number = it.index(); // Number each of the recorded components within each dialect. @@ -245,7 +245,7 @@ // Number the blocks within this region. size_t blockCount = 0; - for (auto &it : llvm::enumerate(region)) { + for (auto &&it : llvm::enumerate(region)) { blockIDs.try_emplace(&it.value(), it.index()); number(it.value()); ++blockCount; diff --git a/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp b/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp --- a/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp +++ b/mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp @@ -200,7 +200,7 @@ // Indexing (voffset) Value voffset; - for (auto &pair : llvm::enumerate(adaptor.getIndices())) { + for (auto &&pair : llvm::enumerate(adaptor.getIndices())) { size_t i = pair.index(); Value index = pair.value(); Value strideOp; diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -134,7 +134,7 @@ SmallVector args; size_t argOffset = resultStructType ? 1 : 0; - for (auto &[index, argType] : llvm::enumerate(type.getInputs())) { + for (auto [index, argType] : llvm::enumerate(type.getInputs())) { Value arg = wrapperFuncOp.getArgument(index + argOffset); if (auto memrefType = argType.dyn_cast()) { Value loaded = rewriter.create( @@ -222,7 +222,7 @@ // Iterate over the inputs of the original function and pack values into // memref descriptors if the original type is a memref. - for (auto &en : llvm::enumerate(type.getInputs())) { + for (auto &&en : llvm::enumerate(type.getInputs())) { Value arg; int numToDrop = 1; auto memRefType = en.value().dyn_cast(); @@ -677,7 +677,7 @@ getTypeConverter()->packFunctionResults(op.getOperandTypes()); Value packed = rewriter.create(loc, packedType); - for (auto &it : llvm::enumerate(updatedOperands)) { + for (auto &&it : llvm::enumerate(updatedOperands)) { packed = rewriter.create(loc, packed, it.value(), it.index()); } diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp @@ -228,7 +228,7 @@ ? barePtrFuncArgTypeConverter : structFuncArgTypeConverter; // Convert argument types one by one and check for errors. - for (auto &en : llvm::enumerate(funcTy.getInputs())) { + for (auto &&en : llvm::enumerate(funcTy.getInputs())) { Type type = en.value(); SmallVector converted; if (failed(funcArgConverter(*this, type, converted))) diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp --- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp @@ -187,7 +187,7 @@ builder.getType(builder.getAllResults(opPos))); } else { bool foundVariableLength = false; - for (auto &resultIt : llvm::enumerate(types)) { + for (auto &&resultIt : llvm::enumerate(types)) { bool isVariadic = resultIt.value().getType().isa(); foundVariableLength |= isVariadic; diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -126,7 +126,7 @@ llvm::errs() << "\t\t" << iv << "\n"; llvm::errs() << "\tLBs:\n"; - for (auto &en : llvm::enumerate(lbs)) { + for (auto &&en : llvm::enumerate(lbs)) { llvm::errs() << "\t\t" << en.value() << "\n"; llvm::errs() << "\t\tOperands:\n"; for (Value lbOp : lbOperands[en.index()]) @@ -134,7 +134,7 @@ } llvm::errs() << "\tUBs:\n"; - for (auto &en : llvm::enumerate(ubs)) { + for (auto &&en : llvm::enumerate(ubs)) { llvm::errs() << "\t\t" << en.value() << "\n"; llvm::errs() << "\t\tOperands:\n"; for (Value ubOp : ubOperands[en.index()]) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2408,7 +2408,7 @@ // Canonicalize any dynamic indices of constant value to constant indices. bool changed = false; SmallVector gepArgs; - for (auto &iter : llvm::enumerate(indices)) { + for (auto &&iter : llvm::enumerate(indices)) { auto integer = iter.value().dyn_cast_or_null(); // Constant indices can only be int32_t, so if integer does not fit we // are forced to keep it dynamic, despite being a constant. diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -2453,7 +2453,7 @@ SmallVector tiled; SmallVector, 4> loops; loops.resize(getLoops().size()); - for (auto &[i, op] : llvm::enumerate(targets)) { + for (auto [i, op] : llvm::enumerate(targets)) { auto tilingInterface = dyn_cast(op); auto dpsInterface = dyn_cast(op); if (!tilingInterface || !dpsInterface) { @@ -2856,7 +2856,7 @@ SmallVector tiled; SmallVector, 4> loops; loops.resize(getLoops().size()); - for (auto &en : llvm::enumerate(targets)) { + for (auto &&en : llvm::enumerate(targets)) { auto tilingInterfaceOp = dyn_cast(en.value()); if (!tilingInterfaceOp) { DiagnosedSilenceableFailure diag = diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @@ -1394,7 +1394,7 @@ // i1 = (i_{folded} / d2) % d1 // i0 = i_{folded} / (d1 * d2) llvm::DenseMap indexReplacementVals; - for (auto &foldedDims : + for (auto &&foldedDims : enumerate(collapsingInfo.getCollapsedOpToOrigOpMapping())) { ReassociationIndicesRef foldedDimsRef(foldedDims.value()); Value newIndexVal = diff --git a/mlir/lib/Dialect/Linalg/Transforms/SplitReduction.cpp b/mlir/lib/Dialect/Linalg/Transforms/SplitReduction.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/SplitReduction.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/SplitReduction.cpp @@ -156,7 +156,7 @@ newMaps.push_back(AffineMap::get(oldOutputMap.getNumDims() + 1, 0, outputExpr, op.getContext())); SmallVector newIteratorTypes; - for (auto &it : llvm::enumerate(op.getIteratorTypesArray())) { + for (auto &&it : llvm::enumerate(op.getIteratorTypesArray())) { if (insertSplitDimension == it.index()) newIteratorTypes.push_back(utils::IteratorType::parallel); newIteratorTypes.push_back(it.value()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -89,7 +89,7 @@ RewriterBase &b, LinalgOp op, SmallVectorImpl &ivs, const LoopIndexToRangeIndexMap &loopIndexToRangeIndex) { SmallVector allIvs(op.getNumLoops(), nullptr); - for (auto &en : enumerate(allIvs)) { + for (auto &&en : enumerate(allIvs)) { auto rangeIndex = loopIndexToRangeIndex.find(en.index()); if (rangeIndex == loopIndexToRangeIndex.end()) continue; diff --git a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp @@ -314,7 +314,7 @@ AffineMap oldOutputMap = linalgOp.getMatchingIndexingMap(linalgOp.getDpsInitOperand(0)); SmallVector outputExpr; - for (auto &[idx, expr] : llvm::enumerate(oldOutputMap.getResults())) { + for (auto [idx, expr] : llvm::enumerate(oldOutputMap.getResults())) { if (static_cast(idx) == insertSplitDimension) { outputExpr.push_back(b.getAffineDimExpr(reductionDims[0])); } diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -1871,7 +1871,7 @@ << srcType << " and result memref type " << resultType; // Match sizes in result memref type and in static_sizes attribute. - for (auto &en : + for (auto &&en : llvm::enumerate(llvm::zip(resultType.getShape(), getStaticSizes()))) { int64_t resultSize = std::get<0>(en.value()); int64_t expectedSize = std::get<1>(en.value()); @@ -1900,7 +1900,7 @@ << resultOffset << " instead of " << expectedOffset; // Match strides in result memref type and in static_strides attribute. - for (auto &en : + for (auto &&en : llvm::enumerate(llvm::zip(resultStrides, getStaticStrides()))) { int64_t resultStride = std::get<0>(en.value()); int64_t expectedStride = std::get<1>(en.value()); diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -3673,7 +3673,7 @@ if (failed(verifyRegion(getDefaultRegion(), "default region"))) return failure(); - for (auto &[idx, caseRegion] : llvm::enumerate(getCaseRegions())) + for (auto [idx, caseRegion] : llvm::enumerate(getCaseRegions())) if (failed(verifyRegion(caseRegion, "case region #" + Twine(idx)))) return failure(); diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp --- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp @@ -423,7 +423,7 @@ return b.notifyMatchFailure( op, "only support ops with one reduction dimension."); int reductionDim; - for (auto &[idx, iteratorType] : + for (auto [idx, iteratorType] : llvm::enumerate(tilingInterfaceOp.getLoopIteratorTypes())) { if (iteratorType == utils::IteratorType::reduction) { reductionDim = idx; diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp @@ -1333,7 +1333,7 @@ {reader, dimSizes}, EmitCInterface::On) .getResult(0); ArrayRef dstShape = dstTp.getRankedTensorType().getShape(); - for (auto &d : llvm::enumerate(dstShape)) { + for (auto &&d : llvm::enumerate(dstShape)) { if (d.value() == ShapedType::kDynamic) { dynSizes.push_back(rewriter.create( loc, dimSizes, constantIndex(rewriter, loc, d.index()))); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -377,7 +377,7 @@ ArrayRef dstShape = dstTp.getShape(); genReshapeDstShape(loc, rewriter, dstSizes, srcSizes, dstShape, op.getReassociationIndices()); - for (auto &d : llvm::enumerate(dstShape)) { + for (auto &&d : llvm::enumerate(dstShape)) { if (d.value() == ShapedType::kDynamic) dstDynSizes.push_back(dstSizes[d.index()]); } diff --git a/mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp @@ -91,7 +91,7 @@ .cast() .getPosition(); int64_t linearizedStaticDim = 1; - for (auto &d : + for (auto &&d : llvm::enumerate(dstStaticShape.slice(startPos, endPos - startPos + 1))) { if (d.index() + startPos == static_cast(dimIndex)) continue; diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -2779,7 +2779,7 @@ // zero-offset and zero-padding tensor::ExtractSliceOp, tensor::PadOp pair // exists. SmallVector newOffsets(rank, rewriter.getIndexAttr(0)); - for (auto &en : enumerate(newOffsets)) { + for (auto &&en : enumerate(newOffsets)) { OpFoldResult innerOffset = innerSliceOp.getMixedOffsets()[en.index()]; OpFoldResult outerOffset = outerSliceOp.getMixedOffsets()[en.index()]; if (!innerDims.test(en.index()) && @@ -2802,7 +2802,7 @@ // tensor::ExtractSliceOp does not match the size of the padded dimension. // Otherwise, take the size of the inner tensor::ExtractSliceOp. SmallVector newSizes = innerSliceOp.getMixedSizes(); - for (auto &en : enumerate(newSizes)) { + for (auto &&en : enumerate(newSizes)) { if (!outerDims.test(en.index())) continue; OpFoldResult sliceSize = innerSliceOp.getMixedSizes()[en.index()]; @@ -2819,7 +2819,7 @@ // Combine the high paddings of the two tensor::PadOps. SmallVector newHighPad(rank, rewriter.getIndexAttr(0)); - for (auto &en : enumerate(newHighPad)) { + for (auto &&en : enumerate(newHighPad)) { if (innerDims.test(en.index())) newHighPad[en.index()] = padOp.getMixedHighPad()[en.index()]; if (outerDims.test(en.index())) diff --git a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp @@ -762,7 +762,7 @@ return isConstantIntValue(ofr, 0); }); bool sizesMatchDestSizes = llvm::all_of( - llvm::enumerate(insertSliceOp.getMixedSizes()), [&](auto &it) { + llvm::enumerate(insertSliceOp.getMixedSizes()), [&](auto &&it) { return getConstantIntValue(it.value()) == destType.getDimSize(it.index()); }); diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaFoldConstantTranspose.cpp @@ -55,11 +55,11 @@ // Transpose the input constant. Because we don't know its rank in advance, // we need to loop over the range [0, element count) and delinearize the // index. - auto attrValues = inputValues.getValues(); + auto attrValuesIt = inputValues.value_begin(); ArrayRef outputShape = outputType.getShape(); - for (const auto &it : llvm::enumerate(attrValues)) { + for (int64_t totalCount = 0, e = inputValues.size(); totalCount != e; + ++totalCount) { SmallVector srcIndices(inputType.getRank(), 0); - int totalCount = it.index(); for (int dim = inputType.getRank() - 1; dim >= 0; --dim) { srcIndices[dim] = totalCount % inputShape[dim]; totalCount /= inputShape[dim]; @@ -73,7 +73,7 @@ for (int dim = 1; dim < outputType.getRank(); ++dim) dstLinearIndex = dstLinearIndex * outputShape[dim] + dstIndices[dim]; - outputValues[dstLinearIndex] = it.value(); + outputValues[dstLinearIndex] = *(attrValuesIt + totalCount); } rewriter.replaceOpWithNewOp( diff --git a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp --- a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp @@ -964,7 +964,7 @@ continue; assert(transformOp->getNumResults() == partialResults.size() && "expected as many partial results as op as results"); - for (auto &[i, value] : llvm::enumerate(partialResults)) + for (auto [i, value] : llvm::enumerate(partialResults)) transposed[i].push_back(value); } diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp @@ -205,7 +205,7 @@ indices.push_back(yieldValues.size() - 1); } else { // If the value already exit the region don't create a new output. - for (auto &yieldOperand : llvm::enumerate(yieldValues.getArrayRef())) { + for (auto &&yieldOperand : llvm::enumerate(yieldValues.getArrayRef())) { if (yieldOperand.value() == std::get<0>(newRet)) { indices.push_back(yieldOperand.index()); break; diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp @@ -628,7 +628,7 @@ SmallVector permutedOffsets(elementOffsets.size()); SmallVector permutedShape(elementOffsets.size()); // Compute the source offsets and shape. - for (auto &indices : llvm::enumerate(permutation)) { + for (auto &&indices : llvm::enumerate(permutation)) { permutedOffsets[indices.value()] = elementOffsets[indices.index()]; permutedShape[indices.value()] = (*targetShape)[indices.index()]; } diff --git a/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp b/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp --- a/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp +++ b/mlir/lib/Dialect/X86Vector/Transforms/AVXTranspose.cpp @@ -257,7 +257,7 @@ return rewriter.notifyMatchFailure(op, "Unsupported vector element type"); SmallVector srcGtOneDims; - for (auto &en : llvm::enumerate(srcType.getShape())) + for (auto &&en : llvm::enumerate(srcType.getShape())) if (en.value() > 1) srcGtOneDims.push_back(en.index()); diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -196,7 +196,7 @@ llvm::Value *argList = interfaceFunc->arg_begin(); SmallVector args; args.reserve(llvm::size(func.args())); - for (auto &indexedArg : llvm::enumerate(func.args())) { + for (auto &&indexedArg : llvm::enumerate(func.args())) { llvm::Value *argIndex = llvm::Constant::getIntegerValue( builder.getInt64Ty(), APInt(64, indexedArg.index())); llvm::Value *argPtrPtr = diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -3274,7 +3274,7 @@ // One value might be used as the operand of an operation more than once. // Only print the operations results once in that case. SmallPtrSet userSet; - for (auto &indexedUser : enumerate(value.getUsers())) { + for (auto &&indexedUser : enumerate(value.getUsers())) { if (userSet.insert(indexedUser.value()).second) printUserIDs(indexedUser.value(), indexedUser.index()); } diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -73,7 +73,7 @@ for (Pass::Statistic *it : pass->getStatistics()) passEntry.push_back({it->getName(), it->getDesc(), it->getValue()}); } else { - for (auto &it : llvm::enumerate(pass->getStatistics())) + for (auto &&it : llvm::enumerate(pass->getStatistics())) passEntry[it.index()].value += it.value()->getValue(); } #endif diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -408,7 +408,7 @@ // For all results whose types are buildable, initialize their type inference // nodes with an edge to themselves. Mark those nodes are fully-inferred. - for (auto &[idx, infer] : llvm::enumerate(inference)) { + for (auto &&[idx, infer] : llvm::enumerate(inference)) { if (getResult(idx).constraint.getBuilderCall()) { infer.sources.emplace_back(InferredResultType::mapResultIndex(idx), "$_self"); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -520,7 +520,7 @@ auto phis = llvmBB->phis(); auto numArguments = bb.getNumArguments(); assert(numArguments == std::distance(phis.begin(), phis.end())); - for (auto &numberedPhiNode : llvm::enumerate(phis)) { + for (auto &&numberedPhiNode : llvm::enumerate(phis)) { auto &phiNode = numberedPhiNode.value(); unsigned index = numberedPhiNode.index(); for (auto *pred : bb.getPredecessors()) { diff --git a/mlir/lib/Transforms/TopologicalSort.cpp b/mlir/lib/Transforms/TopologicalSort.cpp --- a/mlir/lib/Transforms/TopologicalSort.cpp +++ b/mlir/lib/Transforms/TopologicalSort.cpp @@ -24,7 +24,7 @@ void runOnOperation() override { // Topologically sort the regions of the operation without SSA dominance. getOperation()->walk([](RegionKindInterface op) { - for (auto &it : llvm::enumerate(op->getRegions())) { + for (auto &&it : llvm::enumerate(op->getRegions())) { if (op.hasSSADominance(it.index())) continue; for (Block &block : it.value()) diff --git a/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp b/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp --- a/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp +++ b/mlir/lib/Transforms/Utils/ControlFlowSinkUtils.cpp @@ -136,7 +136,7 @@ SmallVectorImpl ®ions) { // Collect constant operands. SmallVector operands(branch->getNumOperands(), Attribute()); - for (auto &it : llvm::enumerate(branch->getOperands())) + for (auto &&it : llvm::enumerate(branch->getOperands())) (void)matchPattern(it.value(), m_Constant(&operands[it.index()])); // Get the invocation bounds. diff --git a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp --- a/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp +++ b/mlir/test/lib/Analysis/DataFlow/TestDenseDataFlowAnalysis.cpp @@ -254,7 +254,7 @@ const LastModification *lastMods = solver.lookupState(op); assert(lastMods && "expected a dense lattice"); - for (auto &it : llvm::enumerate(op->getOperands())) { + for (auto &&it : llvm::enumerate(op->getOperands())) { os << " operand #" << it.index() << "\n"; Value value = getMostUnderlyingValue(it.value(), [&](Value value) { return solver.lookupState(value); 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 @@ -869,7 +869,7 @@ if (arg.kind != LinalgOperandDefKind::IndexAttr) continue; assert(arg.indexAttrMap); - for (auto &en : + for (auto &&en : llvm::enumerate(arg.indexAttrMap->affineMap().getResults())) { if (auto symbol = en.value().dyn_cast()) { std::string argName = arg.name; 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 @@ -951,7 +951,7 @@ LogicalResult DefFormatParser::verify(SMLoc loc, ArrayRef elements) { // Check that all parameters are referenced in the format. - for (auto &it : llvm::enumerate(def.getParameters())) { + for (auto &&it : llvm::enumerate(def.getParameters())) { if (it.value().isOptional()) continue; if (!seenParams.test(it.index())) { diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -123,7 +123,7 @@ // case value to determine when to print in the string form. if (nonKeywordCases.any()) { os << " switch (value) {\n"; - for (auto &it : llvm::enumerate(cases)) { + for (auto &&it : llvm::enumerate(cases)) { if (nonKeywordCases.test(it.index())) continue; StringRef symbol = it.value().getSymbol(); 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 @@ -934,7 +934,7 @@ // Generate the AttrName methods, that expose the attribute names to // users. const char *attrNameMethodBody = " return getAttributeNameForIndex({0});"; - for (auto &attrIt : llvm::enumerate(llvm::make_first_range(attributes))) { + for (auto &&attrIt : llvm::enumerate(llvm::make_first_range(attributes))) { std::string name = op.getGetterName(attrIt.value()); std::string methodName = name + "AttrName"; @@ -2801,7 +2801,7 @@ body << " {\n unsigned index = 0; (void)index;\n"; - for (auto &it : llvm::enumerate(successors)) { + for (auto &&it : llvm::enumerate(successors)) { const auto &successor = it.value(); if (canSkip(successor)) continue; diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -1827,7 +1827,7 @@ // Get a string containing all of the cases that can't be represented with a // keyword. BitVector nonKeywordCases(cases.size()); - for (auto &it : llvm::enumerate(cases)) { + for (auto &&it : llvm::enumerate(cases)) { if (!canFormatStringAsKeyword(it.value().getStr())) nonKeywordCases.set(it.index()); } @@ -1836,7 +1836,7 @@ // overlap with other cases. For simplicity sake, only allow cases with a // single bit value. if (enumAttr.isBitEnum()) { - for (auto &it : llvm::enumerate(cases)) { + for (auto &&it : llvm::enumerate(cases)) { int64_t value = it.value().getValue(); if (value < 0 || !llvm::isPowerOf2_64(value)) nonKeywordCases.set(it.index()); @@ -1849,7 +1849,7 @@ body << " switch (caseValue) {\n"; StringRef cppNamespace = enumAttr.getCppNamespace(); StringRef enumName = enumAttr.getEnumClassName(); - for (auto &it : llvm::enumerate(cases)) { + for (auto &&it : llvm::enumerate(cases)) { if (nonKeywordCases.test(it.index())) continue; StringRef symbol = it.value().getSymbol();