Commit Graph

2588 Commits

Author SHA1 Message Date
Duo Wang
72e0ac2819 [tests] fix missing codesign in test files 2022-07-28 13:59:44 -07:00
Michael Gottesman
7a43d246b0 Merge pull request #60047 from gottesmm/plus_zero_fix_noimplicitcopy
[no-implicit-copy] Use default param convention instead of forcing +1
2022-07-20 02:36:52 -07:00
Michael Gottesman
f1182a73da [no-implicit-copy] Remove auto +1 param signature change called by noimplicit copy in favor of following normal convention.
I also added a bunch of tests for both the trivial/non-trivial case as well as
some docs to SIL.rst.
2022-07-19 16:39:03 -07:00
John McCall
e60095e36a Remove an unnecessary assertion.
I did check that the code doesn't actually rely on not seeing a
type parameter.

rdar://96571508
2022-07-13 16:17:27 -04:00
Anthony Latsis
087eba83a2 Merge pull request #59757 from AnthonyLatsis/close-issues-2
Add regression tests to close several issues p. 2
2022-06-29 02:48:54 +03:00
Michael Gottesman
6a24087f90 Merge pull request #59611 from gottesmm/moveonly-rebase
[no-implicit-copy] Update SILGen/move checker to work with new patterns from copyable_to_moveonly and friends.
2022-06-28 13:45:15 -07:00
Anthony Latsis
18910ae8e5 Add regression test to close #43022 2022-06-28 22:36:01 +03:00
Anthony Latsis
15acfa9a5b Merge pull request #59535 from AnthonyLatsis/close-issues-1
Add regression tests to close some issues
2022-06-23 20:43:51 +03:00
Anthony Latsis
2e75a14e62 Add regression test to close #43070 2022-06-23 18:25:42 +03:00
Michael Gottesman
3088fe1a01 [move-only] Add support in SILGen for unwrapping moveonlywrapped values before materializing for a function argument.
I discovered this as I began to write some Interpreter tests for move only. This
was triggered by SILGen attempting to pass a non-trivial type to StringBuilder
which is generic, so we needed to materialize.

I also discovered a small bug where we were not properly ignoring class_method
in the move only type eliminator. I just folded the small fix + a test for that
into this commit.
2022-06-22 15:31:57 -07:00
Robert Widmann
9e4670a605 Implement Casting For Extended Existentials
Implement casting to and from extended existentials. This is done by slightly generalizing the conditional conformances checking infrastructure.

Unfortunately, casts for reference types and metatypes are unsound because IRGen is peepholing all non-opaque existential conversions with a helper. I’ll disable that in a follow-up.

rdar://92197049
2022-06-15 21:35:15 -06:00
Alastair Houghton
0cf687aa2b [Build][Runtime] Replace SWIFT_STDLIB_SINGLE_THREADED_RUNTIME.
SWIFT_STDLIB_SINGLE_THREADED_RUNTIME is too much of a blunt instrument here.
It covers both the Concurrency runtime and the rest of the runtime, but we'd
like to be able to have e.g. a single-threaded Concurrency runtime while
the rest of the runtime is still thread safe (for instance).

So: rename it to SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY and make it just
control the Concurrency runtime, then add a SWIFT_STDLIB_THREADING_PACKAGE
setting at the CMake/build-script level, which defines
SWIFT_STDLIB_THREADING_xxx where xxx depends on the chosen threading package.

This is especially useful on systems where there may be a choice of threading
package that you could use.

