Commit Graph

29 Commits

Author SHA1 Message Date
Allan Shortlidge
e2bb7e8c8b SILOptimizer: Remove switch cases matching unavailable enum elements.
Unavailable enum elements cannot be instantiated at runtime without invoking
UB. Therefore the optimizer can consider a basic block unreachable if its only
predecessor is a block that terminates in a switch instruction matching an
unavailable enum element. Furthermore, removing the switch instruction cases
that refer to unavailable enum elements is _mandatory_ when
`-unavailable-decl-optimization=complete` is specified because otherwise
lowered IR for these instructions could refer to enum tag accessors that will
not be lowered, resulting in a failure during linking.

Resolves rdar://113872720.
2023-08-15 17:13:10 -07:00
Arnold Schwaighofer
50143048ee Initialize the extraInhabitantCount field of single case enums
rdar://49786768
2019-04-25 12:33:05 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Saleem Abdulrasool
d77801abaf test: define and use %target-rpath
Create a new capturing substitution for adding a rpath to a target
library.  This is needed as Windows doesn't really support the concept
of a rpath.  This also makes it possible to remove the parameter from
the command line on windows.
2018-12-12 19:51:08 -08:00
Saleem Abdulrasool
ed1ec54958 test: make %target-library-name work in captures
Thanks to @jrose for the hint about the substitution ordering, the new
substitution now works even inside the capture group.  Replace the
remaining uses to the new macro.
2018-12-12 10:09:58 -08:00
Saleem Abdulrasool
8968fcad5f test: create and use target-library-name 2018-12-12 08:37:59 -08:00
Saleem Abdulrasool
b212229db1 test: add and use prefix substitutions for libraries
The naming convention is different on Windows than on Unix-like
environments.  In order to follow the convention we need to substitute
the prefix and the suffix.  Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`.  This helps linking the test suite
binaries on Windows.
2018-12-11 15:56:06 -08:00
Arnold Schwaighofer
6eca97add6 Codesign test/Interpreter 2018-08-10 06:58:40 -07:00
Arnold Schwaighofer
1772e77064 IRGen: Fix multi-payload enum lowering
When we have a private resilient enum that is resilient because one of
its payloads is resilient but we have disabled resilience in the
context of lowering the enum as a class member (sigh), we must consider
it's payload's layout enum in the minimal domain (ignore the private
visibility) because we don't truly know the layout.

rdar://41308521
2018-06-25 15:03:28 -07:00
Slava Pestov
0e8fe3d382 Executable resilience tests re-build library under a new name now
Building a new dylib with the same name wasn't breaking some internal bots.

Fixes <rdar://problem/34148403>.
2017-10-02 19:11:13 -07:00
Slava Pestov
41d0503164 Fix resilience tests to pass dylibs on command line 2017-09-29 18:26:45 -07:00
Slava Pestov
afe9ad3b27 Fix some resilience tests for device testing
- Pass -install_name @executable_path/libfoo.dylib to the linker
- Pass dylib as an argument to the binary

Fixes <rdar://problem/34148403>.
2017-09-29 00:25:26 -06:00
Slava Pestov
f61c241edd Get resilience tests working on iOS again 2017-09-05 18:29:35 -07:00
Michael Ilseman
4dd3c82b2d Un-break resilience tests on non-mac platforms 2017-09-01 10:21:42 -07:00
Michael Ilseman
a862713999 Disable more failing tests on iOS 2017-08-31 13:10:10 -07:00
Slava Pestov
f8766fa2e3 Fix resilience tests on Linux 2017-08-29 02:13:55 -07:00
Slava Pestov
194b80049c Sema: Lazy property setters should not be transparent
A lazy property setter stores a value to the underlying storage
of the lazy property. The underlying storage is private, and it
is not proper for a public transparent function body to reference
a private member.

In practice, this only failed if the private member had a
non-constant offset, which only occurs with subclasses of @objc
classes, and resilient classes.

For @objc classes we already had a workaround where no accessors
for stored properties are ever transparent. I put this in to fix
this very issue with lazy properties, but now I realize it was
the wrong workaround, because we still had this problem with
resilient classes.

Note that I'm keeping the logic which made @objc accessors
non-transparent in place, because there's a good chance we will
decide that field offset globals should always be private.

Also, to make this issue reproducible in the test, I changed the
resilience execution tests to build the resilient library as a
dylib and link against that instead of just linking .o files
together. This is because .o files can see each other's internal
symbols, so I was not able to reproduce the original failure
this way. I went ahead and updated the other resilient tests to
do this as well. Also, each test now builds in WMO and non-WMO
mode, to exercise different SIL linking behavior. Again, the
WMO variant was needed to reproduce the issue fixed by this
commit, because without WMO we currently discard serialized SIL,
so no cross-module inlining of the lazy property setter was
taking place.
2017-08-29 01:22:11 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Slava Pestov
1a2beb7cda IRGen: Fix extensions of resilient enums
We need to arrange enum type metadata in a way where a client can
fish out generic parameters without knowing if we have a payload
size or not. The payload size is only used inside the module that
defined the enum, and may change if new cases are added.

So put the generic parameters first before the payload size, and
don't crash when an EnumMetadataScanner is used with a resilient
enum.
2016-09-30 18:28:11 -07:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Slava Pestov
49c54870c1 Serialization: Auto-linking recursively walks modules imported from -sil-serialize-all modules 2016-04-01 12:21:36 -07:00
Dmitri Gribenko
196188b9c8 stdlib: add 'to:' label to dump() 2016-02-22 18:16:38 -08:00
Dmitri Gribenko
5c9214329d Annotate tests as executable 2016-02-04 09:42:26 -08:00
Erik Eckstein
adef0368bb tests: add import statements to workaround linker errors in all relevant tests.
This is needed if we compile StdlibUnittest with -sil-serialize-all
So far I added the imports only in files which needed them. But this may change, depending on the optimizer (inlining).
Adding them in all files doesn't harm and avoids confusion if someone makes an unrelated change which would result in such a linker error.
2016-01-21 09:59:50 -08:00
Slava Pestov
54b22f4455 Re-apply "IRGen: Make case numbering consistent for enums with empty payloads"
Now with a small fix.
2015-12-22 00:17:00 -08:00
Slava Pestov
6c2d8839ec Speculatively revert "IRGen: Make case numbering consistent for enums with empty payloads"
I suspect its breaking the build. I must've screwed up my testing.

This reverts commit 86e6b81336.
2015-12-21 14:50:16 -08:00
Slava Pestov
86e6b81336 IRGen: Make case numbering consistent for enums with empty payloads
If an enum case has a payload but the unsubstituted payload type is
zero-sized, we would convert the case into a no-payload case.
This was valid when the only invariant that had to be preserved
is that an enum's layout is the same between all substitutions
of a generic type.

However this is now wrong if the payload type is resiliently-sized,
because other resilience domains may not have knowledge that it is
zero-sized.

The new utility methods will also be used in class layout.
2015-12-21 13:50:24 -08:00
Slava Pestov
304f4f051f IRGen: Fix for fixed-layout enum with resilient payload
If an enum is fixed-layout in our resilience domain but not
universally fixed-layout, other resilience domains will use
runtime functions to project and inject payloads.

These expect to find the payload size in the metadata, so
emit it if the enum is not universally fixed-layout.

Note that we do know the payload size, so it is constant
for us; there's no runtime call required to initialize
the metadata.
2015-12-19 00:47:47 -08:00
Slava Pestov
c31b209c81 Interpreter tests for resilient enums 2015-12-11 08:58:52 -08:00