[PATCH] D140901: [DebugInfo] Do not delete debug intrinsics with empty metadata operands

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 09:06:05 PST 2023


Orlando created this revision.
Orlando added reviewers: StephenTozer, jmorse, djtodoro, jryans, scott.linder.
Orlando added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A `ValueAsMetadata` may be replaced with nullptr for several reasons including deleting (certain) values and value remapping a use-before-def. In the case of a
`MetadataAsValue` user, `handleChangedOperand` intercepts and replaces the metadata with an empty tuple (`!{}`).

At the moment, an empty metadata operand in a debug intrinsics signals that it can be deleted.

Given that we end up with empty metadata operands in circumstances where the Value has been "lost" the current behaviour can lead to incorrect variable locations. Instead, we should treat empty metadata as meaning "there is no location for the variable" (the same as we currently treat undef operands).

This patch removes the deletion logic from `wouldInstructionBeTriviallyDead`.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value


https://reviews.llvm.org/D140901

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/DebugInfo/Generic/empty-metadata.ll
  llvm/unittests/Transforms/Utils/LocalTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140901.485992.patch
Type: text/x-patch
Size: 5887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230103/29389247/attachment.bin>


More information about the llvm-commits mailing list