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,13 +191,13 @@ dyn_cast(predecessor->getTerminator())) { SuccessorOperands operands = branch.getSuccessorOperands(it.getSuccessorIndex()); - for (auto &it : llvm::enumerate(argLattices)) { - if (Value operand = operands[it.index()]) { - join(it.value(), *getLatticeElementFor(block, operand)); + for (auto [idx, lattice] : llvm::enumerate(argLattices)) { + if (Value operand = operands[idx]) { + join(lattice, *getLatticeElementFor(block, operand)); } else { // Conservatively consider internally produced arguments as entry // points. - setAllToEntryStates(it.value()); + setAllToEntryStates(lattice); } } } 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,8 +98,8 @@ } // Assign the entry numbers based on the sort order. - for (auto &entry : llvm::enumerate(range)) - entry.value()->number = entry.index(); + for (auto [idx, value] : llvm::enumerate(range)) + value->number = idx; } IRNumberingState::IRNumberingState(Operation *op) { @@ -132,8 +132,8 @@ // 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)) - it.value().second->number = it.index(); + for (auto [idx, dialect] : llvm::enumerate(dialects)) + dialect.second->number = idx; // 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,11 +222,11 @@ // 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 (Type input : type.getInputs()) { Value arg; int numToDrop = 1; - auto memRefType = en.value().dyn_cast(); - auto unrankedMemRefType = en.value().dyn_cast(); + auto memRefType = input.dyn_cast(); + auto unrankedMemRefType = input.dyn_cast(); if (memRefType || unrankedMemRefType) { numToDrop = memRefType ? MemRefDescriptor::getNumUnpackedValues(memRefType) @@ -677,9 +677,8 @@ getTypeConverter()->packFunctionResults(op.getOperandTypes()); Value packed = rewriter.create(loc, packedType); - for (auto &it : llvm::enumerate(updatedOperands)) { - packed = rewriter.create(loc, packed, it.value(), - it.index()); + for (auto [idx, operand] : llvm::enumerate(updatedOperands)) { + packed = rewriter.create(loc, packed, operand, idx); } rewriter.replaceOpWithNewOp(op, TypeRange(), packed, op->getAttrs()); 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,12 +228,11 @@ ? barePtrFuncArgTypeConverter : structFuncArgTypeConverter; // Convert argument types one by one and check for errors. - for (auto &en : llvm::enumerate(funcTy.getInputs())) { - Type type = en.value(); + for (auto [idx, type] : llvm::enumerate(funcTy.getInputs())) { SmallVector converted; if (failed(funcArgConverter(*this, type, converted))) return {}; - result.addInputs(en.index(), converted); + result.addInputs(idx, converted); } // If function does not return anything, create the void result type, 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 @@ -185,20 +185,20 @@ if (types.size() == 1 && types[0].getType().isa()) { getTreePredicates(predList, types.front(), builder, inputs, builder.getType(builder.getAllResults(opPos))); - } else { - bool foundVariableLength = false; - for (auto &resultIt : llvm::enumerate(types)) { - bool isVariadic = resultIt.value().getType().isa(); - foundVariableLength |= isVariadic; + return; + } - auto *resultPos = - foundVariableLength - ? builder.getResultGroup(pos, resultIt.index(), isVariadic) - : builder.getResult(pos, resultIt.index()); - predList.emplace_back(resultPos, builder.getIsNotNull()); - getTreePredicates(predList, resultIt.value(), builder, inputs, - builder.getType(resultPos)); - } + bool foundVariableLength = false; + for (auto [idx, typeValue] : llvm::enumerate(types)) { + bool isVariadic = typeValue.getType().isa(); + foundVariableLength |= isVariadic; + + auto *resultPos = foundVariableLength + ? builder.getResultGroup(pos, idx, isVariadic) + : builder.getResult(pos, idx); + predList.emplace_back(resultPos, builder.getIsNotNull()); + getTreePredicates(predList, typeValue, builder, inputs, + builder.getType(resultPos)); } } 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 @@ -127,7 +127,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()]) @@ -135,7 +135,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 @@ -2438,7 +2438,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 @@ -2462,7 +2462,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) { @@ -2865,7 +2865,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/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,10 +156,11 @@ newMaps.push_back(AffineMap::get(oldOutputMap.getNumDims() + 1, 0, outputExpr, op.getContext())); SmallVector newIteratorTypes; - for (auto &it : llvm::enumerate(op.getIteratorTypesArray())) { - if (insertSplitDimension == it.index()) + for (auto [index, iteratorType] : + llvm::enumerate(op.getIteratorTypesArray())) { + if (insertSplitDimension == index) newIteratorTypes.push_back(utils::IteratorType::parallel); - newIteratorTypes.push_back(it.value()); + newIteratorTypes.push_back(iteratorType); } if (insertSplitDimension == op.getIteratorTypesArray().size()) { newIteratorTypes.push_back(utils::IteratorType::parallel); 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/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 @@ -3663,7 +3663,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/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,9 +377,9 @@ ArrayRef dstShape = dstTp.getShape(); genReshapeDstShape(loc, rewriter, dstSizes, srcSizes, dstShape, op.getReassociationIndices()); - for (auto &d : llvm::enumerate(dstShape)) { - if (d.value() == ShapedType::kDynamic) - dstDynSizes.push_back(dstSizes[d.index()]); + for (auto [idx, shape] : llvm::enumerate(dstShape)) { + if (shape == ShapedType::kDynamic) + dstDynSizes.push_back(dstSizes[idx]); } } 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 @@ -2773,7 +2773,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()) && @@ -2796,7 +2796,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()]; @@ -2813,7 +2813,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/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 @@ -969,7 +969,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,9 +205,10 @@ 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())) { - if (yieldOperand.value() == std::get<0>(newRet)) { - indices.push_back(yieldOperand.index()); + for (auto [idx, yieldOperand] : + llvm::enumerate(yieldValues.getArrayRef())) { + if (yieldOperand == std::get<0>(newRet)) { + indices.push_back(idx); 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,9 +257,9 @@ return rewriter.notifyMatchFailure(op, "Unsupported vector element type"); SmallVector srcGtOneDims; - for (auto &en : llvm::enumerate(srcType.getShape())) - if (en.value() > 1) - srcGtOneDims.push_back(en.index()); + for (auto [index, size] : llvm::enumerate(srcType.getShape())) + if (size > 1) + srcGtOneDims.push_back(index); if (srcGtOneDims.size() != 2) return rewriter.notifyMatchFailure(op, "Unsupported vector type"); 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,17 +196,17 @@ llvm::Value *argList = interfaceFunc->arg_begin(); SmallVector args; args.reserve(llvm::size(func.args())); - for (auto &indexedArg : llvm::enumerate(func.args())) { + for (auto [index, arg] : llvm::enumerate(func.args())) { llvm::Value *argIndex = llvm::Constant::getIntegerValue( - builder.getInt64Ty(), APInt(64, indexedArg.index())); + builder.getInt64Ty(), APInt(64, index)); llvm::Value *argPtrPtr = builder.CreateGEP(builder.getInt8PtrTy(), argList, argIndex); llvm::Value *argPtr = builder.CreateLoad(builder.getInt8PtrTy(), argPtrPtr); - llvm::Type *argTy = indexedArg.value().getType(); + llvm::Type *argTy = arg.getType(); argPtr = builder.CreateBitCast(argPtr, argTy->getPointerTo()); - llvm::Value *arg = builder.CreateLoad(argTy, argPtr); - args.push_back(arg); + llvm::Value *load = builder.CreateLoad(argTy, argPtr); + args.push_back(load); } // Call the implementation function with the extracted arguments. 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,9 +3274,9 @@ // 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())) { - if (userSet.insert(indexedUser.value()).second) - printUserIDs(indexedUser.value(), indexedUser.index()); + for (auto [index, user] : enumerate(value.getUsers())) { + if (userSet.insert(user).second) + printUserIDs(user, 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,8 +73,8 @@ for (Pass::Statistic *it : pass->getStatistics()) passEntry.push_back({it->getName(), it->getDesc(), it->getValue()}); } else { - for (auto &it : llvm::enumerate(pass->getStatistics())) - passEntry[it.index()].value += it.value()->getValue(); + for (auto [idx, statistic] : llvm::enumerate(pass->getStatistics())) + passEntry[idx].value += statistic->getValue(); } #endif return; 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,9 +520,7 @@ auto phis = llvmBB->phis(); auto numArguments = bb.getNumArguments(); assert(numArguments == std::distance(phis.begin(), phis.end())); - for (auto &numberedPhiNode : llvm::enumerate(phis)) { - auto &phiNode = numberedPhiNode.value(); - unsigned index = numberedPhiNode.index(); + for (auto [index, phiNode] : llvm::enumerate(phis)) { for (auto *pred : bb.getPredecessors()) { // Find the LLVM IR block that contains the converted terminator // instruction and use it in the PHI node. Note that this block is not 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,8 +136,8 @@ SmallVectorImpl ®ions) { // Collect constant operands. SmallVector operands(branch->getNumOperands(), Attribute()); - for (auto &it : llvm::enumerate(branch->getOperands())) - (void)matchPattern(it.value(), m_Constant(&operands[it.index()])); + for (auto [idx, operand] : llvm::enumerate(branch->getOperands())) + (void)matchPattern(operand, m_Constant(&operands[idx])); // Get the invocation bounds. SmallVector 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,9 +254,9 @@ const LastModification *lastMods = solver.lookupState(op); assert(lastMods && "expected a dense lattice"); - for (auto &it : llvm::enumerate(op->getOperands())) { - os << " operand #" << it.index() << "\n"; - Value value = getMostUnderlyingValue(it.value(), [&](Value value) { + for (auto [index, operand] : llvm::enumerate(op->getOperands())) { + os << " operand #" << index << "\n"; + Value value = getMostUnderlyingValue(operand, [&](Value value) { return solver.lookupState(value); }); assert(value && "expected an underlying value"); 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,16 +951,16 @@ LogicalResult DefFormatParser::verify(SMLoc loc, ArrayRef elements) { // Check that all parameters are referenced in the format. - for (auto &it : llvm::enumerate(def.getParameters())) { - if (it.value().isOptional()) + for (auto [index, param] : llvm::enumerate(def.getParameters())) { + if (param.isOptional()) continue; - if (!seenParams.test(it.index())) { - if (isa(it.value())) + if (!seenParams.test(index)) { + if (isa(param)) continue; return emitError(loc, "format is missing reference to parameter: " + - it.value().getName()); + param.getName()); } - if (isa(it.value())) { + if (isa(param)) { return emitError(loc, "unexpected self type parameter in assembly format"); } 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,15 +934,16 @@ // 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))) { - std::string name = op.getGetterName(attrIt.value()); + for (auto [index, attr] : + llvm::enumerate(llvm::make_first_range(attributes))) { + std::string name = op.getGetterName(attr); std::string methodName = name + "AttrName"; // Generate the non-static variant. { auto *method = opClass.addInlineMethod("::mlir::StringAttr", methodName); ERROR_IF_PRUNED(method, methodName, op); - method->body() << llvm::formatv(attrNameMethodBody, attrIt.index()); + method->body() << llvm::formatv(attrNameMethodBody, index); } // Generate the static variant. @@ -952,7 +953,7 @@ MethodParameter("::mlir::OperationName", "name")); ERROR_IF_PRUNED(method, methodName, op); method->body() << llvm::formatv(attrNameMethodBody, - "name, " + Twine(attrIt.index())); + "name, " + Twine(index)); } } } @@ -2801,7 +2802,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();