[SR-5314] withExtendedLifetime can be very expensive #47889
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
performance
Attachment: Download
Additional Detail from JIRA
md5: 3eaef6661b84b71d4bf854e8ad0b065d
Issue Description:
The issue
I have this pretty simple demo program
which takes 20s to run if compiled with
-D WITH_WEL
to enable thewithExtendedLifetime
but only 0.5s to run with-D NO_WEL
to disablewithExtendedLifetime
. I really can't understand why.Demo run
beginning of an analysis
Attached, please find a diff of the generated SILs of the two programs, on the left hand side is the one with the
withExtendedLifetime
and on the right the one without.the difference seems to be that in the case where I use
withExtendedLifetime
it does a {{ %5 = partial_apply %4(%2) : $@convention(thin) (@in (), @owned @callee_owned () -> Int32) -> @out Int32 // users: %20, %19}} which doesn't seem to happen without it. I wonder what needs to be partially applied? The only thing I can think of is that it's building a "useless" thunk just so it has something it can retain/release forwithExtendedLifetime
but I hope that's not quite true.the version with
withExtendedLifetime
causes amalloc
and afree
every time it's run, that seems to be for the thunk that's created above.The text was updated successfully, but these errors were encountered: