[llvm-reduce] extractArgumentsFromModule(): don't crash when deleting instr twice
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Jul 2020 21:48:05 +0000 (00:48 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Jul 2020 21:52:42 +0000 (00:52 +0300)
commitfbbb6884e108419692a88e28eeeaa92cfbc08122
treea6412b9b58c986be5c5b6727f9f35ba7afffb645
parent76123d338dc542d25cc9c4f20ddc49df1b9712cd
[llvm-reduce] extractArgumentsFromModule(): don't crash when deleting instr twice

As it can be seen in newly-added (previously-crashing) test-case,
there can be a situation where multiple arguments are used in instr,
and we would schedule the same instruction to be deleted several times,
crashing when trying to delete it the second time.

We could either store WeakVH (done here), or use something set-like.
I think using WeakVH is prevalent in these cases elsewhere.
llvm/test/Reduce/Inputs/remove-multiple-use-of-args-in-same-instruction.py [new file with mode: 0644]
llvm/test/Reduce/remove-multiple-use-of-args-in-same-instruction.ll [new file with mode: 0644]
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp