6.0: [NoncopyableWrapperElim] Process undef values. #74335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: Fix an assert-on-valid involving debug info for noncopyable types.
The
debug_value
instructions help map variable names to their values. When a value is consumed, adebug_value undef
is emitted, telling the debugger that the corresponding name no longer maps to a value that's available. SIL verification requires that the type of every mapped to a name by adebug_value
has the same type--includingundef
values.To facilitate checking of
consuming
and related features, normally copyable types are wrapped by a builtin noncopyable generic type (spelled@moveOnly T
). This type only exists during part of the mandatory pass pipeline; theMoveOnlyWrappedTypeEliminator
removes all occurrences.Previously, that pass wasn't updating
debug_value
instructions whose value was anundef
of@moveOnly
wrapped type (e.g.debug_value undef : $@moveOnly X
). This resulted in a verification failure because otherdebug_value
instructions which specified the current value for a name had had their operand's type unwrapped (e.g.debug_value %4 : $X
).Here, this is fixed by visiting replacing uses of undefs whose type is wrapped this way with undefs whose type is obtained by unwrapping. For example, all uses of
undef : $@moveOnly X
are replaced with uses ofundef : $X
.Scope: Affects noncopyable code.
Issue: rdar://129593468
Original PR: #74298
Risk: Low.
Testing: Added and updated tests.
Reviewer: Andrew Trick ( @atrick )