Commit Graph

11224 Commits

Author SHA1 Message Date
Michael Gottesman
0a06c00f47 [region-isolation] When determining isolation from a class_method, check for global actor isolation first.
Before this change in the following code, we would say that message is isolated to the actor instead of the global actor isolation of the actor's method:

```swift
class Message { ... }

actor MessageHolder {
  @MainActor func hold(_ message: Message) { ... }
}

@MainActor
func sendMessage() async {
    let messageHolder = MessageHolder()
    let message = Message()
    // We identified messageHolder.hold as being MessageHolder isolated
    // instead of main actor isolated.
    messageHolder.hold(message)
    Task { @MainActor in print(message) }
}
```

I also used this as an opportunity to simplify the logic in this part of the
code. Specifically, I had made it so that multiple interesting cases were
handled in the same conditional statement in a manner that it made it hard to
know which cases were actually being handled and why it was correct. Now I split
that into two separate if statements with comments that make it clear what we
are actually trying to pattern match against.

rdar://130980933
2024-07-06 23:01:21 -07:00
swift-ci
b7921a8232 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-06 14:34:09 -07:00
Slava Pestov
ca9c09f8a1 Remove some unused variables 2024-07-06 12:05:47 -04:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
3fcda140bb AST: ModuleDecl::checkConformance() is a static method 2024-07-06 12:05:46 -04:00
Slava Pestov
1901862afc AST: Remove LookUpConformanceInSignature 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
swift-ci
9ea0f99aa3 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 22:33:35 -07:00
Anton Korobeynikov
97ba96b8d8 [AutoDiff] Implement active Optional differentiation (#74977)
Fixes #74972
2024-07-04 22:27:23 -07:00
swift-ci
e650b133a7 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 21:13:51 -07:00
Anton Korobeynikov
f8141e27b1 Ensure we are materializing adjoint value into buffer correctly for optionals: (#74964)
- Ue enum $Optional<T.TangentVector>, #Optional.some!enumelt, %wrappedAdjoint : $T for objects
- Use inject_enum_addr %optArgBuf : $*Optional<T.TangentVector>, #Optional.some!enumelt for addresses

Fixes #74841
2024-07-04 20:53:59 -07:00
swift-ci
e072d4635c Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 20:53:57 -07:00
Anton Korobeynikov
080a82ba5f Ensure we emit strong_release only for scalar values inside emitDestroyOperation (#74965) 2024-07-04 20:52:10 -07:00
swift-ci
6a91e9b2b1 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 01:34:10 -07:00
Meghana Gupta
2d3d670e1a Merge pull request #74944 from meg-gupta/abcedgecase
Improve pattern matching range check in ArrayBoundsCheck optimizations
2024-07-04 01:17:51 -07:00
swift-ci
d33023fcdb Merge remote-tracking branch 'origin/main' into rebranch 2024-07-04 00:36:46 -07:00
nate-chandler
04debd3536 Merge pull request #74922 from nate-chandler/lifetime-completion/20240701/1
[LifetimeCompletion] Flag ends synthesized in dead-ends.
2024-07-04 00:23:57 -07:00
swift-ci
01f553dcd8 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-03 23:34:51 -07:00
eeckstein
46256f5cd7 Merge pull request #74897 from eeckstein/fix-vtable-specializer
Fix a SourceKitCrash in the VTableSpecializer pass
2024-07-04 08:16:30 +02:00
Nate Chandler
02c28f5de5 [AllocBoxToStack] Drop dead_end dealloc_boxes.
When creating `dealloc_stack`s corresponding to `dealloc_box`es, don't
bother to create a dealloc_stack if the `dealloc_box` is flagged
`dead_end`.
2024-07-03 17:33:51 -07:00
Nate Chandler
1d47d3ca0d [OME] Erase dead_end lifetime ends.
Such instructions are inserted to ensure complete OSSA lifetimes and
should be removed when lowering out of OSSA.
2024-07-03 16:44:35 -07:00
Nate Chandler
dd730b849c [LifetimeCompletion] Flag instructions dead_end. 2024-07-03 16:44:35 -07:00
Nate Chandler
365c1a0286 [Test] Provide dead-end blocks to SIL tests.
Via a new method on the dependencies struct.
2024-07-03 15:27:00 -07:00
Nate Chandler
91fe12aab4 [NFC] SIL: Typed debug_value.poisonRefs. 2024-07-03 14:53:30 -07:00
swift-ci
4420bc868d Merge remote-tracking branch 'origin/main' into rebranch 2024-07-03 10:55:51 -07:00
Meghana Gupta
aad321c566 Improve pattern matching range check in ArrayBoundsCheck optimizations
Current pattern matching misses when range checks are of the form:

%cond = %end < %start
cond_fail %cond, "Range requires lowerBound <= upperBound"

instead of
%cond =  (%start <= %end) ^ 1
cond_fail %cond, "Range requires lowerBound <= upperBound"
2024-07-03 10:39:15 -07:00
Erik Eckstein
9360c76cd8 Fix a SourceKitCrash in the VTableSpecializer pass
Replace the assert-check if a vtable is available with a regular error message.
This cannot occur in regular builds - only if built with embedded swift and without wmo.
The command line compiler prevents this combination, but it  can happen in SourceKit.

rdar://130167087
2024-07-03 17:13:53 +02:00
Erik Eckstein
3e750f9f1c SimplifyCFG: Fix a missing borrowed-from when doing jump threading
Fixes a compiler crash

rdar://129805179
2024-07-03 13:52:52 +02:00
swift-ci
ee787c823b Merge remote-tracking branch 'origin/main' into rebranch 2024-07-03 00:35:22 -07:00
swift-ci
39f5dccf41 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-02 22:15:01 -07:00
Ben Barham
888b32c964 Merge pull request #74923 from bnbarham/manually-merge-main-to-rebranch
Manually merge main to rebranch
2024-07-02 22:01:56 -07:00
Ben Barham
4c5284fd40 Merge pull request #74851 from bnbarham/rebranch-build-after-branch
[rebranch] Various changes to get rebranch compiling after taking new clang branch
2024-07-02 22:01:17 -07:00
Michael Gottesman
8770e90e43 Fix a thinko.
I was working on c20abe570d and
03bfadea60 at the same time and I forgot to update
to use the new API in 03bfadea60 before I commited
c20abe570d. Sorry!
2024-07-02 21:00:59 -07:00
Michael Gottesman
c20abe570d Merge pull request #74919 from gottesmm/pr-d8b24a45ff257893c8172491f11a617fc00d5589
[region-isolation] Implement support for 'inout sending' diagnostics.
2024-07-02 20:16:25 -07:00
Meghana Gupta
c2fd130fa2 Merge pull request #74795 from meg-gupta/copyelimexpand
Enable ClosureLifetimeFixup's capture copy elimination for copyable types as well.
2024-07-02 20:06:08 -07:00
Meghana Gupta
a470b04bbf [NFC] clang-format some parts of ClousreLifetimeFixup 2024-07-02 16:26:51 -07:00
Meghana Gupta
c895a9ba10 Add a flag to disable copy elimination of captures in ClosureLifetimeFixup 2024-07-02 16:25:38 -07:00
Meghana Gupta
98074a86c4 Enable copy elimination of captures for all types in ClosureLifetimeFixup
rdar://130026658
2024-07-02 16:25:34 -07:00
Michael Gottesman
6fe749626f [region-isolation] Add 'inout sending' diagnostics.
Specifically:

1. We error now if one transfers an 'inout sending' parameter and does not
reinitialize it before the end of the function.

2. We error now if one merges an 'inout sending' parameter into an actor
isolated region and do not reinitialize it with a non-actor isolated value
before the end of the function.

rdar://126303739
2024-07-02 16:21:44 -07:00
Michael Gottesman
5d4b93fa5d [region-isolation] Add a wrapper ADT for RequireInst SILInstructions so we can attach a Kind and propagate it.
The reason why I am doing this is that I am adding support for failing to
reinitialize an inout sending parameter that was transferred. To make it really
easy to do I am just going to explicitly represent this on the RequireInst and
let the decision on what diagnostic to be done to be represented in the
pseudo-IR instead of trying to just infer it straight from the type of require
inst. This keeps all of the logic in the same place and attempts to keep the
diagnostic emitter not use logic and instead just emit.

This is NFC so I can make sure that things work before adding the additional code.
2024-07-02 16:21:44 -07:00
Ben Barham
aa7a3a8268 Cleanup std includes
Remove `deque` from files it isn't actually used in. Add it and `stack`
to files that it is - presumably they were previously transitively found
through other includes.
2024-07-02 16:13:49 -07:00
Michael Gottesman
e9e5c4eb4c [region-isolation] Ensure that some NDEBUG code is properly guarded. 2024-07-02 13:55:33 -07:00
Michael Gottesman
130835a087 Merge pull request #74871 from gottesmm/pr-32c2095d621aa2c4be4bac901c79bfa5d9bd147e
[siloptimizer] Teach VariableNameInference how to look through convert_escape_to_no_escape.
2024-07-01 18:00:47 -07:00
Michael Gottesman
a13c1dc2dc Merge pull request #74869 from gottesmm/rdar130915737
[region-isolation] Improve async let errors to always use a new style error.
2024-07-01 16:24:32 -07:00
Michael Gottesman
b5aa2fec31 [siloptimizer] Teach VariableNameInference how to look through convert_escape_to_no_escape.
This was causing us to emit old style diagnostics in certain cases.

Just doing a walk through of the diagnostics and fixing issues while I
am here sprucing up sending diagnostics.

rdar://130915737
2024-07-01 14:37:11 -07:00
Michael Gottesman
02e003f0de [region-isolation] Change capturing a value into an async let that is not further sent into an actor isolated function to use a new style error.
Just going through and fixing sending errors.

rdar://130915737
2024-07-01 13:12:36 -07:00
Michael Gottesman
78d74cf716 [region-isolation] Make sil-region-isolation-assert-on-unknown-pattern also work with TransferNonSendable versions of the error.
This asserts only option is an option to make it quicker/easier to triage
unknown pattern match errors by aborting when we emit it (allowing one to
immediately drop into the debugger at that point).

Previously, it only happened for errors in RegionAnalysis not in
TransferNonSendable itself.
2024-07-01 13:12:36 -07:00
Meghana Gupta
12484ff919 Merge pull request #74842 from meg-gupta/addopenpackedgecase
Fix isTriviallyDuplicatable to handle open_pack_element
2024-07-01 10:53:53 -07:00
Meghana Gupta
d6729280f3 [NFC] clang-format parts of tryRewriteToPartialApplyStack 2024-07-01 09:53:14 -07:00
Meghana Gupta
56d59c9db3 [NFC] Rename OrigUnusedDuringClosureLifetimeWalker -> OrigUnmodifiedDuringClosureLifetimeWalker 2024-07-01 09:53:14 -07:00