Files
swift-mirror/lib/SIL/Verifier/MemoryLifetimeVerifier.cpp
Andrew Trick 23ddaafdc8 Fix MemoryLifetimeVerifier to ignore thin functions.
SILGen optimizes creation of closure down a thin function when it has
no captures:

  %1 = thin_to_thick_function %0
  : $@convention(thin) () -> () to $@callee_guaranteed () -> ()

ValueOwnership.cpp has a sketchy optimization that treat the result
like a trivial type, even though it is not:

>  CONSTANT_OWNERSHIP_INST(None, ThinToThickFunction)

commit 8c5737d1d5
Date:   Fri Oct 23 15:12:18 2020 -0700

    [ownership] Change thin_to_thick function to always produce a none value.

This creates a mismatch between the SILType and the SILValue
ownership. This is not a coherent design--we have a similar problem
with enums which is endlessly buggy--but reverting the decision will
be hard. Instead, I'll hack the memory verifier to silence this case.

Fixes rdar://115735132 (Lifetime verifier error with opaque return
type and closure)
2023-12-05 09:16:07 -08:00

36 KiB