This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Treat empty metadata operands the same as undef 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 changes isUndef to take this into account.

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:07 AM
Orlando requested review of this revision.Jan 3 2023, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2023, 9:07 AM
Orlando added inline comments.Jan 4 2023, 12:26 AM
llvm/unittests/IR/DebugInfoTest.cpp
228–229

Oops - I forgot to include a patch that changes this to a cast ^.

This revision is now accepted and ready to land.Jan 4 2023, 8:44 AM
Orlando updated this revision to Diff 516783.Apr 25 2023, 6:36 AM

Rebase (no reviewer action required)

This revision was landed with ongoing or failed builds.Apr 25 2023, 9:18 AM
This revision was automatically updated to reflect the committed changes.