[InstCombine] Avoid redundant or out-of-order debug value sinking
authorStephen Tozer <Stephen.Tozer@Sony.com>
Fri, 26 Feb 2021 13:04:33 +0000 (13:04 +0000)
committerStephen Tozer <Stephen.Tozer@Sony.com>
Fri, 26 Feb 2021 13:04:33 +0000 (13:04 +0000)
commitec7b9b0c18bb9c9669231bdfa71b0aa7a71140c1
tree127b7816e70d2495d46ac2e8f35643aad97cceb1
parent13a5cac2ba919b4d02a296428b58919231e08569
[InstCombine] Avoid redundant or out-of-order debug value sinking

This patch modifies TryToSinkInstruction in the InstCombine pass, to prevent
redundant debug intrinsics from being produced, and also prevent the intrinsics
from being emitted in an incorrect order. It does this by ensuring that when
this pass sinks an instruction and creates clones of the debug intrinsics that
use that instruction, it inserts those debug intrinsics in their original order,
and only inserts the last debug intrinsic for each variable in the Instruction's
block.

Differential revision: https://reviews.llvm.org/D95463
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/debuginfo-sink.ll
llvm/test/Transforms/InstCombine/debuginfo_add.ll