Commit Graph

23 Commits

Author SHA1 Message Date
Joe Groff
69e4b95fb8 SIL: Model noescape partial_applys with ownership in OSSA.
Although nonescaping closures are representationally trivial pointers to their
on-stack context, it is useful to model them as borrowing their captures, which
allows for checking correct use of move-only values across the closure, and
lets us model the lifetime dependence between a closure and its captures without
an ad-hoc web of `mark_dependence` instructions.

During ownership elimination, We eliminate copy/destroy_value instructions and
end the partial_apply's lifetime with an explicit dealloc_stack as before,
for compatibility with existing IRGen and non-OSSA aware passes.
2023-02-16 21:43:53 -08:00
Nate Chandler
6bb18263d1 [Test] Adjusted SIL tests.
Now that
- owned arguments don't get lexical borrow scopes from SILGen
- owned arguments get lexical moves during inlining unless the value
  passed for that argument is already lexical
- guaranteed arguments don't get lexical borrow scopes during inlining
  when the value passed for that argument is already lexical
tests involving owned argument emission from SILGen and inlining need to
be updated.
2023-01-25 11:36:33 -08:00
Nate Chandler
ed623d7b64 [NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init]
everywhere.
2022-10-27 10:38:54 -07:00
Hamish Knight
8bc80c146a [SILGen] Avoid delaying functions with user-written code
Previously we would delay the emission of
lazy variable getters and stored property
initializers for property wrapper backing storage.
This could lead to their definitions being dropped
if unused, meaning that we wouldn't run the
mandatory diagnostics passes over them.

Fix the logic such that we consider such cases as
having user-written code, and account for a couple
of cases where we can delay emission where we
didn't previously. There are more cases we can
handle here, but I'm leaving that as future work
for now, as `emitOrDelayFunction` is currently
only used for a handful of SILDeclRef kinds.

This is a source breaking change, but only for
invalid (albeit unused) code.

rdar://99962285
2022-09-28 16:11:12 +01:00
Hamish Knight
28aec55bb8 [SIL] Fix linkage of external property wrapper backing initializers
This should be based on the access level of the
function they're attached to.

rdar://100240367
2022-09-27 11:13:20 +01:00
Michael Gottesman
785153045b [move-operator] Start having SILGen emit lexical lifetimes and teach the optimizer how to maintain lexical lifetimes until the lexical lifetime elimination.
I am doing this so that I can use lexical lifetimes to emit diagnostics such as
the move operator diagnostics.
2021-11-29 18:02:13 -08:00
Holly Borla
85891c9b9f [Test] Add tests for wrapped parameters in initializers. 2021-08-12 13:56:06 -07:00
Holly Borla
fb0121ea60 [SILGen] Emit property wrapper generator functions in the same place
as default argument generator functions.
2021-08-12 13:56:05 -07:00
Holly Borla
39c8eb43b6 [Test] Add tests for wrapped argument coercions. 2021-08-05 15:39:51 -04:00
Holly Borla
e6fe68f77a [SILGen] Account for transitive captures of generic parameters when computing
the generic signature for local property wrapper and default argument
generators.
2021-07-09 22:18:26 -07:00
Holly Borla
b5e525480d [SILGen] For property wrapper generators, don't use the generic signature of
the enclosing context if the property wrapper is declared in a closure that
does not capture any generic parameters.

In this case, the enclosing closure won't have a generic signature, nor any
substitutions to forward when calling the property wrapper generator, which
previously caused an assertion failure when emitting the call because there
were no substitutions to use.
2021-07-09 12:45:32 -07:00
Holly Borla
6c9f8e92e2 [SILGen] When collecting transitive captures of local computed property
accessors, use synthesized accessors for wrapped and projected properties.
2021-05-17 13:43:22 -07:00
Holly Borla
833a453c8a Merge pull request #37301 from hborla/wrapped-parameter-miscompile
[SILGen] Fix a miscompile when emitting the application of a wrapped parameter
2021-05-07 12:44:38 -07:00
Holly Borla
0999deac07 [SILGen] Don't pass down the context when emitting the r-value of the wrapped
or projected value in RValueEmitter::visitAppliedPropertyWrapperExpr
2021-05-07 08:51:47 -07:00
Holly Borla
d8b5d7d51d [Property Wrapper] For a wrapped parameter that is implementation detail,
make the backing stroage a let-constant.
2021-04-29 12:33:15 -07:00
Holly Borla
2a4cc912b6 [Property Wrappers] Fix accessor synthesis of wrapped parameters that infer
the property wrapper attribute.
2021-03-31 18:38:41 -07:00
Holly Borla
833a665027 [Property Wrappers] Correct the source location of applied property
wrapper expressions in property wrapper parameter thunks, and add
SILGen tests for property wrapper parameters in inlinable functions.
2021-03-31 09:29:46 -07:00
Holly Borla
a15f4233a2 [Property Wrappers] Implement implementation-detail property wrappers for
parameters.
2021-03-31 09:29:46 -07:00
Holly Borla
c39d6fd0c5 [Property Wrappers] Invert the dependency between PropertyWrapperBackingPropertyTypeRequest
and PropertyWrapperAuxiliaryVariablesRequest.

Because closure parameter types are inferred in the constraint system, auxiliary
variables must be synthesized before the property wrapper type is resolved for
single-expression closures.
2021-03-19 13:03:14 -07:00
Holly Borla
c29eecd0b6 [Property Wrappers] Store the callee in AppliedPropertyWrapperExpr to use
the correct substitution map when emitting the property wrapper generator
application in SILGen.
2021-02-25 18:35:14 -08:00
Holly Borla
bea89c6a95 [SILGen] Serialize and give PublicNonABI linkage to property wrapper
generator functions for parameters of public functions.
2021-02-25 18:35:14 -08:00
Holly Borla
99e066683c [ConstraintSystem] Inject implicit applied property wrapper expressions
around arguments to property wrapper parameters.
2021-02-25 18:35:14 -08:00
Holly Borla
e40d7ebe15 [NFC][Property Wrappers] Start to add SILGen tests for SE-0293. 2021-02-25 18:35:14 -08:00