[llvm-reduce] extractGVsFromModule(): don't crash when deleting instr twice
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Jul 2020 22:01:46 +0000 (01:01 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 4 Jul 2020 22:01:46 +0000 (01:01 +0300)
commitf804bd586ee58199db4cfb2da8e9ef067425900b
tree60c4a45d138049a2ed28405ffecca849cc4be36b
parentfbbb6884e108419692a88e28eeeaa92cfbc08122
[llvm-reduce] extractGVsFromModule(): 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 GV's 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-global-vars-in-same-instruction.py [new file with mode: 0644]
llvm/test/Reduce/remove-multiple-use-of-global-vars-in-same-instruction.ll [new file with mode: 0644]
llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp