Commit Graph

6960 Commits

Author SHA1 Message Date
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
eeckstein
d154dfda60 Merge pull request #64204 from eeckstein/fix-dce
SILOptimizer: fix a stack overflow in DCE
2023-03-08 17:50:07 +01:00
Erik Eckstein
ca14a08f09 tests: disable many_trys.swift for iOS
For some reason this test times out sometimes when bulding for iOS

rdar://106375480
2023-03-08 12:55:43 +01:00
Erik Eckstein
b741aa0018 SILOptimizer: fix a stack overflow in DCE
For very large control flow graphs the markControllingTerminatorsLive can stack overflow.
Fix this by doing the work iteratively instead of recursively.

rdar://106198943
2023-03-08 12:20:45 +01:00
Mishal Shah
e256b56545 Merge branch 'main' into rebranch 2023-03-02 18:25:09 -08:00
swift-ci
8dac45ed0d Merge pull request #63725 from phausler/pr/observation
Observation and associated macros
2023-03-02 18:02:14 -08:00
Andrew Trick
f1ff6958a3 Merge pull request #63825 from atrick/diagnose-implicit-raw-bitwise
Warn on implicit pointer conversion from nontrivial inout values.
2023-03-02 10:57:30 -08:00
Ben Barham
59afba5bf9 Manually merge branch 'main' into rebranch 2023-03-01 14:13:50 -08:00
Pavel Yaskevich
08e62a35ed Merge pull request #63947 from xedin/rdar-105149979
[ConstraintSystem] Dependent member simplification should be attempte…
2023-02-28 09:12:51 -08:00
swift-ci
622d0b2aa2 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-28 07:14:26 -08:00
Alex Hoppen
0ed6deea9b Merge pull request #63712 from ahoppen/ahoppen/completion-misc
[CodeCompletion] Collection of minor changes to prepare migrating remaining completion kinds to solver-based
2023-02-28 16:02:58 +01:00
Andrew Trick
a354f26d55 Fix unit tests that relied on nontrivial to raw conversion. 2023-02-27 21:51:17 -08:00
Philippe Hausler
8a7f6009b9 Initial draft of observation 2023-02-27 17:09:00 -08:00
Pavel Yaskevich
e450047c6b [ConstraintSystem] Dependent member simplification should be attempted if it has type variable in any position
Current logic attempts simplification of the base type only if it's
a type variable or a dependent member type. That's valid for correct
code but not for invalid code e.g. `(($T) -> Void).Element` is not
going to be simplified even if `$T` is bound, which causes crashes
in diagnostic mode because `matchTypes` is going to re-introduce
constraint with partially resolved dependent member types and by
doing so make it stale forever which trips constraint system state
verification logic.

Resolves: rdar://105149979
2023-02-27 12:41:42 -08:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Erik Eckstein
2d88482c9f EscapeUtils: add a computational limit to avoid quadratic complexity in some corner cases.
The `isEscaping` function is called a lot from ARCSequenceOpt and ReleaseHoisting.
To avoid quadratic complexity for large functions, limit the amount of work what the EscapeUtils are allowed to to.
This keeps the complexity linear.

The arbitrary limit is good enough for almost all functions.
It lets the EscapeUtils do several hundred up/down walks which is much more than needed in most cases.

Fixes a compiler hang
https://github.com/apple/swift/issues/63846
rdar://105795976
2023-02-24 18:58:01 +01:00
swift-ci
aaa54e3e58 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-23 00:33:41 -08:00
Alex Hoppen
46f5119113 [CodeCompletion] Don’t crash if constructors in member lookup have an error type 2023-02-22 22:33:42 +01:00
Pavel Yaskevich
29725e8209 [Sema/Tests] NFC: Limit a couple of perf tests to macOS
Helps to avoid flakiness on simulators/devices.

Resolves: rdar://105752467
2023-02-22 00:30:39 -08:00