Commit Graph

58361 Commits

Author SHA1 Message Date
Slava Pestov
10c37c6565 SILGen: Work around for stored property keypath components not supporting generic resilient classes
A keypath component for a stored property can take one of several forms:

- The property offset is known to be constant at compile-time.

  This is used in the simplest cases for classes and structs.

- The property offset is not constant, but can be loaded from a global.

  This is used for classes that require runtime resilient layout, but where
  the offsets do not depend on the generic context.

- The property offset is not constant, and must be loaded from metadata.

  This is the case where the offset depends on the generic context. Here,
  we were only set up to load it from a fixed offset in the metadata.
  This works for generic structs, or generic classes where the superclass
  chain does not cross a resilience boundary.

  However, if a resilience boundary is crossed, the offset of the field
  offset in the metadata must itself be obtained at runtime by adding a
  constant to a value loaded from a global. This case is not supported by
  the current keypath ABI due to an oversight.

I filed <rdar://problem/59777983> to track extending the ABI to handle
this more elegantly in the future.

Fixes <rdar://problem/59617119>.
2020-02-25 16:39:50 -05:00
Hamish Knight
0c785aaa07 [NameBinding] Remove BoundImport
This was only required to represent an import that
hadn't yet had its scope validated. Now that the
validation has been requestified, we can directly
record the resulting `ImportedModuleDesc` instead.
2020-02-25 13:29:52 -08:00
Hamish Knight
ab9b6d7e11 Requestify scoped import validation
Move the validation of scoped imports into a
request, and force the request when we're
type-checking a primary file. This has the nice
bonus of no longer running the validation for
secondary files.

The use of `ModuleDecl::getTopLevelModule` also
allows us to correctly retrieve the top-level
module for a Clang submodule, rather than
potentially retrieving the Swift module in a mixed
source project.

Resolves SR-12265.
2020-02-25 13:29:52 -08:00
eeckstein
49017c8ee8 Merge pull request #30042 from eeckstein/reinstate-inliner-change
Reinstate "Inliner: inline generic thunks which return a partial_apply."
2020-02-25 22:04:45 +01:00
Michael Gottesman
5237bcd3b1 [silcombine] Eliminate mark_dependence whose base is a trivial object.
This pattern comes up when faking a base using
Builtin.convertUnsafeUnownedToGuaranteed.

rdar://59735604
2020-02-25 12:32:24 -08:00
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Rintaro Ishizaki
571d09a8a2 Merge pull request #29955 from AnthonyLatsis/operator-diag-qoi
[Parse] Improve recovery from and diagnostics for invalid operator names
2020-02-25 10:11:26 -08:00
Joe Groff
0a318a39f1 Merge pull request #29644 from jckarter/subst-function-type-shakeout
Enable substituted SIL function types
2020-02-25 09:47:10 -08:00
Doug Gregor
4830c48960 [Constraint system] Support if let / if case in function builders.
Use the generalized constraint generation and binding for patterns to
introduce support for if-let and if-case in function builders, handling
arbitrary patterns.

Part of function builder generalization, rdar://problem/50426203.
2020-02-25 09:44:06 -08:00
Doug Gregor
3f2f79a699 [Constraint system] Fold pattern variable binding into constraint gen.
Rather than re-walk the pattern to create type bindings for the variables
that show up in the pattern, assign types to each of the variables as part
of constraint generation for the pattern. Only do this in contexts
where we will need the types, e.g., function builders.
2020-02-25 08:51:56 -08:00
Erik Eckstein
2f6c9f3a28 Reinstate "Inliner: inline generic thunks which return a partial_apply.""
This reinstates commit 92a764d9f6.

rdar://problem/59061452
2020-02-25 17:49:50 +01:00
Arnold Schwaighofer
5b046c691c Merge pull request #30037 from aschwaighofer/irgen_fix_partial_apply_conditional_conf_2nd
IRGen: Fix specialized conformances with abstract conditional requirements in the partial apply forwarder
2020-02-25 06:27:19 -08:00
Doug Gregor
fe5c068ffb Merge pull request #29879 from DougGregor/constraint-system-patterns
[Constraint system] Generate constraints from patterns
2020-02-24 20:41:14 -08:00
Hamish Knight
d9182af63d [AST] Introduce ModuleDecl::getTopLevelModule
This can be used to retrieve the Swift module
wrapper for a Clang submodule's top-level module.
2020-02-24 20:10:13 -08:00
Pavel Yaskevich
2cdd78501c [ConstraintSystem] Look through l-value while checking whether dynamic key path is recursive
Fix a crash in dynamic member lookup attempting to recursively
lookup a member on the same base type.

The problem is related to `isSelfRecursiveKeyPathDynamicMemberLookup`
which failed to look through l-value wrapping base type on each side of
the comparison, that's important because it's possible to have l-value
mismatch due to the fact that implicit call always gets l-value base
type but actual subscript which triggered dynamic lookup might be r-value.

Resolves: [SR-11743](https://bugs.swift.org/browse/SR-11743)
Resolves: rdar://problem/57091169
2020-02-24 19:38:20 -08:00
swift-ci
31d63a384c Merge pull request #30039 from vedantk/master 2020-02-24 18:05:19 -08:00
Joe Groff
059f1de9ac Merge pull request #30036 from jckarter/trivial-vs-static-metadata
IRGen: Separate the concept of "metadata should be cached" from "statically referenced"
2020-02-24 17:40:34 -08:00
Vedant Kumar
5fe5fcccc3 [Profiler] Don't crash visiting IfExpr in argument initializer
When visiting an expression in a function argument initializer, there
may not be an active region on the region stack, so don't try to access
it.

rdar://59695604
2020-02-24 16:01:24 -08:00
Doug Gregor
644ed76a01 [Constraint system] Prefer enum cases to static members when pattern matching. 2020-02-24 15:00:39 -08:00
Doug Gregor
6cfa0b047d [Constraint system] Don't dereference a null member locator. 2020-02-24 14:46:25 -08:00
Xi Ge
853c0f545b Merge pull request #29974 from nkcsgexi/53776566
ABIChecker: ignore accessors with forced static dispatch
2020-02-24 14:25:06 -08:00
Arnold Schwaighofer
449766f32a IRGen: Fix specialized conformances with abstract conditional requirements in the partial apply forwarder
2nd attempt.

rdar://59723512
2020-02-24 14:23:19 -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
Joe Groff
7ec52e6329 IRGen: Separate the concept of "metadata should be cached" from "statically referenced"
Some metadata may require instantiation, but not in a way that requires us to put an additional
cache layer in front of it. `Self` metadata is also trivial to access from the local cache, but
isn't statically referenceable. Split these concepts and update code to use one or the other
appropriately. This catches an issue with metadata prespecialization where it would try to
make records for dynamic `Self` incorrectly.
2020-02-24 13:58:57 -08:00
Xi Ge
c585fd6748 ABIChecker: contains only opaque accessors for ABI/API checking
rdar://53776566
2020-02-24 12:23:03 -08:00
Joe Groff
b5c150287a SILGen: +1 function when converting for a reabstraction 2020-02-24 12:14:21 -08:00
Joe Groff
bdece4bae5 OSLogOptimization: Codegen array elements according to the correct maximally-abstracted element type 2020-02-24 12:14:21 -08:00
Joe Groff
7de3ab1406 Include full derived method signature and class in OverrideSignatureKey, because we get invalid collisions otherwise 2020-02-24 12:14:21 -08:00
Joe Groff
2b86330c2b SILGenPoly: Apply trivial argument conversions to return values too 2020-02-24 12:14:21 -08:00
Joe Groff
1b16cd42d3 SIL type lowering: Rearrange assertion so it won't fire on generic subclass overrides 2020-02-24 12:14:21 -08:00
Joe Groff
2b674c317f IsBindableVisitor: Preserve ExtInfo on function types 2020-02-24 12:14:21 -08:00
Joe Groff
cf0e09d9c5 Preserve conformances for upper bound constraints when lowering SILFunctionTypes 2020-02-24 12:14:21 -08:00
Joe Groff
9afd8f0e4e LoadableByAddress: Apply substitutions for indirect returns 2020-02-24 12:14:21 -08:00
Joe Groff
21f7dfa96e Fix some IsBindableVisitor problems with binding class-constrained archetypes to type parameters. 2020-02-24 12:14:21 -08:00
Joe Groff
31a9c8daef Fix IsBindableVisitor with nested BoundGenericTypes not to redundantly collect the parent parameters 2020-02-24 12:14:21 -08:00
Joe Groff
eecc2173d2 Bump module format version 2020-02-24 12:14:21 -08:00
Joe Groff
107686ecb7 SILGen: Handle function conversions in reabstraction thunks 2020-02-24 12:14:21 -08:00
Joe Groff
19770e6471 IRGen: Keep substituted function types out of debug info for now. 2020-02-24 12:14:21 -08:00
Joe Groff
cb9cfc3903 Map substitutions into context when resolving parsed SILFunctionTypes 2020-02-24 12:14:21 -08:00
Joe Groff
9e98dc1ef0 ConstExpr evaluator: Look through substitution-only convert_function insns 2020-02-24 12:14:21 -08:00
Joe Groff
7291cf891d MandatoryInlining: Recognize substitution-only convert_function patterns 2020-02-24 12:14:21 -08:00
Joe Groff
f0fc78753e ClosureLifetimeFixup: Recognize substitution-only convert_function patterns 2020-02-24 12:14:21 -08:00
Joe Groff
45e941c23a SILGen: Apply substitutions before bridging or thunking.
Even if differently-substituted function types have different value representations,
we can still share reabstraction and bridging thunks among types that are equivalent after
substitution, so handle these by generating thunks in terms of the unsubstituted type and
converting to the needed substitution form at the use site.
2020-02-24 12:14:21 -08:00
Joe Groff
da1382886d Don't consider different C function types to be different representation
This should eventually consider how Clang signs different function pointer types,
but for now, this unblocks progress on targets without ptrauth.
2020-02-24 12:14:21 -08:00
Joe Groff
d7d0da1ff4 Verify YieldInst values against substituted function types 2020-02-24 12:14:21 -08:00
Joe Groff
cccef30a59 Drop substitutions from PartialApplyInst's result type if not needed 2020-02-24 12:14:21 -08:00
Joe Groff
306218b77e SIL TypeLowering: Work around imperfect getLayoutConstraint behavior
`GenericSignature::getLayoutConstraint` nor `ArchetypeType::getLayoutConstraint`
appear to reliably reflect implied layout constraints, so we can't use them
in `AbstractionPattern::getLayoutConstraint` for that purpose. The only effective
layout constraint here is class-ness, though, and `requiresClass`, which does
work reliably, satisfies that need for now.
2020-02-24 12:14:21 -08:00
Joe Groff
79a8081a96 LoadableByAddress: Handle substituted SILFunctionTypes 2020-02-24 12:14:21 -08:00
Joe Groff
35560321b7 IRGen: Eliminate SILFunctionType substitutions from reflection info
Until the reflection libraries understand them, maintain compatibility with the existing
representation.
2020-02-24 12:14:21 -08:00
Joe Groff
92cfb1f8f7 Add missing LayoutConstraint::dump implementation 2020-02-24 12:14:21 -08:00