Fix Block::eraseArguments to properly update the cached positions
authorMehdi Amini <joker.eph@gmail.com>
Sat, 27 Feb 2021 19:04:12 +0000 (19:04 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Sat, 27 Feb 2021 19:04:12 +0000 (19:04 +0000)
This is fixing correctness and ASAN failure post-ee90bb3486948.

mlir/lib/IR/Block.cpp

index 2ae983d..0758d1e 100644 (file)
@@ -200,9 +200,8 @@ void Block::eraseArguments(llvm::BitVector eraseIndices) {
     }
   }
   // Update the cached position for the arguments after the first erased one.
-  int64_t index = 0;
-  for (BlockArgument arg :
-       llvm::drop_begin(arguments, eraseIndices.find_first()))
+  int64_t index = eraseIndices.find_first();
+  for (BlockArgument arg : llvm::drop_begin(arguments, index))
     arg.setArgNumber(index++);
 }