Commit Graph

2601 Commits

Author SHA1 Message Date
Yuta Saito
7cccbcc84f [DiscardingTG] Remove reabstraction thunk for () -> Void to () -> T (#70537)
Concurrency runtime expects discarding task operation entrypoint
function not to have result type, but the current SILGen
implementation generates reabstraction thunk to convert `() -> Void`
to `() -> T` for the operation function.

Since the `T` is always `Void` for DiscardingTG, the mismatch of result
type expectation does not cause any problem on most platforms, but the
signature mismatch causes a problem on WebAssembly.

This patch introduces new builtin operations for creating discarding
task, which always takes `() -> Void` as the operation function type.
2024-01-10 07:17:15 +09:00
Meghana Gupta
79c8f5da2d Handle ossa instructions in SimplifyCFG
This can in turn trigger try_apply -> apply [nothrow] transformation.
2024-01-05 13:20:52 -08:00
Andrew Trick
264cbaea42 Add mark_dependence [nonescaping] flag.
The dependent 'value' may be marked 'nonescaping', which guarantees that the
lifetime dependence is statically enforceable. In this case, the compiler
must be able to follow all values forwarded from the dependent 'value', and
recognize all final (non-forwarded, non-escaping) use points. This implies
that `findPointerEscape` is false. A diagnostic pass checks that the
incoming SIL to verify that these use points are all initially within the
'base' lifetime. Regular 'mark_dependence' semantics ensure that
optimizations cannot violate the lifetime dependence after diagnostics.
2024-01-04 14:47:35 -08:00
Michael Gottesman
7712639ab0 [region-isolation] Add support for project_block_storage.
rdar://119743743
2023-12-18 09:35:57 -08:00
nate-chandler
680c737ddb Merge pull request #64789 from nate-chandler/more-move-values
[SILGen] Used move_value for more lexical values.
2023-12-15 07:07:54 -08:00
Nate Chandler
bb3dc295d4 [Gardening] Tweaked comment. 2023-12-14 13:35:26 -08:00
Meghana Gupta
d0de3a9c6c Merge pull request #70439 from meg-gupta/debugmsgs
[NFC] Add some debug logging to optimizer passes
2023-12-13 13:35:24 -08:00
Meghana Gupta
8cb2086c62 [NFC] Add debug msgs to inliner 2023-12-13 10:38:12 -08:00
Alejandro Alonso
f365316d74 Merge pull request #70327 from Azoy/inject-get-enum-tag-builtins
[IRGen] Add getEnumTag and injectEnumTag builtins
2023-12-12 16:07:56 -08:00
Konrad `ktoso` Malawski
828f589be4 Initial Task Executor implementation Task(on:), addTask(on:) etc. (#68793)
Co-authored-by: John McCall <rjmccall@gmail.com>
2023-12-12 17:14:24 +09:00
Alejandro Alonso
49b0a23561 Add getEnumTag and injectEnumTag builtins 2023-12-11 10:58:29 -08:00
Erik Eckstein
dd9ce40ba1 add the allocVector builtin 2023-12-09 18:49:57 +01:00
Meghana Gupta
86b651330b Revert "Merge pull request #69807 from apple/revert-69450-uninarrayfix"
This reverts commit cabb5e109f, reversing
changes made to 09688abb02.
2023-12-06 08:29:50 -08:00
Meghana Gupta
956acc1560 Merge pull request #70243 from meg-gupta/enableedgecase
Handle `unchecked_ref_cast` in ObjectOutliner
2023-12-05 23:46:55 -08:00
Meghana Gupta
d6439b60ff [NFC] Add some debugging messages to COWOpts 2023-12-05 12:49:36 -08:00
Erik Eckstein
0897d8a720 MemoryLifetimeVerifier: use CalleeCache instead of AliasAnalysis
To verify if a function may read from an indirect argument, don't use AliasAnalysis.
Instead use the CalleeCache to get the list of callees of an apply instruction.
Then use a simple call-back into the swift Function to check if a callee has any relevant memory effect set.

This avoids a dependency from SIL to the Optimizer.
It fixes a linker error when building some unit tests in debug.
2023-12-01 19:20:18 +01:00
Erik Eckstein
e80fedc52a move CalleeCache from SILOptimizer to SIL
Extract the CalleeCache from BasicCalleeAnalysis so that it can be used in SIL without BasicCalleeAnalysis
2023-12-01 19:20:18 +01:00
Dario Rexin
45d1e959a3 [SILOpt] Fix mutable state in EagerSpecializer (#70083)
* [SILOpt] Fix mutable state in EagerSpecializer

rdar://118554892

On the first occurance of a `@_specialize` attribute with `target:` argument, `onlyCreatePrespecializations` would be set to `true`, preventing any subsequent pre-specializations with `exported: false`

* Fix test on non-darwin platforms
2023-11-29 14:37:34 -08:00
eeckstein
67ebbee39e Merge pull request #69955 from eeckstein/deinit-devirtualizer
Optimizer: de-virtualize deinits of non-copyable types
2023-11-27 12:41:49 +01:00
Erik Eckstein
17f246e219 Remove the old MoveOnlyDeinitDevirtualization.cpp pass 2023-11-27 09:21:34 +01:00
Erik Eckstein
3ba935605e SimplifyCFG: fix try_apply -> apply transformation for indirect error results
Indirect error results must not be included in the final apply arguments which they are not present in the callee.
2023-11-27 08:51:12 +01:00
Nate Chandler
ae6868a296 [DCE] Process instructions added during deletion.
In cea0f00598, `InstructionDeleter` began
deleting `load [take]` instructions.  Analogous to how it creates a
`destroy_value` when deleting an instruction which consumes a value, in
the case of deleting a `load [take]` the `InstructionDeleter` inserts a
compensating `destroy_addr`.

Previously, `DeadCodeElimination` did not observe the creation of any
instructions created by the `InstructionDeleter`.  In the case of the
newly created `destroy_addr`, DCE didn't mark that the `destroy_addr`
was live and so deleted it.  The result was a leak.

Here, this is fixed by passing an `InstModCallbacks`--with an
`onCreateNewInst` implementation--down into `erasePhiArgument` that
eventually invokes the `InstructionDeleter`.  When the
`InstructionDeleter` creates a new instruction, DCE marks it live.
2023-11-15 15:03:24 -08:00
Doug Gregor
84a078b361 Teach the speculative devirtualize to deal with error basic blocks without args 2023-11-13 14:51:14 -08:00
Mishal Shah
e8de333daf Revert "Add a mark_dependence while emitting SIL for uninitialized array allocation " 2023-11-12 09:43:13 -08:00
Kuba Mracek
afced311f9 [embedded] Fix class_method devirtualizer to consider specialized VTables 2023-11-06 17:08:12 -08:00
Erik Eckstein
d6e86a8cd4 Fix specialization of class method calls in embedded swift.
Unlike in regular swift, The class_method instruction references the specialized version of a class method.
This must be handled in ReabstractionInfo: it needs to work without a concrete callee SIL function.

Also, the SILVerifier must handle the case that a class_method instruction references a specialized method.
2023-11-06 21:08:22 +01:00
Doug Gregor
53c8e84a1f [Typed throws] Handle throw_addr in the same places as throw. 2023-11-03 19:02:58 -07:00
swift-ci
6532b23b3e Merge pull request #69591 from kavon/noncopyable-generics-pt3
[NoncopyableGenerics] Basic end-to-end testing (without stdlib).
2023-11-03 13:06:43 -07:00
Meghana Gupta
192bb2eed2 Merge pull request #69450 from meg-gupta/uninarrayfix
Add a mark_dependence while emitting SIL for uninitialized array allocation
2023-10-31 22:07:14 -07:00
Slava Pestov
05ccd9734c SIL: Introduce ThrowAddrInst 2023-10-31 16:58:54 -04:00
Meghana Gupta
0ac83f1f29 Remove dead alloc_ref after deleting allocating apply 2023-10-31 11:07:40 -07:00
Meghana Gupta
baebc7d00b Handle mark_dependence in Differentiation 2023-10-31 11:07:36 -07:00
Kavon Farvardin
70fe62cce9 [nfc] remove unnecessary overload 2023-10-28 23:57:09 -07:00
Meghana Gupta
50f88293be Handle mark_dependence in DeadObjectElimination 2023-10-27 14:19:21 -07:00
Meghana Gupta
7ea31e91e1 Handle mark_dependence in ArrayCountPropagation 2023-10-27 14:19:21 -07:00
Meghana Gupta
473905b6b2 Handle mark_dependence in ArrayElementPropagation 2023-10-27 14:19:21 -07:00
Kshitij
12e3a6ecfb [AutoDiff] Modify inlining logic to award inlining benefits to VJPs
Similar to #69029 but for VJPs.
2023-10-27 06:43:59 -10:00
Erik Eckstein
5b7cd4ef71 PerformanceInliner: favor inlining of co-routines
Not inlined co-routines are so expensive that they should be inlined, unless they are really large.
So far co-routines didn't get any special treatment in the inliner, except generic co-routines.
With this change, even non-generic co-routines are treated as high-priority to inline.

rdar://117201823
2023-10-24 10:36:19 +02:00
swift-ci
2361eae8e7 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 09:54:35 -07:00
eeckstein
0ada2e2cac Merge pull request #69029 from jkshtj/main
[Autodiff] Modify inliner logic to award inlining benefits to linear …
2023-10-12 18:38:25 +02:00
Kshitij
f973aa1423 [Autodiff] Modify inliner logic to award inlining benefits to linear maps w/ control-flow
For linear maps containing control-flow, closures (representing the pullbacks
of intermediate values) may be passed as arguments, however, they may be
hidden behind a branch-tracing enum (tracing execution flow of the original
function).

Such linear maps did not use to get inlining benefits as the compiler
could not see that the intermediate pullback closures were actually part
of the input.

This change modifies the inliner logic to correctly award inlining
benefits to linear maps containing control-flow, by checking if a
"callee" in the linear map actually traces back to an input closure that
was received as part of a branch-tracing enum input argument.

Fixes #68945
2023-10-08 14:37:13 -07:00
swift-ci
6cf1f90e79 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 04:35:13 -07:00
Tony Allevato
5f8466445a Merge pull request #68951 from allevato/const-equality
[C++20] Make `operator{==,!=}`s const.
2023-10-04 07:19:53 -04:00
swift-ci
fcd83ab7fc Merge remote-tracking branch 'origin/main' into rebranch 2023-10-03 22:58:16 -07:00
eeckstein
8e9ff9bfc6 Merge pull request #68903 from eeckstein/fix-templvalue-opt
TempLValue opt: don't insert destroy_addr too early due to ignoring deinit barriers
2023-10-04 07:46:27 +02:00
Tony Allevato
5f5b24f96e [C++20] Make operator{==,!=}s const.
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
swift-ci
556272e95f Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 21:54:26 -07:00
Nate Chandler
04e827fc57 [DestroyAddrHoisting] NFC: Added comment.
Explain why deinit barriers are not respected within mutable exclusive
access scopes.
2023-10-02 16:51:41 -07:00
Erik Eckstein
a14128a35a TempLValue opt: don't insert destroy_addr too early due to ignoring deinit barriers
This can happen for inout arguments. It fixes a potential miscompile, e.g. observable by a weak reference being nil where it shouldn't.

rdar://116335089
2023-10-02 14:56:59 +02:00
swift-ci
2e6b1cd2f7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 07:13:53 -07:00