Closure specialization for reabstracted closures

As it stands the closure-specialization optimization specializes a callsite against a closure that has undergone reabstractions (via reabstraction thunks) only if the final closure is passed in as a @noescape thick function parameter.

What is the reason for this limitation and what extra complications arise if we don't have it?

I'm confused because the optimization copies over a "root" closure along with all its conversions and reabstractions, while doing the required memory management for the captured arguments and the original/cloned closures.

@Arnold you seem to be the original author for this change. If possible, could you please elaborate the reasoning behind this limitation?

1 Like

@Erik_Eckstein would you happen to have any information about this?