Skip to content

Commit cff6565

Browse files
authored
[mlir][spirv] Fix incorrect argument erasure in deserializer (llvm#134610)
The current implementation iterates and modifies the list of arguments at the same time. Depending on the number of arguments this will trigger an assert: `assert(index < arguments.size())`. This change replaces loop with a range based erasure.
1 parent 0d71d9a commit cff6565

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,8 +2077,7 @@ LogicalResult ControlFlowStructurizer::structurize() {
20772077
// block arguments from the original merge block.
20782078
for (unsigned i = 0, e = outsideUses.size(); i != e; ++i)
20792079
outsideUses[i].replaceAllUsesWith(selectionOp.getResult(i));
2080-
for (unsigned i = 0, e = mergeBlock->getNumArguments(); i != e; ++i)
2081-
mergeBlock->eraseArgument(i);
2080+
mergeBlock->eraseArguments(0, mergeBlock->getNumArguments());
20822081
}
20832082

20842083
// Check that whether some op in the to-be-erased blocks still has uses. Those

0 commit comments

Comments
 (0)