Commit Graph

9594 Commits

Author SHA1 Message Date
Slava Pestov
db60caecc0 Merge pull request #71441 from slavapestov/specializer-loop-rdar121867690
SILOptimizer: Fancier 'too complex' check to prevent runaway specialization
2024-02-08 13:54:23 -05:00
Slava Pestov
f79b621ad5 SILOptimizer: Fancier 'too complex' check to prevent runaway specialization
We weren't looking at the length of an opaque archetype's type parameter,
which could lead to unbounded growth in the number of emitted specializations.

Fixes rdar://problem/121867690.
2024-02-08 09:54:25 -05:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
John McCall
60807a76a4 Merge pull request #71433 from rjmccall/isolated-any-typechecking
Experimental type-checking support for `@isolated(any)` function types.
2024-02-07 14:07:53 -05:00
Michael Gottesman
1795f7f661 Merge pull request #71429 from gottesmm/fixes-for-stdlib
[region-isolation] Fixes that enable the stdlib to build with region based isolation
2024-02-07 09:47:11 -08:00
Kuba (Brecka) Mracek
802aab80a0 Merge pull request #71415 from kubamracek/vtable-specialize-print-types
[embedded] Print function name + class name when missing loc in 'non-final generic fuctions' diagnostic
2024-02-07 07:14:04 -08:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
nate-chandler
01bce39100 Merge pull request #71418 from nate-chandler/nfc/20240206/1/rename-inst-class
[NFC] SIL: Renamed SpecifyTestInst.
2024-02-06 22:02:05 -08:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Michael Gottesman
1e4fe6c4ea [region-isolation] Do not transfer @out parameters!
Instead treat them as actual results.
2024-02-06 18:14:34 -08:00
Michael Gottesman
501158450e [region-isolation] Handle (project_box (load %boxAddr)) correctly.
I thought that we would never actually hit this test case, but since we do not
have opaque values this pattern is treated like a projection in certain cases. I
updated the code as appropriate and added a test.
2024-02-06 18:05:05 -08:00
Michael Gottesman
6200a3bc4c [region-isolation] Fix a thinko.
project_box's type is not a box type... it is the type contained in the box.
2024-02-06 17:49:58 -08:00
Michael Gottesman
b2f1c41213 [region-isolation] get_async_continuation{,_addr} can take a parameter, so we need to treat it as a require.
We should make this as a transfer... but this is just temporary until I get
around to it. For now this is always an out parameter, so we should be safe.
2024-02-06 17:49:03 -08:00
Michael Gottesman
e34dc59cea [region-isolation] When asserting about a bad inst, print the inst out to ease debugging. 2024-02-06 16:57:47 -08:00
Michael Gottesman
dd7f5ec11d [region-isolation] Handle ref_to_bridge_object especially.
I was correct that it is lookthrough, but it has multiple parameters, so the
normal "baked" implementation cannot be used since the "baked" implementation
assumes that any insts it handles has a single operand.
2024-02-06 16:57:34 -08:00
Michael Gottesman
d4f727adde [region-isolation] Add support for identifying names when a temporary is initialized with a store. 2024-02-06 16:49:30 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Michael Gottesman
7df13b3c1f [sil] Refactor VariableNameUtils for handling more kinds of writes to temporaries. 2024-02-06 16:18:34 -08:00
Ellie Shin
e38bc9756c Merge pull request #71083 from apple/es-sil-pkg
Support a package SILLinkage
2024-02-07 09:10:13 +09:00
Michael Gottesman
2010579b02 [sil] Add basic test support for variable name inference. 2024-02-06 15:21:11 -08:00
Michael Gottesman
fef1b5e3df [region-isolation] Use VariableNameUtils to emit name diagnostics when possible.
A name diagnostic looks as follows:

Some notes:

1. VariableNameUtils still doesn't pattern match all cases. In the cases where
we fail to pattern match, I fall back to the old diagnostics. I am going to be
adding tests/etc specific to VariableNameUtils in a later patch.

2. I took this as an opportunity to begin preparing to change the diagnostics
into diags of the following form:

a. The main diagnostic is changed to something short "transferring non-Sendable
%0 could yield races with later accesses".

b. I added a longer note at the same location that explains that our caller is
in a specific isolation domain and our callee is isolated differently.

