[PATCH] D48837: [DebugInfo] Corrections for salvageDebugInfo

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 09:25:27 PDT 2018


bjope created this revision.
bjope added reviewers: aprantl, vsk.
Herald added a subscriber: JDevlieghere.

When salvaging a dbg.declare/dbg.addr we should not add
DW_OP_stack_value to the DIExpression
(see test/Transforms/InstCombine/salvage-dbg-declare.ll).

Consider this example

  %vla = alloca i32, i64 2
  call void @llvm.dbg.declare(metadata i32* %vla, metadata !1, metadata !DIExpression())

Instcombine will turn it into

  %vla1 = alloca [2 x i32]
  %vla1.sub = getelementptr inbounds [2 x i32], [2 x i32]* %vla, i64 0, i64 0
  call void @llvm.dbg.declare(metadata [2 x i32]* %vla1.sub, metadata !19, metadata !DIExpression())

If the GEP can be eliminated, then the dbg.declare will be salvaged
and we should get

  %vla1 = alloca [2 x i32]
  call void @llvm.dbg.declare(metadata [2 x i32]* %vla1, metadata !19, metadata !DIExpression())

The problem was that salvageDebugInfo did not recognize dbg.declare
as being indirect (%vla1 points to the value, it does not hold the
value), so we incorrectly got

  call void @llvm.dbg.declare(metadata [2 x i32]* %vla1, metadata !19, metadata !DIExpression(DW_OP_stack_value))

I also made sure that llvm::salvageDebugInfo and
DIExpression::prependOpcodes do not add DW_OP_stack_value to
the DIExpression in case no new operands are added to the
DIExpression. That way we avoid to, unneccessarily, turn a
register location expression into an implicit location expression
in some situations (see test11 in test/Transforms/LICM/sinking.ll).


Repository:
  rL LLVM

https://reviews.llvm.org/D48837

Files:
  lib/IR/DebugInfoMetadata.cpp
  lib/Transforms/Utils/Local.cpp
  test/Transforms/InstCombine/salvage-dbg-declare.ll
  test/Transforms/LICM/sinking.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48837.153736.patch
Type: text/x-patch
Size: 5465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/3c1aabb5/attachment.bin>


More information about the llvm-commits mailing list