Commit Graph

7628 Commits

Author SHA1 Message Date
Tim Kientzle
9bfe1b1691 Merge branch 'main' into tbkka-RemoteMirror-MPE-zero-sized-plus-generics 2023-04-24 08:22:38 -07:00
Tim Kientzle
ed28d8e4eb Add a test case where the innermost type has no generic parameters 2023-04-22 11:52:31 -07:00
Pavel Yaskevich
b081bdbf57 [CSGen] Allow is pattern types to be holes 2023-04-21 12:14:41 -07:00
Tim Kientzle
16c0729492 Correct and simplify the test from PR #62854
The new logic no longer includes non-generic parent types as part
of the type reference.

This also combines the 32- and 64-bit tests validations, since they
were identical for this test anyway.
2023-04-20 14:31:06 -07:00
Tim Kientzle
02160e68a0 Recursively reconstruct nested generics, skipping non-generic
This is a more correct fix for the issue that inspired PR #62854.
In particular, this does not change the numbering of generic
argument levels, and so does not break generic type parameter
lookups.

Added a new test case to verify that nested types that mix
generics and non-generics in different ways consistently identify
the correct generic argument labels.
2023-04-20 14:31:06 -07:00
nate-chandler
0e8a6060ee Merge pull request #65306 from nate-chandler/rdar81421394
Address asserts raised when conforming pseudogeneric type to protocol with coroutine requirement.
2023-04-20 07:14:36 -07:00
Evan Wilde
37d2d692b3 Merge pull request #65303 from etcwilde/ewilde/disable-tsan-ignores-arc-locs
Unblock package bots: Disable tsan test
2023-04-19 22:45:16 -07:00
Nate Chandler
b9ccde3771 SILFunctionType: Loosened assert.
Allowed SILFunctionType instances for pseudogeneric coroutines without
signatures to be created.  Such instances are created by
SILTypeSubstituter::substSILFunctionType when SILGen'ing a conformance
of a pseudogeneric type to a protocol featuring a coroutine requirement.

rdar://81421394
2023-04-19 17:53:15 -07:00
Evan Wilde
5bad63bf1f Unblock package bots: Disable tsan test 2023-04-19 14:53:21 -07:00
nate-chandler
d20b8d26b8 Merge pull request #65274 from nate-chandler/rdar107275872
[Concurrency] Nest stack traffic in withValue.
2023-04-19 11:52:41 -07:00
Nate Chandler
4fe988b7c2 [Concurrency] Nest stack traffic in withValue.
Because `_taskLocalValuePush` and `_taskLocalValuePop` can result in calls
to `swift_task_alloc` and `swift_task_dealloc` respectively, and because
the compiler hasn't been taught about that (e.g.
`SILInstruction::isAllocatingStack`,
`SILInstruction::isDeallocatingStack`, etc), calling them (push and pop)
from a function which makes use the stack for dynamically sized
allocations can result in violations of stack discipline of the form

```
swift_task_alloc // allocates %ptr_1
copy_value_witness // copies into %ptr_1
swift_task_localValuePush // calls swift_task_alloc and allocates %ptr_2
swift_task_dealloc // deallocates %ptr_1
swift_task_localValuePop // calls swift_task_dealloc and deallocates %ptr_2
```

Avoid the problem by not allocating dynamically sized stack space in the
function which calls `_taskLocalValuePush` and `_taskLocalValuePop`.
Split the calls to those functions into `withValueImpl` function which
takes its argument `__owned`.  Call that function from `withValue`,
ensuring that the necessary copy (to account for the fact that withValue
takes its argument `__guaranteed` but `_taskLocalValuePush` takes its
`__owned`) and associated stack traffic occur in `withValue`.

Still, allow `withValueImpl` to be inlined.  The stack nesting will be
preserved across it.

rdar://107275872
2023-04-18 19:51:34 -07:00
Tim Kientzle
894f116189 Remove a test that is not actually ready; it was just an experiment 2023-04-12 17:24:12 -07:00
Tim Kientzle
a6ff81345a Make some tests work better on varying platforms.
In particular, the exactly internal layout of Array<> is quite
different between macOS and Linux, which makes it impractical
for use in tests like this.  An empty class is still a reference
and doesn't introduce so many complications.
2023-04-12 16:40:44 -07:00
Tim Kientzle
ef0eafc84f Generalize a test to work correctly on Linux aarch64 2023-04-11 17:40:07 -07:00
Pavel Yaskevich
976c0b17c3 [CSSyntaticElement] Canonicalize type before collecting "in scope" variables
Follow-up to https://github.com/apple/swift/pull/65048

`getDesugaredType` unwraps sugar types that appear in sequence,
to remove sugar from nested positions we need to get a canonical type.