c. I added a note on the definition location of the identified value.
2024-02-06 13:42:35 -08:00
Michael Gottesman
a569160f21 [sil] Refactor out the variable name inferer from MoveOnlyDiagnostics.cpp -> VariableNameUtils.
I am going to reuse this for TransferNonSendable. In the process I made a few
changes to make it more amenable to both use cases and used the current set of
tests that we have for noncopyable types to validate that I didn't break
anything.
2024-02-06 13:42:35 -08:00
Kuba Mracek
d9624abc81 [embedded] Print function name + class name when missing loc in 'non-final generic fuctions' diagnostic 2024-02-06 11:20:25 -08:00
Joe Groff
2092240072 Merge pull request #71406 from jckarter/borrowing-switch-5
SILGen: Emit borrowing switch subjects under a formal access.
2024-02-06 08:12:32 -08:00
nate-chandler
f98b211f18 Merge pull request #71403 from nate-chandler/delete-flag
[Frontend] Removed enable-lexical-borrow-scopes flag.
2024-02-06 07:00:25 -08:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Joe Groff
2f519f42c6 SILGen: Emit borrowing switch subjects under a formal access.
Ensure that dependent accesses are properly nested when a subject isn't directly
a borrowed parameter binding.
2024-02-05 19:39:10 -08:00
Nate Chandler
336afca477 [SILOpt] Removed unreachable bailouts.
Now that supportsMoveOnlyTypes is always true, these bailouts can't be
reached.  Delete the bailouts and the predicate.
2024-02-05 17:40:17 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Anton Korobeynikov
f5cce4784f Make autdiff more robust in presence of unreachable blocks (#71356)
Unreachable blocks possess some challenges to autodiff since in reverse pass (pullback generation) we need to execute the function backwards, pushing the values from return BB back to entry block. As a result, unreachable blocks might become reachable from the return BB and this might cause all kind of issues.
2024-02-03 08:33:36 -08:00
Michael Gottesman
4bed671820 [region-isolation] Now that we support all instructions, remove Unhandled... all future instructions added must be handled! 2024-02-02 14:50:10 -08:00
Michael Gottesman
7d13d27685 [region-isolation] Add support for init_existential_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
9b686f564f [region-isolation] Add support for strong_copy_unmanaged_value.
I also made ref_to_unmanaged and unmanaged_to_ref look through. They should have
always been look through, but I believe early on they were marked assign and I
never touched fixed it. To get the test for strong_copy_unmanaged_value to work,
I needed them to obey these semantics so I fixed them at the same time.
2024-02-02 14:50:10 -08:00
Michael Gottesman
40c1120a6e [region-isolation] Add support for strong_copy_weak_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
7d4f8c261a [region-isolation] Add support for weak_copy_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
ab3204b610 [region-isolation] Add support for metatype instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
34dcb8d48c [region-isolation] Add support for load_unowned. 2024-02-02 14:50:10 -08:00
Michael Gottesman
62c6ed2c77 [region-isolation] Add support for open_existential_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4bba1942b1 [region-isolation] Add support for differentiability instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
347310835a [region-isolation] Make vector asserting since we should never see it.
It can only be in a global variable static initializer list which we do not run
on.
2024-02-02 14:50:10 -08:00
Michael Gottesman
e42b112f53 [region-isolation] Add support for {begin,end}_unpaired_access. 2024-02-02 14:50:10 -08:00
Michael Gottesman
12e4e8d6e8 [region-isolation] Add support for all pack instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
feec25cb05 [region-isolation] Mark get_async_continuation{,addr} and extract_executor as AssertingIfNonSendable. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4414636f5f [region-isolation] Add support for bind_memory and rebind_memory. 2024-02-02 14:50:10 -08:00
Michael Gottesman
62a64d3b37 [region-isolation] Update for throw_addr.' 2024-02-02 14:50:10 -08:00
Michael Gottesman
45bb16764e [region-isolation] Add support for await_async_continuation. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4218f5b79d [region-isolation] Teach the checker about unmanaged {retain, release, autorelease}. 2024-02-02 14:50:10 -08:00
Michael Gottesman
0cfe58cca1 [region-isolation] Mark all assign_* variants as asserting since they should be eliminated by DI before we run. 2024-02-02 14:50:10 -08:00
Michael Gottesman
3cacb1f86d [region-isolation] Add support for mark_function_escape. 2024-02-02 14:50:10 -08:00
Michael Gottesman
e3274b34ad [region-isolation] Move unhandled pack instructions away from the rest of unhandled instructions. 2024-02-02 14:50:10 -08:00