Commit Graph

11193 Commits

Author SHA1 Message Date
Michael Gottesman
4bb2e4f3b1 [region-isolation] Improve the error we emit for closure literals captured as a sending parameter.
Specifically:

I changed the main error message to focus on the closure and that the closure
is being accessed concurrently.

If we find that we captured a value that is the actual isolation source, we
emit that the capture is actually actor isolated.

If the captured value is in the same region as the isolated value but is not
isolated, we instead say that the value is accessible from *-isolated code or
code within the current task.

If we find multiple captures and we do not which is the actual value that was
in the same region before we formed the partial apply, we just emit a note on
the captures saying that the closure captures the value.

I changed the diagnostics from using the phrase "task-isolated" to use some
variant of accessible to code in the current task.

The idea is that in all situations we provide a breadcrumb that the user can
start investigating rather than just saying that the closure is "task-isolated".

From a preconcurrency perspective, I made it so that we apply the preconcurrency
behavior of all of the captures. This means that if one of the captures is
preconcurrency, we apply the preconcurrency restriction to the closure. This is
one step towards making it so that preconcurrency applies at the region level...
we just are not completely there yet.

rdar://133798044
2024-08-14 10:37:31 -07:00
swift-ci
e545ba00b7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-14 00:55:30 -07:00
Meghana Gupta
49bb19d27e Fix debug info in LICM
Use RegularLocation::getAutoGeneratedLocation() while hoisting a load.
Previously the source location of the preheader's terminator was used,
this need not be a RegularLocationKind triggering verification errors.
2024-08-14 01:49:58 +05:30
swift-ci
88e671860c Merge remote-tracking branch 'origin/main' into rebranch 2024-08-12 23:33:59 -07:00
Kuba (Brecka) Mracek
2941f24da3 Merge pull request #75308 from kubamracek/embedded-indexing-non-wmo
[embedded] Don't produce PerfDiags when in non-WMO mode (e.g. when building during indexing)
2024-08-12 23:29:30 -07:00
swift-ci
370a0b4ecf Merge remote-tracking branch 'origin/main' into rebranch 2024-08-12 15:14:17 -07:00
Michael Gottesman
fd863f90e8 Merge pull request #75841 from gottesmm/pr-4c4ea8453f92202322e4254fa1156e77a0716bc3
[region-isolation] Improve debug logging
2024-08-12 15:04:39 -07:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Michael Gottesman
8a20df1c44 [region-isolation] When dumping send never-sendable errors, dump the isolated value and its name if we can compute it.
This just makes it quicker/easier to diagnose inability to infer the appropriate
name of an isolated value and what the isolated value itself is.
2024-08-12 11:35:57 -07:00
Michael Gottesman
2535ef0c87 [region-isolation] When dumping info for send never sendable, dump the full one line logging of the isolation instead of just the diagnostics. 2024-08-12 11:35:57 -07:00
swift-ci
6cd717acec Merge remote-tracking branch 'origin/main' into rebranch 2024-08-12 10:35:39 -07:00
Erik Eckstein
1dab2942df Optimizer: enable the DeinitDevirtualizer pass
It was disabled so far to not hide bugs in the deinit code generation. Now hopefully deinit code generation is stable enough to enable the pass.
2024-08-12 13:34:51 +02:00
Erik Eckstein
65adc5a582 FunctionSignatureOpts: don't convert non-copyable owned -> guaranteed arguments
It's not safe to insert a compensating release_value at the call site.
This release_value calls the deinit which might have been already de-virtualized in the callee.
2024-08-12 08:54:22 +02:00
Kuba Mracek
80056c15cd [embedded] Explicitly disable PerfDiags from SourceKit instead of always disabling when WMO is off 2024-08-10 14:50:22 -07:00
Kuba Mracek
3ad777b942 [embedded] Don't produce PerfDiags when in non-WMO mode (e.g. when building during indexing) 2024-08-10 14:48:24 -07:00
swift-ci
e7794ef4e4 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-09 23:13:57 -07:00
Meghana Gupta
920c5603fc Merge pull request #75807 from meg-gupta/fixdebuginfodoe
Fix debug info in DeadObjectElimination in OSSA
2024-08-10 11:28:43 +05:30
Ben Barham
467e528200 Merge remote-tracking branch 'origin/main' into manual-rebranch-merge
Conflicts:
  - `lib/Serialization/ModuleFormat.h` bumped version to account for
    differences between main and rebranch.
