Commit eeef50b1 authored by Fangrui Song's avatar Fangrui Song
Browse files

[mlir] Fix -Wrange-loo-analysis warnings

for (const auto &x : llvm::zip(..., ...))

->

for (auto x : llvm::zip(..., ...))

The return type of zip() is a wrapper that wraps a tuple of references.

> warning: loop variable 'p' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<long> &, ArrayRef<long> &>' does not return a reference [-Wrange-loop-analysis]
parent 681b1be7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ LogicalResult createLaunchFromOp(OpTy rootForOp, ArrayRef<Value> numWorkGroups,

  // Replace values that are used within the region of the launchOp but are
  // defined outside. They all are replaced with kernel arguments.
  for (const auto &pair :
  for (auto pair :
       llvm::zip_first(valuesToForward, launchOp.getKernelArguments())) {
    Value from = std::get<0>(pair);
    Value to = std::get<1>(pair);
@@ -467,7 +467,7 @@ void LoopToGpuConverter::createLaunch(OpTy rootForOp, OpTy innermostForOp,
  // Remap the values defined outside the body to use kernel arguments instead.
  // The list of kernel arguments also contains the lower bounds for loops at
  // trailing positions, make sure we don't touch those.
  for (const auto &pair :
  for (auto pair :
       llvm::zip_first(valuesToForward, launchOp.getKernelArguments())) {
    Value from = std::get<0>(pair);
    Value to = std::get<1>(pair);
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static bool areCompatibleShapes(ArrayRef<int64_t> shape1,
  };
  if (shape1.size() != shape2.size())
    return false;
  for (const auto &p : llvm::zip(shape1, shape2))
  for (auto p : llvm::zip(shape1, shape2))
    if (!isCompatible(std::get<0>(p), std::get<1>(p)))
      return false;
  return true;
+1 −1
Original line number Diff line number Diff line
@@ -1349,7 +1349,7 @@ public:
    // Compute slice of vector mask region.
    SmallVector<int64_t, 4> sliceMaskDimSizes;
    assert(sliceOffsets.size() == maskDimSizes.size());
    for (const auto &it : llvm::zip(maskDimSizes, sliceOffsets, sliceSizes)) {
    for (auto it : llvm::zip(maskDimSizes, sliceOffsets, sliceSizes)) {
      int64_t maskDimSize = std::get<0>(it);
      int64_t sliceOffset = std::get<1>(it);
      int64_t sliceSize = std::get<2>(it);
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ LogicalResult mlir::verifyCompatibleShape(ArrayRef<int64_t> shape1,
                                          ArrayRef<int64_t> shape2) {
  if (shape1.size() != shape2.size())
    return failure();
  for (const auto &dims : llvm::zip(shape1, shape2)) {
  for (auto dims : llvm::zip(shape1, shape2)) {
    int64_t dim1 = std::get<0>(dims);
    int64_t dim2 = std::get<1>(dims);
    if (!ShapedType::isDynamic(dim1) && !ShapedType::isDynamic(dim2) &&
+2 −2
Original line number Diff line number Diff line
@@ -3766,7 +3766,7 @@ Operation *OperationParser::parseGenericOperation() {
  }

  // Add the successors, and their operands after the proper operands.
  for (const auto &succ : llvm::zip(successors, successorOperands)) {
  for (auto succ : llvm::zip(successors, successorOperands)) {
    Block *successor = std::get<0>(succ);
    const SmallVector<Value, 4> &operands = std::get<1>(succ);
    result.addSuccessor(successor, operands);
@@ -4176,7 +4176,7 @@ public:

    SmallVector<std::pair<OperationParser::SSAUseInfo, Type>, 2>
        regionArguments;
    for (const auto &pair : llvm::zip(arguments, argTypes)) {
    for (auto pair : llvm::zip(arguments, argTypes)) {
      const OperandType &operand = std::get<0>(pair);
      Type type = std::get<1>(pair);
      OperationParser::SSAUseInfo operandInfo = {operand.name, operand.number,
Loading