Commit Graph

11224 Commits

Author SHA1 Message Date
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
swift-ci
fd033c4d93 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-31 13:19:04 -07:00
Michael Gottesman
e7e035f60c [region-isolation] Convert the transfer non sendable typed error to be a new short-error, long-note form error.
I also messed with the text a little bit.

This eliminates the last of the old style diagnostics.
2024-07-31 13:10:02 -07:00
Michael Gottesman
359ae52cc3 [region-isolation] Move from old style to new style the typed error for passing never sendable types as a sending parameter. 2024-07-31 13:10:02 -07:00
Michael Gottesman
46b2224123 [region-isolation] Add .highlight to a few diagnostics that I missed.
Just trying to be standardized about this.
2024-07-31 13:10:02 -07:00
Michael Gottesman
c7d24e0003 [region-isolation] Convert the typed strongly transferred value diagnostic into a short error, longer note diagnostic.
Just finishing these diagnostics.
2024-07-31 13:10:02 -07:00
Michael Gottesman
2febd26861 [region-isolation] Convert emitTypedIsolationCrossingDueToCapture error to use a new form of error.
NOTE: To make testing these easier (since they are fallback paths), I
added an option that disables named errors only for use in asserts.
2024-07-31 13:10:02 -07:00
Michael Gottesman
bfdbc760cf [region-isolation] Convert UseAfterTransfer's typed isolation transfer error to the split small error/large note format we are standardizing on.
I also cleaned up the diagnostic a little bit.
2024-07-31 13:10:02 -07:00
Michael Gottesman
4713880ae8 [region-isolation] Add the ability to force the diagnostic emitter to emit typed diagnostics instead of named diagnostics.
We only use typed diagnostics if we are unable to pattern match a name for a
SILValue. Since we generally do this (in most of our tests we do for instance),
it is hard to test this. So I put in an option here that is enabled only in
asserts that forces the diagnostic emitter to emit the typed diagnostic by
forcing a name inference failure. This then allows me to write an asserts only
test that validates the behavior of the typed diagnostics since I can guarantee
the typed diagnostics will run.
2024-07-31 13:10:01 -07:00
Michael Gottesman
4e71e3248e [region-isolation] Delete an unused old form diagnostic. 2024-07-31 13:10:01 -07:00
Michael Gottesman
a75501e985 [region-isolation] Eliminate the last non-SIL test case usage of SILIsolationInfo::getWithIsolationCrossing().
The reason that I am changing this code is that getWithIsolationCrossing is a
bad API that was being used to infer actor isolation straight from an ApplyExpr
without adding an actor instance. This can cause us to reject programs
unnecessarily if we in other parts of the code correctly infer the SILValue
actor instance for the isolation.

Rather than allow for that, I am removing this code and I improved the rest of
the pattern matching here to ensure that we handled that with the normal actor
instance inferring code. This will prevent this type of mismerge from happening
by mistake. I fixed up the changes in the test cases.

The only usage of this left is for ApplyIsolationCrossings parsed straight from
SIL that we use only when testing. This is safe since if a test writer is using
the parsed SIL in this manner, they can make sure that mismerges do not happen.
2024-07-31 13:10:01 -07:00
Michael Gottesman
541863dbc6 [region-isolation] Fix handling of coroutine apply results.
In this part of the code, we are attempting to merge all of the operands into
the same region and then assigning all non-Sendable results of the function to
that same region. The problem that was occuring here was a thinko due to the
control flow of the code here not separating nicely the case of whether or not
we had operands or not. Previously this did not matter, since we just used the
first result in such a case... but since we changed to assign to the first
operand element in some cases, it matters now. To fix this, I split the confused
logic into two different easy to follow control paths... one if we have operands
and one where we do not have an operand. In the case where we have a first
operand, we merge our elements into its region. If we do not have any operands,
then we just perform one large region assign fresh.

This was not exposed by code that used non-coroutines since in SIL only
coroutines today have multiple results.

rdar://132767643
2024-07-31 09:37:42 -07:00
Ben Barham
64579adf24 [SILOpt] Rename GetUndefVal to GetPoisonVal
This function was renamed in upstream LLVM.
2024-07-31 08:57:02 -07:00
swift-ci
b485d7f708 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-31 05:17:38 -07:00
eeckstein
d5f95c354e Merge pull request #75565 from eeckstein/fix-keypath-folding
Optimizer: fix a crash in keypath folding
2024-07-31 14:06:00 +02:00
swift-ci
000d7b0a4a Merge remote-tracking branch 'origin/main' into rebranch 2024-07-30 11:16:40 -07:00
Joe Groff
d37ff048aa Merge pull request #75560 from jckarter/disable-consuming-self-in-deinit
Disallow consuming `self` in a noncopyable `deinit` again.
2024-07-30 10:59:35 -07:00
Erik Eckstein
9d6643b07e Optimizer: fix a crash in keypath folding
The KeyPathProjector utility crashed for keypaths  to stored objectiveC properties.

rdar://132780588
2024-07-30 16:59:31 +02:00
swift-ci
74c720b622 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-29 22:34:22 -07:00
eeckstein
8189840e95 Merge pull request #75505 from eeckstein/alias-analysis
AliasAnalysis: a complete overhaul of alias- and memory-behavior analysis
2024-07-30 07:32:22 +02:00