2024-08-09 15:22:39 -07:00
Michael Gottesman
226e97a5a6 [region-isolation] Clean up some code now that SILBasicBlock::{dump,print}ID are in front of NDEBUG. 2024-08-09 11:10:37 -07:00
Meghana Gupta
f71ab17e7a Fix debug info in DeadObjectElimination in OSSA
Move debug_value insertion before destroy_value insertion.
2024-08-09 22:39:38 +05:30
Slava Pestov
b2ff3c9fa8 SILOptimizer: Clean up emitDistributedActorSystemWitnessCall() 2024-08-08 23:35:58 -04:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
swift-ci
43bd40f4d7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-08 19:11:05 -07:00
Andrew Savonichev
5aa9d3e29b Add partial_apply support for coroutines (#71653)
The patch adds lowering of partial_apply instructions for coroutines.

This pattern seems to trigger a lot of type mismatch errors in IRGen, because
coroutine functions are not substituted in the same way as regular functions
(see the patch 07f03bd2 "Use pattern substitutions to consistently abstract
yields" for more details). 

Other than that, lowering of partial_apply for coroutines is straightforward: we
generate another coroutine that captures arguments passed to the partial_apply
instructions. It calls the original coroutine for yields (first return) and
yields the resulting values. Then it calls the original function's continuation
for return or unwind, and forwards them to the caller as well.

After IRGen, LLVM's Coroutine pass transforms the generated coroutine (along with
all other coroutines) and eliminates llvm.coro.* intrinsics. LIT tests check
LLVM IR after this transformation.

Co-authored-by: Anton Korobeynikov <anton@korobeynikov.info>
Co-authored-by: Arnold Schwaighofer <aschwaighofer@apple.com>
2024-08-08 18:36:42 -07:00
swift-ci
517c5a6397 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 23:15:10 -07:00
eeckstein
f51cdf76e1 Merge pull request #75755 from eeckstein/borrowed-from-verification
Fix a the borrowed-from verifier and fix a few passes which caused a verifier error
2024-08-08 08:09:45 +02:00
swift-ci
7525555b15 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 19:55:01 -07:00
Michael Gottesman
2dd1ef2322 Merge pull request #75759 from gottesmm/variable-name-utils-refactor
[variable-name-utils] Change internal representation to use StringRef instead of a SILValue
2024-08-07 19:37:46 -07:00
swift-ci
5e74c499bf Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 16:55:20 -07:00
Michael Gottesman
d263bf0b41 Merge pull request #75760 from gottesmm/pr-d43ef71ddf97306ef50962d71b306ca6b7ce0b3d
[region-isolation] Make logging and debug tooling appear in non-asserts builds.
2024-08-07 16:40:29 -07:00
swift-ci
5be82afce7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 16:34:44 -07:00
Michael Gottesman
1fbc930cdd [region-isolation] Make logging and debug tooling appear in non-asserts builds.
This will just help me to more quickly triage without needing to compile an
asserts compiler.
2024-08-07 13:35:18 -07:00
Michael Gottesman
0039b286b5 [variable-name-inference] Eliminate the old value representation and just use StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
98fd04c3cd [variable-name-utils] Convert function_ref and method_inst to use the new StringRef form 2024-08-07 13:14:50 -07:00
Michael Gottesman
aa5db257ce [variable-name-utils] Move destructure and function arg to the new string ref representation. 2024-08-07 13:14:50 -07:00
Michael Gottesman
63b67389b0 [variable-name-utils] Convert all DebugVarCarryingInst|VarDeclCarryingInst to the new representation of storing a StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
76f67cf092 [variable-name-utils] Convert all gep like instructions except ref_element_addr to be put on the stack as StringRefs instead of values. 2024-08-07 13:14:50 -07:00
Michael Gottesman
765d3ba039 [variable-name-utils] Convert debug_value to StringRef form.
Just doing the refactoring.
2024-08-07 13:14:50 -07:00
Michael Gottesman
3d85f47671 [variable-name-utils] Store a std::variant instead of a pointer union and add the ability to append StringRef.
CONTEXT: This code works by building up a stack of SIL values of values that
need to be transformed into a StringRef as part of generating our name path and
then as a second phase performs the conversion of those values to StringRef as
we pop from the stack.

This is the first in a string of commits that are going to refactor
VariableNameUtils so that the stack will only contain StringRef instead of SIL
entities. This will be accomplished by moving the SIL value -> StringRef code
from the combining part of the algorithm (where we drain the stack) to the
construction of the stack.

The reason why I am doing this is two fold:

1. By just storing StringRef into the stack I am simplifying the code. Today as
mentioned above in the context, we gather up the SILValue we want to process and
then just convert them to StringRef. This means that any time one has to add a
new instruction, one has to update two different pieces of code. By trafficking
in StringRef instead, one only has to update one piece of code.

2. I want to add some simple code that allows for us to get names from closures
which would require me to recurse. I am nervous about putting
values/instructions from different functions in the same data structure. Today
it is safe, but it is bad practice. Instead, by just using StringRef in the
stack, I can avoid this problem.
2024-08-07 13:14:50 -07:00
Michael Gottesman
2e138024a8 [variable-name-utils] Look through convert function when finding names. 2024-08-07 13:10:54 -07:00
Erik Eckstein
80a0da9615 Optimizer: update borrowed-from instructions in some passes
Fixes verifier crashes (once the borrowed-from verifier is fixed).
2024-08-07 18:02:38 +02:00
Ben Barham
7bdf1e117e Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp` not positive
    what the cause here was, just took main.
2024-08-06 13:44:27 -07:00
Holly Borla
0ccbc7b4e6 Merge pull request #75705 from hborla/isolated-property-init-note
[Concurrency] Emit a better note when an isolated stored property initializer cannot be used.
2024-08-06 06:54:43 -07:00
Holly Borla
34cc7ea081 [Concurrency] Emit a better note when an isolated stored property initializer
cannot be used in an init with mismatching isolation.
2024-08-05 18:38:44 -07:00
swift-ci
d928d906eb Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 15:16:22 -07:00
Michael Gottesman
9c4da1ffb6 Merge pull request #75597 from gottesmm/incremental-diagnostics
[region-isolation] Incremental diagnostic updates
2024-08-02 15:10:34 -07:00
Ben Barham
3a4c1b8d51 Merge pull request #75633 from bnbarham/final-rebranch-pass
Changes to compile on macOS for stable/20240723 LLVM
2024-08-01 16:28:51 -07:00
swift-ci
bedbd0e7d2 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-31 20:15:20 -07:00
Michael Gottesman
e945c55c97 Merge pull request #75605 from gottesmm/pr-d4066f062c015e630d51fe05140fe756391079a9
[region-isolation] Use a hard to use API correctly.
2024-07-31 20:03:01 -07:00
Michael Gottesman
7255281c1d [region-isolation] Use a hard to use API correctly.
Specifically, this API has some hard edges where instead of just returning an
invalid value to signal that we do not have self, we assert or return something
bogus. This commit just fixes our usage of that API to be correct.

rdar://132545626
2024-07-31 16:51:15 -07:00