swift
368536ce - [SILGen] Remove subtle identity function call.

Commit
2 years ago
[SILGen] Remove subtle identity function call. Back in 33f4f57cc47f5a13a91fec7c4cb30254a53b53b3 of https://github.com/apple/swift/pull/28044 fame, non-`CaptureKind::Constant:` uses of `Entry.val` in `SILGenFunction::emitCaptures` were replaced with a use of the newly added lambda `getAddressValue` applied at `Entry.val`. The replacement of `Entry.value` with `getAddressValue(Entry.value)` in the case of `CaptureKind::Box` had no effect. Back then, the reason was that the condition SGM.Types .getTypeLowering( valueType, TypeExpansionContext::noOpaqueTypeArchetypesSubstitution( expansion.getResilienceExpansion())) .isAddressOnly() && !entryValue->getType().isAddress() 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 because `false` was being passed for the `CaptureKind::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. The same all holds for the `CaptureKind::ImmutableBox` case which only differs from the `CaptureKind::Box` by a couple of lines.
Author
Committer
Parents
Loading