[PATCH] D56788: [DebugInfo][InstCombine] Prefer salvaging dbg.values over sinking them

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 16 08:42:02 PST 2019


jmorse created this revision.
jmorse added reviewers: aprantl, vsk, bjope.
Herald added a subscriber: llvm-commits.

When sinking an instruction InstCombine currently sinks any local dbg.value users -- something that potentially re-orders variables. I've experienced some circumstances where pointer casts (and associated dbg.values) get sunk across multiple blocks to the point where they're used, artificially shortening the location range of the corresponding debuginfo variable.

Instead of sinking everything, attempt to salvage the dbg.value first. This requires exposing a more expressive form of salvageDebugInfo where we can specify which debug users to attempt to salvage -- otherwise many debug users would be needlessly rewritten. If un-successful, the debug users gets sunk as it does now to prevent debug-use-before-def, if successful it stays. While we're here, fix the salvageDebugUsers' salvaging of GEPs to return false if it's unsalvagable.

Testing for this behaviour happens in the updated test -- where we can push through both the sunk addition, and even the load, to keep all dbg.values in their original locations.

(This patch makes minimal differences to a build of clang-3.4, once more due to our old friend placeDbgValues, but is a worthwhile improvement IMHO).


Repository:
  rL LLVM

https://reviews.llvm.org/D56788

Files:
  include/llvm/Transforms/Utils/Local.h
  lib/Transforms/InstCombine/InstructionCombining.cpp
  lib/Transforms/Utils/Local.cpp
  test/Transforms/InstCombine/debuginfo_add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56788.182056.patch
Type: text/x-patch
Size: 5516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190116/4838f487/attachment.bin>


More information about the llvm-commits mailing list