This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Do not delete debug intrinsics with empty metadata operands
ClosedPublic

Authored by Orlando on Jan 3 2023, 9:06 AM.

Details

Summary

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

Diff Detail

Event Timeline

Orlando created this revision.Jan 3 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2023, 9:06 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Jan 3 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2023, 9:06 AM
StephenTozer accepted this revision.Jan 4 2023, 8:21 AM

Simple enough, LGTM (but since this is part of a more substantial patch stack, leave a little time for others to have a look).

This revision is now accepted and ready to land.Jan 4 2023, 8:21 AM

Thanks for the review. I factored out a part of this into D141140 so it can be committed before this patch (which I agree needs more time to receive others' reviews - I'll open a fresh discourse thread soon).

llvm/lib/IR/Verifier.cpp
6028–6032 ↗(On Diff #485992)

Factored out this part into another patch that comes with a test: D141140

This revision was landed with ongoing or failed builds.Apr 26 2023, 1:58 AM
This revision was automatically updated to reflect the committed changes.