CodeGenPrep: remove AssertingVH references before deleting dead instructions.
authorTim Northover <t.p.northover@gmail.com>
Wed, 15 Jul 2020 08:49:49 +0000 (09:49 +0100)
committerTim Northover <t.p.northover@gmail.com>
Wed, 15 Jul 2020 14:19:21 +0000 (15:19 +0100)
commit37b96d51d0cfc82a64598aaae2a567fa77e44de9
tree428e4d090011c5f4087d693ccf02a385173105be
parent313fca6520b43d95abb73e7c78a252a60ee4cf48
CodeGenPrep: remove AssertingVH references before deleting dead instructions.

CodeGenPrepare keeps fairly close track of various instructions it's
seen, particularly GEPs, in maps and vectors. However, sometimes those
instructions become dead and get removed while it's still executing.
This triggers AssertingVH references to them in an asserts build and
could lead to miscompiles in a release build (I've only seen a later
segfault though).

So this patch adds a callback to
RecursivelyDeleteTriviallyDeadInstructions which can make sure the
instruction about to be deleted is removed from CodeGenPrepare's data
structures.
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/CodeGenPrepare/ARM/dead-gep.ll [new file with mode: 0644]