Commit Graph

5674 Commits

Author SHA1 Message Date
Erik Eckstein
5b77f64356 tests: The large_string_array test only works for 64 bits. 2020-04-13 08:19:16 +02:00
eeckstein
628bf7beae Merge pull request #30957 from eeckstein/fix-large-string-arrays
Several compile time fixes related to large string arrays.
2020-04-11 06:55:00 +02:00
Hamish Knight
a61223a255 [CS] Visit all fixed bindings for constraint re-activation (#30886)
[CS] Visit all fixed bindings for constraint re-activation
2020-04-10 12:27:47 -07:00
Erik Eckstein
e117378d68 tests: add a compile-time test for large string arrays.
rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Hamish Knight
47541d86f7 [CS] Visit all fixed bindings for constraint re-activation
Start visiting transitive fixed bindings for type
variables, and stop visiting adjacencies for
`gatherConstraint`'s `AllMentions` mode.

This improves performance and fixes a correctness
issue with the old implementation where we could
fail to re-activate a coercion constraint, and
then let invalid code get past Sema, causing
either miscompiles or crashes later down the
pipeline.

Unfortunately this change requires us to
temporarily drop the non-ephemeral fix for a couple
of fairly obscure cases where the overload hasn't
yet been resolved. The logic was previously relying
on stale adjacency state in order to re-activate
the fix when the overload is bound, but it's not
connected on the constraint graph. We need to find
a way to connect constraints to unresolved
overloads they depend on.

Resolves SR-12369.
2020-04-10 10:16:07 -07:00
marcrasi
ddef9292a6 [AutoDiff upstream] DifferentiationUnittest and some e2e tests (#30915)
Adds 2 simple e2e tests and some lit subsitutions and unittest libraries
necessary to support them.
2020-04-09 14:25:31 -07:00
Slava Pestov
549f630c40 Merge pull request #30809 from slavapestov/curry-thunk-source-range-fix
Sema: Fix source range for curry thunks
2020-04-06 13:37:01 -04:00
Xi Ge
698f62c4c6 test: disable stdlib tests due to rdar://61347183 2020-04-06 10:12:31 -07:00
Slava Pestov
5f51546480 Sema: Fix source range for curry thunks
Fixes <rdar://problem/61117301> / <https://bugs.swift.org/browse/SR-12496>.
2020-04-03 23:26:04 -04:00
Pavel Yaskevich
4bc049b864 [TypeChecker] NFC: Add a perf test for rdar://problem/60961087 2020-04-03 15:56:27 -07:00
marcrasi
dccb75c810 [AutoDiff] disable SIL/verify_all_overlays.py for "_Differentiation"
It is failing so I'll disable it to fix the tests until we fix it.
2020-04-01 12:07:39 -07:00
marcrasi
77fd034a0b Merge pull request #30711 from rxwei/differential-operators
[AutoDiff upstream] Add differential operators and some utilities.
2020-04-01 10:11:35 -07:00
Marc Rasi
013a66bffc exempt _Differentiation from verify_all_overlays test 2020-03-31 16:25:09 -07:00
tbkka
3c8fde7885 Implement MultiPayloadEnum support for projectEnumValue (#30635)
This code rearchitects and simplifies the projectEnumValue support by
introducing a new `TypeInfo` subclass for each kind of enum, including trivial,
no-payload, single-payload, and three different classes for multi-payload enums:

* "UnsupportedEnum" that we don't understand.  This returns "don't know" answers for all requests in cases where the runtime lacks enough information to accurately handle a particular enum.

* MP Enums that only use a separate tag value.  This includes generic enums and other dynamic layouts, as well as enums whose payloads have no spare bits.

* MP Enums that use spare bits, possibly in addition to a separate tag.  This logic can only be used, of course, if we can in fact compute a spare bit mask that agrees with the compiler.

The final challenge is to choose one of the above three handlings for every MPE.  Currently, we do not have an accurate source of information for the spare bit mask, so we never choose the third option above.  We use the second option for dynamic MPE layouts (including generics) and the first for everything else.

TODO: Once we can arrange for the compiler to expose spare bit mask data, we'll be able to use that to drive more MPE cases.
2020-03-31 15:12:44 -07:00
swift-ci
047438711f Merge pull request #30355 from mikeash/remote-mirror-type-name-api 2020-03-27 10:51:24 -07:00
Mike Ash
625768e976 [Reflection] Fix up Reflection/existentials.swift test.
rdar://problem/59909982
2020-03-27 10:11:19 -04:00
Karoy Lorentey
4d0ea75e15 [test] Convert XCTest test to a build-only API test
Some bad interactions with StdlibUnittest and XCTest lead to sporadic test timeouts for this test. Given that the codebase is obsolete, the best option seems to be to stop running this test altogether. All we really care is that the resulting dylib still contains the right symbols, and building (but not running) this test seems to be a reasonable way of doing that.
2020-03-26 16:35:22 -07:00
Mike Ash
3a9e7a6611 [Reflection] Implement TypeRef demangling for foreign classes.
rdar://problem/59909982
2020-03-25 17:22:45 -04:00
Slava Pestov
d7d7e2d2ec Add test case for rdar://problem/60081992 2020-03-24 01:29:26 -04:00
Mike Ash
e05720cd09 [RemoteMirror] Add a call to get the demangled name for a typeref.
rdar://problem/59909982
2020-03-23 13:53:35 -04:00
Brent Royal-Gordon
cd7bc73a0a Merge pull request #30462 from brentdax/futures-end-part-two
Provide fallback SourceLoc for swiftinterface build errors
2020-03-18 16:23:49 -07:00
Slava Pestov
c543838854 Sema: Rewrite partial applications into closures
When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
2020-03-18 09:29:22 -04:00
Brent Royal-Gordon
a27fdad4e5 Provide fallback SourceLoc for swiftinterface build errors
When a swiftinterface fails to build for any of various reasons, we try to diagnose the failure at the site of the `import` declaration. But if the import is implicitly added—which happens for many SDK modules, like the standard library and ClangImporter overlays—there is no source location for the import, so the error ends up being diagnosed at <unknown>:0. This causes a number of issues; most notably, Xcode doesn’t display the diagnostic as prominently as others.

This change falls back to diagnosing the error at line 1, column 1 of the swiftinterface file itself. This is perhaps not an ideal location, and it won’t help with I/O errors where we can’t open the swiftinterface file (and therefore can’t diagnose an error in it), but it should improve the way we display most module interface building errors.
2020-03-17 18:44:31 -07:00
Brent Royal-Gordon
5b7a13cf69 Merge pull request #30410 from brentdax/futures-end
Improve diagnostic for broken module interfaces
2020-03-14 01:25:58 -07:00
Brent Royal-Gordon
a7a5e340aa Improve diagnostic for broken module interfaces
Currently, when a swiftinterface file fails to load, we emit the specific diagnostics for the failures, followed by a generic “failed to load module ‘Foo’” message. This PR improves that final diagnostic, particularly when the cause may be that the interface was emitted by a newer compiler using backwards-incompatible syntax.
2020-03-13 20:31:55 -07:00
Meghana Gupta
8e800e49bf Recommit #29812 with fixes (#30342) 2020-03-13 19:34:16 -07:00
tbkka
ee36c1cc3e RemoteMirror: Project some multi-payload enums (#30357)
* First part of multi-payload enum support

This handles multi-payload enums with fixed
layouts that don't use spare payload bits.
It includes XI calculations that allow us to
handle single-payload enums where the payload
ultimately includes a multi-payload enum
(For example, on 32-bit platforms, String uses
a multi-payload enum, so this now supports single-payload
enums carrying Strings.)
2020-03-11 18:48:39 -07:00
Rintaro Ishizaki
ccbc26d947 Revert "Use in_guaranteed for let captures (#29812)"
This reverts commit 13b9915c6f.
2020-03-10 16:08:08 -07:00
Meghana Gupta
13b9915c6f Use in_guaranteed for let captures (#29812)
* Use in_guaranteed for let captures

With this all let values will be captured with in_guaranteed convention
by the closure. Following are the main changes :

SILGen changes:
- A new CaptureKind::Immutable is introduced, to capture let values as in_guaranteed.
- SILGen of in_guaranteed capture had to be fixed.
  in_guaranteed captures as per convention are consumed by the closure. And so SILGen should not generate a destroy_addr for an in_guaranteed capture.
  But LetValueInitialization can push Dealloc and Release states of the captured arg in the Cleanup stack, and there is no way to access the CleanupHandle and disable the emission of destroy_addr while emitting the captures in SILGenFunction::emitCaptures.
  So we now create, temporary allocation of the in_guaranteed capture iduring SILGenFunction::emitCaptures without emitting destroy_addr for it.

SILOptimizer changes:
- Handle in_guaranteed in CopyForwarding.
- Adjust dealloc_stack of in_guaranteed capture to occur after destroy_addr for on_stack closures in ClosureLifetimeFixup.

IRGen changes :
  - Since HeapLayout can be non-fixed now, make sure emitSize is used conditionally
  - Don't consider ClassPointerSource kind parameter type for fulfillments while generating code for partial apply forwarder.
    The TypeMetadata of ClassPointSource kind sources are not populated in HeapLayout's NecessaryBindings. If we have a generic parameter on the HeapLayout which can be fulfilled by a ClassPointerSource, its TypeMetaData will not be found while constructing the dtor function of the HeapLayout.
    So it is important to skip considering sources of ClassPointerSource kind, so that TypeMetadata of a dependent generic parameters gets populated in HeapLayout's NecessaryBindings.
2020-03-10 12:23:02 -07:00
Holly Borla
b12bd4e919 Merge pull request #30307 from hborla/merge-partial-solutions-too-complex
[ConstraintSystem] Respect the constraint solver performance thresholds,
2020-03-10 09:44:32 -07:00
Holly Borla
c1c6a884a4 [ConstraintSystem] Respect the constraint solver performance thresholds,
including time and allocated memory, in mergePartialSolutions.
2020-03-09 14:44:12 -07:00
Mike Ash
b80e33b514 Fix reuse of the payload area when the discriminator != 0 2020-03-09 11:58:54 -07:00
Pavel Yaskevich
a1987ec274 Merge pull request #30283 from xedin/rdar-60185506
Revert "[ConstraintSystem] Make it possible to infer subtype bindings…
2020-03-07 22:34:10 -08:00
Pavel Yaskevich
0ecedfa5ea Revert "[ConstraintSystem] Make it possible to infer subtype bindings through argument conversions"
Reverts apple/swift#30006. It caused a regression that we'd like to address before re-landing:

```swift
struct X {
  var cgf: CGFloat
}

func test(x: X?) {
  let _ = (x?.cgf ?? 0) <= 0.5
}
```

This reverts commit 0a6b444b49.
This reverts commit ed255596a6.
This reverts commit 3e01160a2f.
This reverts commit 96297b7e39.

Resolves: rdar://problem/60185506
2020-03-07 20:16:56 -08:00
Tim Kientzle
03a0042ace API changes in SwiftRemoteMirror make these tests unsuitable for back-deployment testing 2020-03-07 13:13:23 -08:00
tbkka
0d361bd3ea Teach RemoteMirror how to project enum values (#30161)
Teach RemoteMirror how to project enum values

This adds two new functions to the SwiftRemoteMirror
facility that support inspecting enum values.

Currently, these support non-payload enums and
single-payload enums, including nested enums and
payloads with struct, tuple, and reference payloads.
In particular, it handles nested `Optional` types.

TODO: Multi-payload enums use different strategies for
encoding the cases that aren't yet supported by this
code.

Note: This relies on information from dataLayoutQuery
to correctly decode invalid pointer values that are used
to encode enums.  Existing clients will need to augment
their DLQ functions before using these new APIs.

Resolves rdar://59961527

```
/// Projects the value of an enum.
///
/// Takes the address and typeref for an enum and determines the
/// index of the currently-selected case within the enum.
///
/// Returns true iff the enum case could be successfully determined.
/// In particular, note that this code may fail for valid in-memory data
/// if the compiler is using a strategy we do not yet understand.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
                                      swift_addr_t EnumAddress,
                                      swift_typeref_t EnumTypeRef,
                                      uint64_t *CaseIndex);

/// Finds information about a particular enum case.
///
/// Given an enum typeref and index of a case, returns:
/// * Typeref of the associated payload or zero if there is no payload
/// * Name of the case if known.
///
/// The Name points to a freshly-allocated C string on the heap.  You
/// are responsible for freeing the string (via `free()`) when you are finished.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
                                        swift_typeref_t EnumTypeRef,
                                        unsigned CaseIndex,
                                        char **CaseName,
                                        swift_typeref_t *PayloadTypeRef);
```


Co-authored-by: Mike Ash <mikeash@apple.com>
2020-03-06 13:17:40 -08:00
Holly Borla
24d8aa148f Merge pull request #30185 from hborla/dependent-type-requirement-failure
[ConstraintSystem] Replace dependent member types with holes when the…
2020-03-03 19:55:07 -08:00
Holly Borla
fce8738ea8 [ConstraintSystem] Replace dependent member types with holes when the base type
doesn't conform to the associatedtype's protocol (only in diagnostic mode).

This allows the solver to find solutions for more cases involving requirement
failures for dependent member types without special cases across the solver
that check for dependent member types with no type variables.
2020-03-03 15:45:24 -08:00
Joe Groff
d8e8b3d307 Merge pull request #30105 from jckarter/objc-opt-self
IRGen: Invoke objc_opt_self directly when available.
2020-03-03 07:29:27 -08:00
Nathan Hawes
168a9ba318 [test] Remove orphaned comment from validation-test/SIL/verify_all_overlays.py 2020-03-02 15:12:08 -08:00
Joe Groff
e844771a74 Remove explicit target(s) from reflect_empty_struct tests
Swift CI tests backward deployment on different host OSes, so this should be covered in
testing. The explicit target doesn't work well with `executable_test` since it leads to
binaries with too-new minimum deployment targets getting executed on older host OSes.
2020-03-02 12:38:32 -08:00
Nathan Hawes
68ad8acded [test] remove xfail on validation-test/SIL/verify_all_overlays.py
Looks like it started passing:
https://ci.swift.org/job/oss-swift_tools-RA_stdlib-RDA_long-test/3521/
2020-03-02 11:01:10 -08:00
Pavel Yaskevich
20fc51d4f4 [CSBindings] Open collection before binding parameter only if original argument type failed
Instead of always opening argument type represented by a collection
without type variables (to support subtyping when element is a labeled tuple),
let's try original type first and if that fails use a slower path with
indirection which attempts `array upcast`. Doing it this way helps to
propagate contextual information faster which fixes a performance regression.

Resolves: rdar://problem/54580247
2020-02-27 16:26:13 -08:00
Doug Gregor
031f5a4888 Merge pull request #30065 from DougGregor/function-builders-if-case-fixes
[Constraint system] Cleanups for function builders support for if let/if case let
2020-02-26 10:38:15 -08:00
Doug Gregor
b94a5c8dd4 Update a test case's expected output 2020-02-25 20:39:42 -08:00
Pavel Yaskevich
b926250c70 Merge pull request #30006 from xedin/rdar-56212087
[ConstraintSystem] Make it possible to infer subtype bindings through argument conversions
2020-02-24 14:18:35 -08:00
Saleem Abdulrasool
e9aaef4bea test: move RangeSet test into validation-test
The RangeSet test depends on the StdlibCollectionUnittest, which is part
of the validation tests.  This should repair the tests.
2020-02-22 17:26:43 -08:00
Slava Pestov
e69a361655 Merge pull request #29994 from slavapestov/disable-test-harder
Disable test_backward_deploy_conformance completely on Swift-in-the-OS bots
2020-02-21 21:30:44 -05:00
Pavel Yaskevich
96297b7e39 [CSStep] Always attempt literal bindings in diagnostic mode
In case of contextual failures such bindings could produce
better solutions with fewer fixes.
2020-02-21 17:47:39 -08:00
Pavel Yaskevich
dec2ad0f93 Merge pull request #29979 from xedin/rdar-56400265
[ConstraintSystem] Avoid exploring too much search space when call ar…
2020-02-21 11:16:33 -08:00