Commit Graph

7628 Commits

Author SHA1 Message Date
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
swift-ci
4c9032a9df Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 10:34:25 -08:00
Tim Kientzle
791d780da4 Merge pull request #59488 from tbkka/tbkka-remoteMirrorIndirectEnums
Test support for indirect enums in RemoteMirror
2023-02-15 10:30:08 -08:00
swift-ci
80446e28eb Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 08:53:03 -08:00
Daniel Rodríguez Troitiño
8be7136a0b Change experimental reflection lit feature to reflection_runtime (#63670)
The feature "reflection" was already used in the tests (enabled with
SWIFT_ENABLE_REFLECTION). The new feature tests were triggered even if
the experimental feature was not enabled in people builds.

Change the spelling to "reflection_runtime" to not clash with the
existing feature. Change all the tests I found added lately that has the
existing spelling.
2023-02-15 08:40:39 -08:00
Tim Kientzle
017373b899 Add more detail to test 2023-02-14 10:41:15 -08:00
swift-ci
9ca01155df Merge remote-tracking branch 'origin/main' into rebranch 2023-02-13 22:14:24 -08:00
Karoy Lorentey
2e8ae40344 Merge pull request #63592 from lorentey/rework-string-breadcrumbs
[stdlib] Rework String breadcrumbs initialization/loading
2023-02-13 22:11:57 -08:00
swift-ci
9b8c8421c5 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-10 21:54:43 -08:00
Karoy Lorentey
73f349cb15 [stdlib] Rework String breadcrumbs initialization/loading
This is a wild guess at what might be causing our persistent, random
String failures on the main branch:

```
  Swift(macosx-x86_64) :: Prototypes/CollectionTransformers.swift
  Swift(macosx-x86_64) :: stdlib/NSSlowString.swift
  Swift(macosx-x86_64) :: stdlib/NSStringAPI.swift
  Swift(macosx-x86_64) :: stdlib/StringIndex.swift
  Swift-validation(macosx-x86_64) :: stdlib/String.swift
  Swift-validation(macosx-x86_64) :: stdlib/StringBreadcrumbs.swift
  Swift-validation(macosx-x86_64) :: stdlib/StringUTF8.swift
```

FWIW, it appears this is *not* caused by https://github.com/apple/swift/pull/62717:
that change has also landed on release/5.8, and I haven’t seen these
issues on that branch.

Our atomic breadcrumbs initialization vs its non-atomic loading
gives me an uneasy feeling that this may in fact be a long standing
synchronization issue that is only now causing problems (for whatever
reason). I am unable to reproduce these issues locally, so this guess
may be (and probably is) wildly off the mark, but this PR is likely
to be a good idea anyway, if only to rule out this possibility.

rdar://104751936
2023-02-10 20:23:56 -08:00
Pavel Yaskevich
bffb8d9ee2 Revert "[CSGen] Handle recursive use of variable declarations" 2023-02-10 16:45:59 -08:00
swift-ci
5127f32808 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-09 11:33:33 -08:00
Pavel Yaskevich
83dd93ad2e [CSGen] Handle recursive use of variable declarations
It's possible for out-of-scope type variable to be the type of
declaration if such declaration is recursively referenced in
the body of a closure located in its initializer expression.
In such cases type of the variable declaration cannot be connected
to the closure because its not known in advance (determined by the
initializer itself).

Resolves: https://github.com/apple/swift/issues/63455
2023-02-07 17:48:26 -08:00
swift-ci
197114cb22 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-03 08:55:08 -08:00
Hamish Knight
a40f1abaff Introduce if/switch expressions
Introduce SingleValueStmtExpr, which allows the
embedding of a statement in an expression context.
This then allows us to parse and type-check `if`
and `switch` statements as expressions, gated
behind the `IfSwitchExpression` experimental
feature for now. In the future,
SingleValueStmtExpr could also be used for e.g
`do` expressions.

For now, only single expression branches are
supported for producing a value from an
`if`/`switch` expression, and each branch is
type-checked independently. A multi-statement
branch may only appear if it ends with a `throw`,
and it may not `break`, `continue`, or `return`.

The placement of `if`/`switch` expressions is also
currently limited by a syntactic use diagnostic.
Currently they're only allowed in bindings,
assignments, throws, and returns. But this could
be lifted in the future if desired.
2023-02-01 15:30:18 +00:00
swift-ci
82c0288da8 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-01 06:13:47 -08:00
Arnold Schwaighofer
770648f161 Initial runtime changes to support relative protocol witness tables 2023-01-31 10:59:37 -08:00
swift-ci
df03bae172 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-30 17:14:39 -08:00
Tim Kientzle
7ea2b4becb Merge pull request #63249 from tbkka/tbkka-fix-MPE-degenerate-test-on-32-bit
Fill in the missing 32-bit checks for this test
2023-01-30 17:10:24 -08:00
swift-ci
8fb2a6d520 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-26 15:54:40 -08:00
Tim Kientzle
a959161707 Fill in the missing 32-bit checks for this test 2023-01-26 14:29:03 -08:00
Egor Zhdan
063be28a54 [cxx-interop] Update the C++ stdlib module name in SIL/verify_all_overlays.py 2023-01-26 19:19:46 +00:00
swift-ci
e72e4d36e1 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-20 09:27:31 -08:00
Tim Kientzle
693c276313 Disable this test on watchOS
I've not been able to fill in the 32-bit expectations here yet.
Until I can do that, this won't work on any 32-bit platforms.
2023-01-19 12:58:01 -08:00
swift-ci
ce7f90aaef Merge remote-tracking branch 'origin/main' into rebranch 2023-01-17 09:34:30 -08:00
Alejandro Alonso
c7a9360806 [Reflection] Build the _Runtime and Reflection modules (#62973)
* Move Runtime into _Runtime

Fix more _Runtime names

* Add availability to all API

* Build _Runtime and Reflection modules

* Use threading's mutex for all platforms

add stdlib include
2023-01-17 09:30:16 -08:00
Erik Eckstein
7ee2c105d5 tests: disable floating point conversion tests for the x86_64 simulator
There is a problem with 16-bit floating point conversions.

rdar://104232602
2023-01-16 09:58:23 +01:00
Karoy Lorentey
a3e517ed36 [stdlib] String: Fix forward implementation of grapheme breaking rule 11
Rule GB11 in Unicode Annex 29 is:

GB11: Extended_Pictographic Extend* ZWJ × Extended_Pictographic

However, our forward grapheme breaking state machine implements it as:

GB11: Extended_Pictographic Extend* ZWJ+ × Extended_Pictographic

We implement the correct rules when going backward, which can cause String values to have different counts whether we’re going forward or back.

The rule as implemented would be fine (Unicode doesn’t care much about the placement of grapheme breaks in invalid sequences), but the directional inconsistency messes with String’s Collection conformance.

rdar://104279671
2023-01-15 16:12:38 -08:00
Tim Kientzle
d969611ec5 Merge pull request #62614 from tbkka/tbkka-92945673-RemoteMirror-MPE
[RemoteMirror] Fix handling of zero-sized payloads and extra inhabitant calculations
2023-01-09 16:41:21 -08:00
Tim Kientzle
f087b5e0fb This PR aligns RemoteMirror more closely with the compiler's handling of enums
that contain zero-sized payloads, which should resolve a number of issues with
RemoteMirror incorrectly reflecting enum cases and/or measuring the layout of
structures containing enums.

Background: Enum cases that have zero-sized payloads are handled
differently from other payload-bearing cases.

1. For layout purposes, they're treated as
   non-payload cases.  This can cause an MPE to
   actually get represented in memory as a single-payload
   or non-payload enum.

2. However, zero-sized payloads are still considered for
   extra inhabitant calculations.  Since they have no
   extra inhabitants, this tends to cause such enums to
   also not expose extra inhabitants to containing enums.

This commit makes several change to how RemoteMirror determines
enum layout:

* The various "*EnumTypeInfo" classes now represent
  layout mechanisms -- as described in (1) above,
  this can differ from the source code concept.

* An Enum "kind" is separately computed to reflect the
  source code concept; this ensures that the dumped
  type information reflects the source code.

* For single-payload and no-payload _layouts_,
  the extra inhabitant calculation has been adjusted
  to ensure that zero-sized payloads are correctly
  considered.

Resolves: rdar://92945673
2023-01-06 11:16:07 -08:00
Augusto Noronha
893d83ba0a Fix wrong calculation of generic params per level when building decl
Fix computation of generic params per level when a generic type is
nested in  a non-generic one. For example, for the following code:

```
class A {
  class B<T, U> {
  }
}
```
Fix the array of generic params per level from [2] to [0, 2].

rdar://103457629
2023-01-06 10:41:41 -08:00
Kavon Farvardin
f594699c99 Merge pull request #62153 from kavon/lose-mainactor-94462333
Allow a global-actor to be dropped for some non-async functions.
2023-01-06 09:45:31 -08:00
Kavon Farvardin
3f6a0ccb90 Allow a global-actor to be dropped for some non-async functions.
It's ok to drop the global-actor qualifier `@G` from a function's type if:

- the cast is happening in a context isolated to global-actor `G`
- the function value will not be `@Sendable`
- the function value is not `async`

It's primarily safe to drop the attribute because we're already in the
same isolation domain. So it's OK to simply drop the global-actor
if we prevent the value from later leaving that isolation domain.
This means we no longer need to warn about code like this:

```
@MainActor func doIt(_ x: [Int], _ f: @MainActor (Int) -> ()) {
  x.forEach(f)
// warning: converting function value of type '@MainActor (Int) -> ()' to '(Int) throws -> Void' loses global actor 'MainActor'
}
```

NOTE: this implementation is a bit gross in that the constraint solver
might emit false warnings about casts it introduced that are actually
safe. This is mainly because closure isolation is only fully determined
after constraint solving. See the FIXME's for more details.

resolves rdar://94462333
2023-01-05 17:54:00 -08:00