diff options
author | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-09-11 06:07:16 +0000 |
---|---|---|
committer | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-09-11 06:07:16 +0000 |
commit | 6b1c6c1287dc1bb4511687d2795d00046a804572 (patch) | |
tree | ee1ccbc2b33b0126219f36ec3e82252b0f2ff99d /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 9ca1b94a6d3f491f26ccbeacf910342e6861fc7f (diff) | |
download | bcm5719-llvm-6b1c6c1287dc1bb4511687d2795d00046a804572.tar.gz bcm5719-llvm-6b1c6c1287dc1bb4511687d2795d00046a804572.zip |
[Debuginfo][Instcombiner] Do not clone dbg.declare.
TryToSinkInstruction() has a bug: While updating debug info for
sunk instruction, it could clone dbg.declare intrinsic.
That is wrong. There could be only one dbg.declare.
The fix is to not clone dbg.declare intrinsic and to update
it`s arguments, to not to point to sunk instruction.
Differential Revision: https://reviews.llvm.org/D67217
llvm-svn: 371587
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 81095bf0a03..41cadb387e5 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3164,6 +3164,21 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { findDbgUsers(DbgUsers, I); for (auto *DII : reverse(DbgUsers)) { if (DII->getParent() == SrcBlock) { + if (isa<DbgDeclareInst>(DII)) { + // A dbg.declare instruction should not be cloned, since there can only be + // one per variable fragment. It should be left in the original place since + // sunk instruction is not an alloca(otherwise we could not be here). + // But we need to update arguments of dbg.declare instruction, so that it + // would not point into sunk instruction. + if (!isa<CastInst>(I)) + continue; // dbg.declare points at something it shouldn't + + DII->setOperand( + 0, MetadataAsValue::get(I->getContext(), + ValueAsMetadata::get(I->getOperand(0)))); + continue; + } + // dbg.value is in the same basic block as the sunk inst, see if we can // salvage it. Clone a new copy of the instruction: on success we need // both salvaged and unsalvaged copies. |