[SR-14519] is __owned not properly working anymore? #56871
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
SILOptimizer
Area → compiler: SIL optimization passes
Environment
Additional Detail from JIRA
md5: acd86da8a7a814c8207858c2e7f2ae19
Issue Description:
In this Swift program
I create a top level "Logger" (which is a CoW struct) and hold onto it.
The top-level then passes that Logger to
foowhich mutates it (should cause a CoW copy) and passes in intoHolder.init(Holder is a class).Given that
foodoesn't use Logger anymore (ie it's dead) andHolder.inittakes the Logger__ownedI would assume that it's just moved intoHolderwithout much ARC traffic. And I'd assumefooto just pass Logger on which should make the mutation inHoldernot trigger a copy.Sadly, this doesn't work:
So we have 3 sites which cause 99,999 allocations each. Only 2 are expected.
The SIL also looks interesting:
it has
so why does
__owned test.Loggerbecome a type of$@convention(thin) (@guaranteed Logger) -> @owned Holder?See that it's
@guaranteedand not@owned?The text was updated successfully, but these errors were encountered: