Commit Graph

2520 Commits

Author SHA1 Message Date
Mishal Shah
06c975cff4 Remove code sign from stdlib/Error.swift 2020-08-07 12:40:11 -07:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Saleem Abdulrasool
48b0802b63 test: swap parameters in test assertion (NFC)
Swap the parameters in `assertEqual` to improve diagnostics on failure.
This now prints as:

```
stdout>>> expected: -431 (of type Swift.int)
stdout>>> actual: -11 (of type Swift.int)
```
2020-08-06 09:04:23 -07:00
Rintaro Ishizaki
4e003dc8cc [Tests] Mark two test cases 'UNSUPPORTED: use_os_stdlib'
test/Runtime/demangleToMetadata.swift
test/stdlib/Casts.swift

rdar://problem/66394834
rdar://problem/66394791
2020-07-31 16:02:49 -07:00
eeckstein
53d3dda55e Merge pull request #33179 from eeckstein/existential-box-elimination
SILCombine: optimize casts of existential boxes.
2020-07-31 18:02:31 +02:00
Doug Gregor
e2cdc5e04b Merge pull request #33196 from DougGregor/concurrency-lib
[Concurrency] Stub out an experimental concurrency support library.
2020-07-30 11:51:27 -07:00
Erik Eckstein
5f3e79b84e StringOptimization: bug fixes
Fix some bugs in the optimization and in the test files.

rdar://problem/66283894
2020-07-30 11:32:39 +02:00
Doug Gregor
9b0266cf6a [Concurrency] Stub out an experimental concurrency support library.
The experimental concurrency model will require a supporting runtime
and possibly end-user-visible library constructs. Introduce a stub of
such a library, enabled by a new `build-script` option
`--enable-experimental-concurrency`, so we have a place to put this
work.
2020-07-29 16:32:27 -07:00
Erik Eckstein
662f03ec4c SILCombine: optimize casts of existential boxes.
Optimize the unconditional_checked_cast_addr in this pattern:

   %box = alloc_existential_box $Error, $ConcreteError
   %a = project_existential_box $ConcreteError in %b : $Error
   store %value to %a : $*ConcreteError
   %err = alloc_stack $Error
   store %box to %err : $*Error
   %dest = alloc_stack $ConcreteError
   unconditional_checked_cast_addr Error in %err : $*Error to ConcreteError in %dest : $*ConcreteError

to:
   ...
   retain_value %value : $ConcreteError
   destroy_addr %err : $*Error
   store %value to %dest $*ConcreteError

This lets the alloc_existential_box become dead and it can be removed in following optimizations.
The same optimization is also done for conditional_checked_cast_addr.

There is also an implication for debugging:
Each "throw" in the code calls the runtime function swift_willThrow. The function is used by the debugger to set a breakpoint and also add hooks.
This optimization can completely eliminate a "throw", including the runtime call.
So, with optimized code, the user might not see the program to break at a throw, whereas in the source code it is actually throwing.
On the other hand, eliminating the existential box is a significant performance win and we don't guarantee any debugging behavior for optimized code anyway. So I think this is a reasonable trade-off.
I added an option "-Xllvm -keep-will-throw-call" to keep the runtime call which can be used if someone want's to reliably break on "throw" in optimized builds.

rdar://problem/66055678
2020-07-29 21:57:51 +02:00
Doug Gregor
41817229d5 Merge pull request #33147 from DougGregor/async-function-types
[Concurrency] Add `async` to the Swift type system.
2020-07-29 08:59:34 -07:00
Doug Gregor
06d322b211 [Concurrency] Rename -enable-experimental-async.
Use the more general name `-enable-experimental-concurrency` instead,
since async is one part of the model.
2020-07-28 09:38:54 -07:00
Doug Gregor
f6e9f352f0 [Concurrency] Add async to the Swift type system.
Add `async` to the type system. `async` can be written as part of a
function type or function declaration, following the parameter list, e.g.,

  func doSomeWork() async { ... }

`async` functions are distinct from non-`async` functions and there
are no conversions amongst them. At present, `async` functions do not
*do* anything, but this commit fully supports them as a distinct kind
of function throughout:

* Parsing of `async`
* AST representation of `async` in declarations and types
* Syntactic type representation of `async`
* (De-/re-)mangling of function types involving 'async'
* Runtime type representation and reconstruction of function types
involving `async`.
* Dynamic casting restrictions for `async` function types
* (De-)serialization of `async` function types
* Disabling overriding, witness matching, and conversions with
differing `async`
2020-07-27 18:18:03 -07:00
Erik Eckstein
7f684b62e2 SIL optimizer: Add a new string optimization.
Optimizes String operations with constant operands.

Specifically:
  * Replaces x.append(y) with x = y if x is empty.
  * Removes x.append("")
  * Replaces x.append(y) with x = x + y if x and y are constant strings.
  * Replaces _typeName(T.self) with a constant string if T is statically known.

With this optimization it's possible to constant fold string interpolations, like "the \(Int.self) type" -> "the Int type"

This new pass runs on high-level SIL, where semantic calls are still in place.

rdar://problem/65642843
2020-07-27 21:32:56 +02:00
Luciano Almeida
33d23719eb [tests] Fixing pattern match of note avalable overload lists diagnostic 2020-07-24 15:01:52 -03:00
Luciano Almeida
c09af513a0 [tests] Adjusting regression tests argument mismatch diagnostics on suit 2020-07-23 20:05:27 -03:00
Holly Borla
c8e9018c4d [CSGen] Don't merge type variables for literals in computeFavoredTypeForExpr 2020-07-22 14:43:05 -07:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Karoy Lorentey
8961b4ea56 [test] stdlib/DefaultIndices: Adjust test conditional
This makes it easier to find & update the availability condition if this behavior ships in an OS release.
2020-07-15 14:27:21 -07:00
Nate Chandler
a2ce157a98 [Test] Disable stdlib/DefaultIndices when use_os_stdlib.
rdar://problem/65605593
2020-07-15 09:58:36 -07:00
Karoy Lorentey
5f489fc719 [test] Fix architecture conditional
rdar://64995079
2020-07-14 18:55:41 -07:00
Stephen Canon
103961a7d5 Make Float16 unavailable on macOS and macCatalyst, mirroring Xcode's Swift. (#32868)
LLVM doesn't have a stable ABI for Float16 on x86 yet; we're working with Intel to get that fixed, but we don't want to make the type available on macOS until a stable ABI is actually available, because we'd break binaries compiled before any calling convention changes if we do.
2020-07-14 20:42:12 -04:00
Nate Cook
3af1deb447 [stdlib] Add _forEachField(of:options:body:) function (#32873)
This function walks all the fields of a struct, class, or tuple, and calls
`body` with the name, offset, and type of each field. `body` can perform
any required work or validation, returning `true` to continue walking fields
or `false` to stop immediately.
2020-07-14 16:31:32 -05:00
Karoy Lorentey
40d7da4fad Merge pull request #32019 from NevinBR/patch-1
[SR-12881] DefaultIndices dynamic dispatch
2020-07-14 12:05:12 -07:00
Brent Royal-Gordon
745dbef3ef Use file IDs in generated code
Such as force unwraps, as! casts, etc.
2020-07-13 14:05:13 -07:00
Saleem Abdulrasool
08924c476d Merge pull request #32826 from compnerd/bloating-point-operations
test: make `stdlib/Integer.swift.gyb` python 3 friendly
2020-07-13 13:46:11 -07:00
Saleem Abdulrasool
cb1aeea9af test: make stdlib/Integer.swift.gyb python 3 friendly
Adjust the division operation to ensure that we get an integral value
back.  Without this, we would attempt to shift a floating point value
by bitwise operations which is not supported.
2020-07-10 14:28:49 -07:00
Nate Chandler
c5270a5968 [Test] Xfail stdlib/NSValueBridging.swift
rdar://problem/64995079
2020-07-10 06:29:52 -07:00
Karoy Lorentey
b42910a430 [test] Reenable NSValueBridging tests on i386
Instead, disable tests we cannot run with a targeted platform conditional.
2020-07-08 22:33:17 -07:00
Mishal Shah
ca87af103b Merge pull request #32705 from apple/apple-silicon-master
[master] Apple Silicon support
2020-07-04 21:53:08 -07:00
Mishal Shah
92ca9fc924 [Apple Silicon] Generalize tests for other macOS architectures
Most of the changes fall into a few categories:
* Replace explicit "x86_64" with %target-cpu in lit tests
* Cope with architecture differences in IR/asm/etc. macOS-specific tests
2020-07-02 16:27:46 -07:00
Dario Rexin
732698e268 Fix symbol visibility test for CentOS 7 2020-07-02 13:21:38 -07:00
tbkka
f989aa2b22 SR-12486: T.self is Any.Protocol is broken (#31662)
* SR-12486: `T.self is Any.Protocol` is broken

This turned out to be fallout from https://github.com/apple/swift/pull/27572
which was in turn motivated by our confusing metatype syntax when generic variables are bound to protocols.

In particular, the earlier PR was an attempt to make the expression
`x is T.Type` (where `T` is a generic type variable bound to a protocol `P`)
behave the same as
`x is P.Type` (where `P` is a protocol).
Unfortunately, the generic `T.Type` actually binds to `P.Protocol` in this case (not `P.Type`), so the original motivation was flawed, and as it happens, `x is T.Type` already behaved the same as `x is P.Protocol` in this situation.

This PR reverts that earlier change and beefs up some of the tests around these behaviors.

Resolves SR-12486

Resolves rdar://62201613

Reverts PR#27572
2020-07-02 13:10:01 -07:00
Robert Widmann
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03:01 -07:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Károly Lőrentey
b3fb7626c1 [test] Don’t import UIKit on iOS 10.3 2020-06-29 18:44:22 -07:00
Karoy Lorentey
73c99acf29 [test] Reinstate CoreGraphics↔︎NSValue bridging tests on iOS/watchOS/tvOS 2020-06-29 16:46:50 -07:00
Saleem Abdulrasool
a817409562 test: make stdlib.NumericParsing Python 3 friendly
Use the proper division operation as the test otherwise generates
different patterns.
2020-06-29 08:55:01 -07:00
Pavel Yaskevich
a8d44bc9ce Merge pull request #32558 from xedin/fix-req-conformace-assessment
[ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
2020-06-26 15:28:13 -07:00
Ben Cohen
87df9961a5 Add fast string interpolation for metatypes (#32113) 2020-06-26 09:46:54 -07:00
Pavel Yaskevich
0ea0b8e27b [ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
Currently it's possible to have a type conflict between different
requirements deduced as the same type which leads to incorrect
diagnostics. To mitigate that let's adjust how "fixed" requirements
are stored - instead of using resolved type for the left-hand side,
let's use originating generic parameter type.
2020-06-25 13:40:15 -07:00
Mishal Shah
ace20bdeb1 Remove comment in TestData.swift 2020-06-23 09:11:39 -07:00
Mishal Shah
52d11fdc57 Remove comment in TestData.swift 2020-06-23 09:11:04 -07:00
Karoy Lorentey
da242bd2d4 [SDK] Remove obsolete overlay code 2020-06-22 15:43:39 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Pavel Yaskevich
82fcee7bc7 [Diagnostics] NFC: Adjust diagnostic test-cases improved by new ambiguity diagnosis 2020-06-12 13:13:27 -07:00
Pavel Yaskevich
ac2305e7f1 [ConstraintSystem] Increase impact of fixes for some conditional requirements
If there is a conditional requirement failure associated with
member/function reference used in a call let's increase a score
of a fix for such failure because it renders member/function
unreachable in current context or with a given set of arguments.
2020-06-12 11:47:04 -07:00
Pavel Yaskevich
d9594c712a [TypeChecker] NFC: Adjust tests improved by new approach for ambiguity diagnosis 2020-06-12 11:47:03 -07:00
tbkka
db9cf4cd80 Filter out more std::__once_call_impl<>() constructors (#32325)
One of our Ubuntu 16.04 CI machines is seeing different variations
of the std::__once_call_impl<>() constructor than the ones we're already filtering out.

Resolves rdar://64267618
2020-06-12 10:03:13 -07:00
3405691582
7b431b4ddb [test] Mark XFAIL tests for OpenBSD.
These tests are marked XFAIL or UNSUPPORTED because either the tests:
require libc annotation, require Mach-O support, don't recognize calls to
swift-autolink-extract, requires porting alongside Linux, or rely on simd
which is not present.

Additionally, explicit REQUIRES for tsan/asan/fuzzer are added to some
tests, since OpenBSD does not support these sanitizers or fuzzers, since
it's nicer to mark that with REQUIRES rather than XFAIL.
2020-06-10 18:57:19 -04:00
Saleem Abdulrasool
017d99d7e4 test: add a test to prevent weak symbol leakage
The Swift standard library should not export weak symbols.  Ensure that
no public weak symbols are defined in the standard library by adding a
test case.  This would have identified the issue introduced by the
recent changes for the runtime.
2020-06-08 16:24:11 -07:00