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
Factored out this part into another patch that comes with a test: D141140