From 7b06786de239a4ab7d53ee8ca0b2f5a9b15a871a Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 27 Feb 2021 19:04:12 +0000 Subject: [PATCH] Fix Block::eraseArguments to properly update the cached positions This is fixing correctness and ASAN failure post-ee90bb3486948. --- mlir/lib/IR/Block.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 2ae983d9c51d..0758d1ecb647 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -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++); }