Commit Graph

3 Commits

Author SHA1 Message Date
Michael Gottesman
b2a52ff036 [move-only] Do not attempt to lazily deserialize the moveonly deinit table in IRGen.
SIL Functions are serialized in canonical SIL before they have their final ABI
adjusted for large function arguments. Large function argument ABI is adjusted
to be indirect as part of the transition from canonical SIL to lowered SIL. This
means that if we deserialize a function from another module in canonical SIL and
attempt to call it in IRGen we will call it with the wrong ABI implying if we
reference any fields of the type in the deinit we will most likely crash (among
other potential issues).

This patch fixes the issue by changing IRGen to not lazily deserialize the
moveonly deinit table and its associated functions. Instead if we do not have
our table already deserialized, we just call the function's deinit via the
destroy value deinit table.

rdar://110496872
2023-06-09 15:41:38 -04:00
Michael Gottesman
a52302d384 Some misc fixes for tests. 2023-05-27 23:29:56 -07:00
Michael Gottesman
8579c1924d [move-only] Make sure that we serialize deinits and if we are not able to see the value witness function, call it via the value witness function.
Some notes:

1. I put in both a swiftpm like test case and a library evolution test case. I
also updated the moveonly_deinit serialization swift test to show that we
actually serialize the deinit.

2. I changed when we emit the deinit table to only be when we have a type with
an actual value type destructor. Notably this doesn't include classes today so
as a side-effect, we no longer attempt to devirtualize moveonly class deinits.
This doesn't affect anything we are trying to actually do since we do not
support noncopyable classes today. With that in mind, I changed one test that
was showing that deinit devirtualization worked to use a struct with deinit
instead of a class.

rdar://109679168
2023-05-27 22:07:04 -07:00