Thanks to @slavapestov for pointing it out.
2023-04-11 11:53:31 -07:00
Pavel Yaskevich
6b3a17bad9 Merge pull request #65048 from xedin/rdar-107835060
[CSSyntaticElement] Desugar types before collecting "in scope" type v…
2023-04-11 10:47:38 -07:00
Pavel Yaskevich
ca14ab7157 [CSSyntaticElement] Desugar types before collecting "in scope" type variables
Generic type aliases, unless desugared, could bring unrelated type variables
into the scope i.e. `TypeAlias<$T, $U>.Context` is actually `_Context<$U>`.
These variables could be inferrable only after the the body the closure is
solved. To avoid that, let's adjust `TypeVariableRefFinder` to desugar types
before collecting referenced type variables.

Resolves: rdar://107835060
2023-04-10 15:33:03 -07:00
Tim Kientzle
a76c925b49 Merge remote-tracking branch 'github-apple/main' into tbkka-RemoteMirror-MPE-zero-sized-plus-generics 2023-04-10 12:42:12 -07:00
Dario Rexin
021d524056 [IRGen] Pass component generic sig when emitting key path component f… (#64871)
* [IRGen] Pass component generic sig when emitting key path component for external property

rdar://101179225

When no generic environment was present, we passed nullptr, which is not correct when the property uses an external associated type, causing crashes in IRGen. In those cases, we have to pass the component generic sig instead.

* Fix test
2023-04-07 13:58:47 -07:00
Tim Kientzle
2f27e06591 Generalize tests that already work for 32 bits 2023-04-06 13:27:06 -07:00
Tim Kientzle
3bb9285d45 Accurately distinguish generic and non-generic cases.
A "generic" case is any case whose payload type depends
on generic type parameters for the enum or any enclosing type.
Some examples:

```
struct S<T> {
  enum E {
    case a        // Non-generic case
    case b(Int)   // Non-generic case
    case c(T)     // Generic case
    case d([U])   // Generic case
    case e([Int]) // Non-generic case
  }
}
```

This is important for correctly distinguishing MPE versus
SPE layouts.  A case is considered "empty" only if it
is either a non-payload case (`case a`) or if the payload
is zero-sized and non-generic.  Generic cases are always
treated as non-zero-sized for purposes of determining
the layout strategy.

Correctly testing this is tricky, since some of the
layout strategies differ only in whether they export
extra tag values as XIs.  The easiest way to verify is
to check whether wrapping the result in an `Optional<>`
adds another byte to the overall size.
2023-04-03 17:17:59 -07:00
Tim Kientzle
e573366a53 Fix handling of generic MPEs
This exercises a number of cases that the previous logic got
wrong, including cases where MPEs are laid out like SPEs,
and cases where we use the SPE or MPE layout strategies for enums
that have no non-empty payloads.  (These cases are superficially
similar but differ in how they handle XIs.)

These new tests allowed me to correct a number logical flaws
about how layouts are selected.  In particular, cases with
generic payloads are always considered to be non-empty for
purposes of selecting a layout strategy.  Only cases that
are statically known to be empty are considered empty for
layout purposes.
2023-04-02 21:09:24 -07:00
Rintaro Ishizaki
9dc7ee8222 Merge pull request #64796 from rintaro/test-hosttriple-rdar107398734
[Test] Add %host_triple and %host_sdk substitutions
2023-03-31 10:43:31 -07:00
Rintaro Ishizaki
1d2fd4223f [Test] Add %host_triple and %host_sdkroot substitutions
Macro tests need to build host libraries/tools. We can't use %target-*
substitutions for that.

rdar://107398734
2023-03-31 07:41:41 -07:00
nate-chandler
5e0267b9b7 Merge pull request #64553 from nate-chandler/eagermove_collections
[stdlib] Collection types are eagerMove.
2023-03-30 16:16:26 -07:00
Nate Chandler
b46232857c [Test] Added optimization test case.
rdar://92652273
2023-03-30 11:04:47 -07:00
Alejandro Alonso
aa3fd951d2 Merge pull request #64731 from Azoy/update-unicode-15
[stdlib] Update the stdlib to use Unicode 15 data
2023-03-29 22:49:38 -07:00
Alejandro Alonso
f16f0c3c23 Update the stdlib to use Unicode 15 data 2023-03-29 10:18:16 -07:00
Nate Chandler
1a7c4a4d12 [NFC] Renamed DestroyAddrHoisting.
It was previously named SSADestroyHoisting which is rather misleading
considering that it deals with addresses and hoists destroy_addrs.
2023-03-27 14:15:03 -07:00
Allan Shortlidge
adda1f559d IRGen: Weakly link symbols for unavailable declarations.
When computing linkage, the compiler would treat unavailable declarations as if
they were "always available" when they lack an `introduced:` version:

```
// Library
@available(macOS, unavailable)
public func foo() {
  // …
}

// Client
import Library

@available(macOS, unavailable)
func bar() {
  // Even though foo() and bar() are unavalable on macOS the compiler still
  // strongly links foo().
  foo()
}
```

This created an unnecessary dependency between libraries and their clients and
also can interfere with back deployment, since unavailable declarations may not
be present in a library on all OS versions. Developers could work around these
issues by conditionally compiling the code that references an unavailable
declaration, but they shouldn't have to given that unavailable code is meant to
be provably unreachable at runtime. Additionally, it could improve library code
size if we allowed the compiler to strip unavailable declarations from a binary
completely.

Resolves rdar://106673713
2023-03-23 08:57:15 -07:00
Alex Hoppen
edfd3fde38 Merge pull request #64506 from ahoppen/ahoppen/no-begin-end-completions
[IDE] Remove "Begin completions" and "End completions" from test cases
2023-03-22 17:21:37 -07:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Anthony Latsis
c9b1071456 Merge pull request #64428 from AnthonyLatsis/xcode-gen-opt
build-script: Don't build LLVM testing tools when generating Xcode projects
2023-03-20 20:32:57 +03:00
Guillaume Lessard
d6a02682ad Merge pull request #64393 from glessard/rdar106656555-slowtest
[test] fix compilation performance issues in validation-test/stdlib/UnsafeBufferPointerSlices.swift
2023-03-17 10:22:07 -07:00
Anthony Latsis
e8be44d14e Merge pull request #64324 from AnthonyLatsis/cse-open-exist
SILOptimizer: Fix some issues with CSE of `open_existential_ref`
2023-03-17 17:26:09 +03:00
Allan Shortlidge
ca5acf3255 Merge pull request #64412 from tshortli/relax-unsafe-main-actor-availability-checking
Sema: Relax availability checking for `@MainActor`
2023-03-16 19:38:31 -07:00
Pavel Yaskevich
26c0d0a0c9 Merge pull request #64433 from xedin/remove-old-result-builder-impl
[BuilderTransform] NFC: Remove original result builder implementation
2023-03-16 16:12:53 -07:00
Allan Shortlidge
fb03b4aa04 Sema: Relax availability checking for @MainActor.
The `@MainActor` global actor constraint on a declaration does not carry an
inherent ABI impact and therefore use of this constraint should not be limited
to OS versions where Swift concurrency is available.

Resolves rdar://105610970
2023-03-16 14:23:36 -07:00
Saleem Abdulrasool
f8aaf18093 Merge pull request #64419 from mhjacobson/freebsd-implement-POSIXErrorCode
stdlib: implement POSIXErrorCode for FreeBSD
2023-03-16 11:14:56 -07:00
Anthony Latsis
f94f401a06 build-script: Don't build LLVM testing tools when generating Xcode projects 2023-03-16 20:58:14 +03:00
Matt Jacobson
2febbb4aaf stdlib: implement POSIXErrorCode for FreeBSD
It shares many of the same values as OpenBSD (which both inherited from 4.4BSD),
and we wouldn't expect those to diverge due to the respective platforms'
bincompat goals.
2023-03-16 01:20:56 -04:00
Pavel Yaskevich
36c61bdd3e [Tests] NFC: Remove ResultBuilderASTTransform references from tests 2023-03-15 14:29:04 -07:00
Guillaume Lessard
a441756ff4 [test] re-enable test/stdlib/UnsafeBufferPointerSlices 2023-03-15 10:54:24 -07:00
Guillaume Lessard
c5a59054d6 [test] simplify needlessly complex test expressions 2023-03-15 10:51:19 -07:00
Alejandro Alonso
09b1476ddf Stop building Reflection 2023-03-14 11:49:38 -07:00
Pavel Yaskevich
52f9d845da [Tests] NFC: Adjust REQUIRES declaration for UnsafeBufferPointerSlices validation test 2023-03-14 11:16:16 -07:00
Alejandro Alonso
0fd1fde7c3 Merge pull request #64352 from Azoy/disable-ubps
[Test] Disable UnsafeBufferPointerSlices.swift to unblock CI
2023-03-14 09:48:42 -07:00
Alejandro Alonso
b1107e4a3d Update UnsafeBufferPointerSlices.swift 2023-03-14 09:47:34 -07:00
Allan Shortlidge
4058ad1421 AST: Improved inferred availability accuracy.
Previously, when creating availability attributes for synthesized declarations
we would identify some set of reference declarations that the synthesized
declaration should be as-available-as. The availability attributes of the
reference declarations would then be merged together to create the attributes
for the synthesized declaration. The problem with this approach is that the
reference declarations themselves may implicitly inherit availability from their
enclosing scopes, so the resulting merged attributes could be incomplete. The
fix is to walk though the enclosing scopes of the reference declarations,
merging the availability attributes found at each level.

Additionally, the merging algorithm that produces inferred availability
attributes failed to deal with conflicts between platform specific and platform
agnostic availability. Now the merging algorithm notices when platform agnostic
availability should take precedence and avoids generating conflicting platform
specific attributes.

Resolves rdar://106575142
2023-03-13 18:27:03 -07:00
Anthony Latsis
d650ce47f3 SILOptimizer: Fix some issues with CSE of open_existential_ref
* A direct user might have a dependent result
* An indirect user can also be a terminator instruction
2023-03-13 21:41:02 +03:00