[SILGen] Remove subtle identity function call. #67846
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.
Back in 33f4f57 of #28044 fame, non-
CaptureKind::Constant:
uses ofEntry.val
inSILGenFunction::emitCaptures
were replaced with a use of the newly added lambdagetAddressValue
applied atEntry.val
.The replacement of
Entry.value
withgetAddressValue(Entry.value)
in the case ofCaptureKind::Box
had no effect.Back then, the reason was that the condition
under which something other than the input was returned would never hold:
CaptureKind::Box
is used for LValues and those never satisfy!entryValue->getType().isAddress()
.Since that PR, the
getAddressValue
lambda has grown. There are two additional aspects to consider: (1)forceCopy
, (2)isPack
. (1) is not relevant becausefalse
was being passed for theCaptureKind::Box
case. (2) can not currently happen because pack lvalues haven't been implemented. But even if they were implemented, the argument passed to the lambda would still need to be an address, and it still wouldn't be desired to convert that address (a project_box) into an on-stack temporary (what theisPack
branch ofgetAddressValue
presently does).The same all holds for the
CaptureKind::ImmutableBox
case which only differs from theCaptureKind::Box
by a couple of lines.