[InstCombine] Drop debug loc in TryToSinkInstruction
authorVedant Kumar <vsk@apple.com>
Wed, 24 Jun 2020 18:33:28 +0000 (11:33 -0700)
committerVedant Kumar <vsk@apple.com>
Fri, 26 Jun 2020 20:23:24 +0000 (13:23 -0700)
commit903cf140d0118cf0d3f0f6f8967c6a20d9c5be6b
tree99dc011946d2ec019cd77e262c8c404659c04642
parentff5ccf258e297df29f32d6b5e4fa0a7b95c44f9c
[InstCombine] Drop debug loc in TryToSinkInstruction

Summary:
The advice in HowToUpdateDebugInfo.rst is to "... preserve the debug
location of an instruction if the instruction either remains in its
basic block, or if its basic block is folded into a predecessor that
branches unconditionally".

TryToSinkInstruction doesn't seem to satisfy the criteria as it's
sinking an instruction to some successor block. Preserving the debug loc
can make single-stepping appear to go backwards, or make a breakpoint
hit on that location happen "too late" (since single-stepping from that
breakpoint can cause the function to return unexpectedly).

So, drop the debug location.

Reviewers: aprantl, davide

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82487
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/sink_to_unreachable_dbg.ll [new file with mode: 0644]