rdar://90776105
2022-06-07 07:39:51 +01:00
Pavel Yaskevich
5f0dcb572b [ConstraintSystem] Implicitly open existential type of for-in sequence
This allows to use `for-in` statement to iterate over i.e. `any Collection`
and other existentials that conform to `Sequence` protocol.
2022-05-30 23:17:41 -07:00
Ben Barham
efc9469444 Merge pull request #58975 from bnbarham/make-features-consistent
[Tests] Make OS features consistent
2022-05-25 16:02:43 -07:00
Robert Widmann
663722d892 Parameterized Existential Types Are Enabled By Default
See https://forums.swift.org/t/accepted-se-0353-constrained-existential-types/57560
2022-05-25 09:50:36 -07:00
Ben Barham
c163e0fe5e [Tests] Make OS features consistent
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.

Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
2022-05-20 19:51:23 -07:00
Slava Pestov
ac74b845e5 Merge pull request #58513 from AnthonyLatsis/se-309-sil-opt
SE-0309: SILOptimizer fixes & reenable executable tests
2022-05-20 16:38:05 -07:00
Slava Pestov
dac8d666ee Stop passing -requirement-machine-{abstract,inferred,protocol}-signatures flags in tests
These flags are now no-ops.
2022-05-10 12:56:17 -04:00
Robert Widmann
857c5786f6 Merge pull request #58655 from CodaFi/proto-molecule
Diagnose Availability for Parameterized Existential Types
2022-05-05 10:05:28 -07:00
Dario Rexin
4a8f9a5ca6 [Test] Add executable_test requirement to closure_zero_size_allocation.swift (#58674)
rdar://92744237
2022-05-04 20:21:59 -07:00
Josh Soref
7aefe0162e Spelling test interpreter (#58566)
* spelling: bridgeable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constrained

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exist

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overridden

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-04 19:23:25 -07:00
Robert Widmann
5bcea4146a Disable Availability Checking in Tests That Use Parameterized Existentials 2022-05-03 23:36:13 -07:00
Dario Rexin
e6d75b126a [IRGen] Return null reference from IRGenFunction::emitUnmanagedAlloc … (#58532)
* [IRGen] Return null reference from IRGenFunction::emitUnmanagedAlloc when layout isKnownEmpty

rdar://92418090

This fixes a runtime crash on x86 caused by allocations of size 0, which are later deallocated with swift_deallocObjectImpl, but are missing the object header.

* Fix test compiler arguments

* Add IRGen test case

* Add assert to FixedBoxTypeInfoBase does not get created with known empty layout
2022-05-03 22:21:47 -07:00
Anthony Latsis
5dc483472c Supplement, relocate and reenable SE-0309 executable tests 2022-05-02 14:20:04 +03:00
Robert Widmann
ddbb38aa0e Merge pull request #58490 from CodaFi/the-shape-of-water
Legacy Runtimes Are Not Supported for Parameterized Protocol Runtime Test
2022-04-28 16:00:03 -07:00
Robert Widmann
d8f31a46cd Mark Parameterized Protocol Test Unsupported in Legacy Runtime Contexts
rdar://92468243
2022-04-28 12:08:43 -07:00
Mike Ash
a0dec1d30a [Test] Disable objc_old_swift.swift on ARM64e.
The bit twiddling done by this test falls afoul of ptrauth on ARM64e. We don't support pre-stable Swift ABI code on ARM64e anyway, so just disable the test there.

rdar://92469961
2022-04-28 12:53:06 -04:00
Artem Chikin
2d2586e692 Merge pull request #58391 from artemcm/XFailInterpreterConvenienveceInitTest
Disable failing convenience_init_peer_delegation.swift test.
2022-04-25 09:44:08 -07:00
Artem Chikin
f6402836e1 Disable failing convenience_init_peer_delegation.swift test. 2022-04-25 09:42:42 -07:00
John McCall
edb6fbfcc1 Enable this execution test now that it seems to be working. 2022-04-21 23:46:47 -04:00
Anthony Latsis
97eb7721e7 Add executable tests for the edge case of unbound reference to optional method on AnyObject 2022-04-22 00:49:16 +03:00
Anthony Latsis
2d43be60f6 Merge pull request #41978 from AnthonyLatsis/dyn-unbound-ref
CSApply: Handle unbound references to methods found via dynamic lookup
2022-04-13 04:58:41 +03:00
John McCall
1b5a79ec90 Add a testcase to verify basic execution for constrained existentials
Disabled for now; there's apparently a bug.
2022-04-12 14:52:47 -04:00
Anthony Latsis
ad0175033b Some executable tests for unbound references through AnyObject 2022-04-12 08:22:02 +03:00
Mike Ash
b00397c7eb [Concurrency] Fix ObjC weak references to actors.
Change actor destruction to call swift_deallocClassInstance instead of swift_deallocObject. When ObjC interop is enabled, swift_deallocClassInstance will check the "pure swift deallocation" bit and call into the ObjC runtime to destruct the instance when needed. This is what clears weak references and associated objects.

rdar://91270492
2022-04-06 15:57:01 -04:00
Anthony Latsis
77b3f24845 Test: Add executable tests for references to @objc optional methods 2022-03-30 19:11:34 +03:00
Dario Rexin
6d55ecd37d Merge pull request #41459 from drexin/wip-dealloc-recur
[SILGen] Optimize generated dealloc for linearly recursive data struc…
2022-03-14 08:12:48 -07:00
Slava Pestov
64fce332e6 Re-enable test/Interpreter/subclass_existentials.swift 2022-03-07 23:24:38 -05:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
Dario Rexin
06aa3349dc Address review feedback 2022-03-03 09:24:46 -08:00
Andrew Trick
4eb7351f4d Disable MandatoryCopyPropagation.
Mandatory copy propagation was primarily a stop-gap until lexcial
lifetimes were implemented. It supposedly made variables lifetimes
more consistent between -O and -Onone builds. Now that lexical
lifetimes are enabled, it is no longer needed for that purpose (and
will never satisfactorily meet that goal anyway).

Mandatory copy propagation may be enabled again later as a -Onone "
optimization. But that requires a more careful audit of the effect on
debug information.

For now, it should be disabled.
2022-02-18 17:29:04 -08:00
Kuba (Brecka) Mracek
e8830fc869 Add an LTO test that uses 'ar' to create a static library (#41242) 2022-02-08 04:52:47 -08:00
Doug Gregor
9609484961 [IRGen] Fix logic for finding witness tables in an opaque result type.
Use the same logic as we do for forming the opaque type result descriptor,
of course.
2022-01-20 12:11:19 -08:00
Doug Gregor
2bf7f36542 Don't build opaque archetypes referencing the outer environment.
When there are same-type constraints involving opaque archetype
parameters and generic parameters of the enclosing environment, a
nested type of an opaque type archetype might in fact refer to
something in the outer environment of the opaque type. Recognize this
case and perform substitutions on such types using the opaque type's
substitutions.
2022-01-19 16:26:28 -08:00
Doug Gregor
588c7608ee Add executable test for named opaque result types 2022-01-19 09:00:34 -08:00
Erik Eckstein
6ee19f0bea Do conservative cross-module-optimization by default
The "regular" CMO is done with the option `-cross-module-optimization`. It's good for performance but can increase code size.
Now, which this change CMO is also done if the option is not given, but in a very conservative way. Only very small functions are serialized and not additional type metadata is kept alive.

rdar://70082202
2022-01-12 12:43:53 +01:00
Arnold Schwaighofer
764408a60d unresolvable_dynamic_metadata_cycles.swift expects output only available on newer
runtimes

The runtime was changed in "Eliminate priority inversions in the metadata
completion runtime".

rdar://86643295
2021-12-17 11:29:01 -08:00
John McCall
749ed09f8c Eliminate priority inversions in the metadata completion runtime.
The current system is based on MetadataCompletionQueueEntry
objects which are allocated and then enqueued on dependencies.
Blocking is achieved using a condition variable associated
with the lock on the appropriate metadata cache.  Condition
variables are inherently susceptible to priority inversions
because the waiting threads have no dynamic knowledge of
which thread will notify the condition.  In the current system,
threads that unblock dependencies synchronously advance their
dependent metadata completions, which means the signaling
thread is unreliable even if we could represent it in condition
variables.  As a result, the current system is wholly unsuited
for eliminating these priority inversions.

An AtomicWaitQueue is an object containing a lock.  The queue
is eagerly allocated, and the lock is held, whenever a thread
is doing work that other threads might wish to block on.  In
the metadata completion system, this means whenever we construct
a metadata cache entry and the metadata isn't already allocated
and transitively complete after said construction.  Blocking
is done by safely acquiring a shared reference to the queue
object (which, in the current implementation, requires briefly
taking a lock that's global to the surrounding metadata cache)
and then acquiring the contained lock.  For typical lock
implementations, this avoids priority inversions by temporarily
propagating the priority of waiting threads to the locking
threads.

Dependencies are unblocked by simply releasing the lock held
in the queue.  The unblocking thread doesn't know exactly what
metadata are blocked on it and doesn't make any effort to
directly advance their completion; instead, the blocking
thread will wake up and then attempt to advance the dependent
metadata completion itself, eliminating a source of priority
overhang that affected the old system.  Successive rounds of
unblocking (e.g. when a metadata makes partial progress but
isn't yet complete) can be achieved by creating a new queue
and unlocking the old one.  We can still record dependencies
and use them to dynamically diagnose metadata cycles.

The new system allocates more eagerly than the old one.
Formerly, metadata completions which were never blocked never
needed to allocate a MetadataCompletionQueueEntry; we were
then unable to actually deallocate those entries once they
were allocated.  The new system will allocate a queue for
most metadata completions, although, on the positive side,
we can reliably deallocate these queues.  Cache entries are
also now slightly smaller because some of the excess storage
for status has been folded into the queue.

The fast path of an actual read of the metadata remains a
simple load-acquire.  Slow paths may require a bit more
locking.  On Darwin, the metadata cache lock can now use
os_unfair_lock instead of pthread_mutex_t (which is a massive
improvement) because it does not need to support associated
condition variables.

The excess locking could be eliminated with some sort of
generational scheme.  Sadly, those are not portable, and I
didn't want to take it on up-front.

rdar://76127798
2021-12-14 22:18:46 -05:00
Slava Pestov
2441e688e4 Pass -requirement-machine-protocol-signatures=on in a few tests where the GSB got it wrong
These fail with -requirement-machine-protocol-signatures=verify because
the GSB produces incorrect output. Enable the requirement machine
unconditionally for these tests, bypassing verification.

A new file test/Generics/same_type_requirements_in_protocol.swift
contains reduced versions of all of the failures, with FileCheck
used to confirm the exact requirement signature output.
2021-12-14 02:17:51 -05:00
Nate Chandler
ea42e2f334 Enabling copy propagation enables lexical lifetimes.
The effect of passing -enable-copy-propagation is both to enable the
CopyPropagation pass to shorten object lifetimes and also to enable
lexical lifetimes to ensure that object lifetimes aren't shortened while
a variable is still in scope and used.

Add a new flag, -enable-lexical-borrow-scopes=true to override
-enable-copy-propagation's effect (setting it to ::ExperimentalLate) on
SILOptions::LexicalLifetimes that sets it to ::Early even in the face of
-enable-copy-propagation.  The old flag -disable-lexical-lifetimes is
renamed to -enable-lexical-borrow-scopes=false but continues to set that
option to ::Off even when -enable-copy-propagation is passed.
2021-12-08 19:13:21 -08:00