[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 in 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
foo
which mutates it (should cause a CoW copy) and passes in intoHolder.init
(Holder is a class).Given that
foo
doesn't use Logger anymore (ie it's dead) andHolder.init
takes the Logger__owned
I would assume that it's just moved intoHolder
without much ARC traffic. And I'd assumefoo
to just pass Logger on which should make the mutation inHolder
not 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.Logger
become a type of$@convention(thin) (@guaranteed Logger) -> @owned Holder
?See that it's
@guaranteed
and not@owned
?The text was updated successfully, but these errors were encountered: