Commit Graph

26 Commits

Author SHA1 Message Date
Pavel Yaskevich
1f7b76edd3 Merge pull request #77816 from xedin/fix-property-wrapper-projected-value-applies
[CSApply] Avoid shortcutting argument conversion when parameter has a…
2024-12-02 13:52:30 -08:00
Pavel Yaskevich
44908acd75 [CSApply] Avoid shortcutting argument conversion when parameter has an external property wrapper
The check to see whether argument matches the parameter exactly
causes two problems: prevents projected value initialized injection;
and, if there are multiple parameters with property wrappers,
would apply incorrect wrapper to other locations because the wrapper
application index wasn't incremented.

Resolves: rdar://140282980
2024-11-22 14:02:06 -08:00
Erik Eckstein
7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00
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