[SimplifyCFG] Keep !dgb metadata of moved instruction, if they match.
authorFlorian Hahn <flo@fhahn.com>
Sat, 9 Jan 2021 17:02:58 +0000 (17:02 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sat, 9 Jan 2021 19:15:16 +0000 (19:15 +0000)
commitd98fc62ae68cd7e96bf6e85b7fbbee969cec9aa7
treeafe17f3697852245aa41821df662d7da49a9c0b1
parent87d4ea2433663b4aabe9c979a4dd47ef6adedc8b
[SimplifyCFG] Keep !dgb metadata of moved instruction, if they match.

Currently SimplifyCFG drops the debug locations of 'bonus' instructions.
Such instructions are moved before the first branch. The reason for the
current behavior is that this could lead to surprising debug stepping,
if the block that's folded is dead.

In case the first branch and the instructions to be folded have the same
debug location, this shouldn't be an issue and we can keep the debug
location.

Reviewed By: vsk

Differential Revision: https://reviews.llvm.org/D93662
llvm/docs/HowToUpdateDebugInfo.rst
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/fold-debug-location.ll