Improve the effectiveness of BDCE's debug info salvaging
authorAdrian Prantl <aprantl@apple.com>
Mon, 27 Sep 2021 17:51:04 +0000 (10:51 -0700)
committerAdrian Prantl <aprantl@apple.com>
Thu, 30 Sep 2021 16:28:49 +0000 (09:28 -0700)
commit9232ca4712cf3f3a99a8cd095165241daf0ddc4e
tree64042bc726e6e595c8e998ee79f02fca52fd16c3
parent981b12fe89f1a8e01445d05e5f6145e420a1c76d
Improve the effectiveness of BDCE's debug info salvaging

This patch improves the effectiveness of BDCE's debug info salvaging
by processing the instructions in reverse order and delaying
dropAllReferences until after debug info salvaging. This allows
salvaging of entire chains of deleted instructions!

Previously we would remove all references from an instruction, which
would make it impossible to use that instruction to salvage a later
instruction in the instruction stream, because its operands were
already removed.

This reapplies the previous patch with a fix for a use-after-free.

Differential Revision: https://reviews.llvm.org/D110568
llvm/lib/Transforms/Scalar/BDCE.cpp
llvm/test/Transforms/Util/salvage-debuginfo.ll