Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
patterns) in argument positions in reabstraction thunks.
Most of the difficulty in this work continues to center around
(1) trying to reuse as much code as possible between the parameter
and result paths and (2) propagating ownership information as
necessary throughout the code. I did my best to assert the preconditions
and postconditions here, but undoubtedly I'm missing cases. Some
simplicity here is still eluding me here.
This patch necessarily changes quite a bit of the code used in
non-variadic paths. I tried to avoid doing things that I knew would
be risky, like optimizing copies. I did fail in a few places: e.g.
we should now generate significantly better code when erasing to
Optional<Any>, just because the code was oddly poorly-factored before.
You can see the effect on the function_conversion test case.
The result-reabstraction code doesn't need to handle cleanups properly
during the planning phase because of course we don't have any values
yet. That is not true of argument reabstraction, so we need to make
sure that the recursive emitters can produce values with cleanups
so that we can collect and forward those cleanups correctly when
emitting the call.
As part of this, I've changed the code so that it should forward
outer addresses to inner address more consistently; it wouldn't
have done this before if we were breaking apart or assembling
a pack. I'm not sure I can directly test this without figuring
out a way to get SILGen to reabstract both sides of a function,
though.
I'm not sure this is really doing borrowed vs owned arguments
correctly, if e.g. we need to rebstract one component of a tuple
that's otherwise borrowed.