Commit Graph

11224 Commits

Author SHA1 Message Date
Joe Groff
de687db20f Disallow consuming self in a noncopyable deinit again.
The changes to allow for partial consumption unintentionally also allowed for
`self` to be consumed as a whole during `deinit`, which we don't yet want to
allow because it could lead to accidental "resurrection" and/or accidental
infinite recursion if the consuming method lets `deinit` be implicitly run
again. This makes it an error again. The experimental feature
`ConsumeSelfInDeinit` will allow it for test coverage or experimentation
purposes. rdar://132761460
2024-07-29 21:20:14 -07:00
swift-ci
eb2214ddaa Merge remote-tracking branch 'origin/main' into rebranch 2024-07-29 13:06:53 -07:00
Michael Gottesman
72ad780578 Merge pull request #75541 from gottesmm/pr-7133549c90f98b7c9be71f80b74a97d088aa62f2
[region-isolation] Do not ignore non-trivial results that are Sendable to be more permissive in the face of lazy typechecker issues.
2024-07-29 13:00:24 -07:00
swift-ci
11f8fa2d69 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-29 10:55:36 -07:00
Michael Gottesman
8604480d12 [region-isolation] Do not ignore non-trivial results that are Sendable to be more permissive in the face of lazy typechecker issues.
We have found certain cases due to the requestified typechecker, a type is
initially Sendable and then is later non-Sendable. This can be seen by the
attached test case where the first time one calls isNonSendableType on the test
value, one would get that it is Sendable and then the second time one would get
it was non-Sendable. The result of this is that the pass gets into an
inconsistent state.

This patch is a small patch that makes the pass more permissive in the face of
such an error by making it so that we do not ignore Sendable results of
instructions (that is we make sure to track a value for them), so we do not
break invariants.

The longer term better fix is to make it so that we have a cache in the pass for
this query that way we just always use the first answer returned from the
typechecker and cache that. If the typechecker has such a bug, we may get bogus
results, but we at least do not break invariants.

As an example of this type of behavior, in the test case in this patch, we first
find the Sendable conformance of MySubClass and then the typechecker after doing
some more type checking while performing that query, the second time finds the
inherited non-Sendable conformance of MyParentClass causing MySubClass to be
considered to be non-Sendable.

rdar://132347404
2024-07-29 09:44:57 -07:00
Erik Eckstein
f9b524b1cb AliasAnalysis: a complete overhaul of alias- and memory-behavior analysis
The main changes are:

*) Rewrite everything in swift. So far, parts of memory-behavior analysis were already implemented in swift. Now everything is done in swift and lives in `AliasAnalysis.swift`. This is a big code simplification.

*) Support many more instructions in the memory-behavior analysis - especially OSSA instructions, like `begin_borrow`, `end_borrow`, `store_borrow`, `load_borrow`. The computation of end_borrow effects is now much more precise. Also, partial_apply is now handled more precisely.

*) Simplify and reduce type-based alias analysis (TBAA). The complexity of the old TBAA comes from old days where the language and SIL didn't have strict aliasing and exclusivity rules (e.g. for inout arguments). Now TBAA is only needed for code using unsafe pointers. The new TBAA handles this - and not more. Note that TBAA for classes is already done in `AccessBase.isDistinct`.

*) Handle aliasing in `begin_access [modify]` scopes. We already supported truly immutable scopes like `begin_access [read]` or `ref_element_addr [immutable]`. For `begin_access [modify]` we know that there are no other reads or writes to the access-address within the scope.

*) Don't cache memory-behavior results. It turned out that the hit-miss rate was pretty bad (~ 1:7). The overhead of the cache lookup took as long as recomputing the memory behavior.
2024-07-29 17:33:46 +02:00
Erik Eckstein
8f2531348d LICM: make sure that getMemoryBehavior is only called for address values
It was called for non-address operands of fix_lifetime.
Just exclude such fix_lifetime instructions from moving. It's not important anyway.
2024-07-29 17:33:44 +02:00
Erik Eckstein
4c49e0039b Verifier: in the swift verifier call the bridged C++ verificationFailure function in case of a failure
This brings all the nice verifier features to the swift verifier, like printing the surrounding instructions in case of a failure, etc.
2024-07-29 17:33:43 +02:00
Erik Eckstein
04e0907ab0 SIL: rename Type.instanceTypeOfMetatype -> Type.loweredInstanceTypeOfMetatype
The same for SILType

It needs to be made clear that this is not the "original", but the lowered SIL type.

NFC
2024-07-29 17:33:36 +02:00
Nate Chandler
344ef3df37 [ClosureLifetimeFixup] Flag dead-end destroys. 2024-07-29 07:26:08 -07:00
Nate Chandler
45f3cf9150 [OwnedLifetimeCan] Persist [dead_end].
When creating `destroy_value`s, create them with the `dead_end` flag if
all subsequent destroys (those from which it is notionally being
hoisted) have the flag.
2024-07-29 07:26:08 -07:00
swift-ci
0a99f57502 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-26 17:16:44 -07:00
Anton Korobeynikov
a751b076b6 Fixes inject_enum_addr handling: (#75459)
- Ensure it really accumulates the adjoint buffer
- Handle Optional.none case when there is no value to propagate to

Fixes #75280
2024-07-26 17:04:26 -07:00
swift-ci
8f7c33c6a1 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-26 16:33:56 -07:00
Andrew Trick
030f2b8e90 Merge pull request #75050 from atrick/vardecl_lifetime
[SILGen] Create SIL variable declaration scopes for trivial values.
2024-07-26 16:23:07 -07:00
swift-ci
1c725e6fc1 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-26 10:35:19 -07:00
Andrew Trick
4915bfa9cb Fix ConstExpr evaluation to handle extend_lifetime. 2024-07-26 08:27:31 -07:00
Andrew Trick
027684aab8 Teach MoveOnlyTypeWrapperEliminator to lower trivial moves/borrows. 2024-07-26 08:27:31 -07:00
Andrew Trick
9478d3488f Fix ConsumeOperatorCopyableValuesChecker to ignore trivial values. 2024-07-26 08:27:31 -07:00
Nate Chandler
a7c6538d4e Revert "Merge pull request #73275 from nate-chandler/lifetime-completion/enable"
This reverts commit 840198ec9b, reversing
changes made to b74303c214.
2024-07-26 07:12:45 -07:00
swift-ci
6c22b2307d Merge remote-tracking branch 'origin/main' into rebranch 2024-07-25 19:43:11 -07:00
Nate Chandler
2e2a81b766 [Test] Underscored dump_function.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
acab991197 [Test] Underscored canonicalize_ossa_lifetime.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
06bdd79936 [Test] Underscored deleter_delete_if_dead.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
fb56178481 [Test] Underscored canonicalize_borrow_scope.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
0cad62521e [Test] Underscored sil_isolation_info_inference.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
3e5d0039e9 [Test] Underscored lexical_destroy_folding.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
a75bd893b9 [Test] Underscored variable_name_inference.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:52:21 -07:00
Nate Chandler
074036982c [Test] Underscored simplify_cfg_simplify_argument.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
9825b26e3a [Test] Underscored simplify_cfg_simplify_argument.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
2878b053ec [Test] Underscored simplify_cfg_simplify_block_args.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
dd19acdf68 [Test] Underscored simplify_cfg_canonicalize_switch_enum.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
4329512fb0 [Test] Underscored simplify_cfg_simplify_term_with_identical_dest_blocks.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
b0bb97467f [Test] Underscored simplify_cfg_simplify_switch_enum_block.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
c0d95c121b [Test] Underscored simplify_cfg_simplify_switch_enum_on_objc_class_optional.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:14 -07:00
Nate Chandler
7470c29cfe [Test] Underscored simplify_cfg_simplify_switch_enum_unreachable_blocks.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:48:22 -07:00
Nate Chandler
8d3a5a17d9 [Test] Underscored simplify_cfg_try_jump_threading.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:47:45 -07:00
swift-ci
24381eddc3 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-25 12:33:16 -07:00
nate-chandler
840198ec9b Merge pull request #73275 from nate-chandler/lifetime-completion/enable
[LifetimeCompletion] Enable.
2024-07-25 12:29:44 -07:00
Nate Chandler
92e5dc84cd [ClosureLifetimeFixup] Flag dead-end destroys. 2024-07-24 17:56:31 -07:00
Nate Chandler
c726366f88 [OwnedLifetimeCan] Persist [dead_end].
When creating `destroy_value`s, create them with the `dead_end` flag if
all subsequent destroys (those from which it is notionally being
hoisted) have the flag.
2024-07-24 17:56:31 -07:00
swift-ci
8093bbb848 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-24 17:33:17 -07:00
Nate Chandler
95b8eef292 [NFC] OwnedLifetimeCan: Use isWithinBoundary.
Now that `isWithinBoundary` and `areUsesWithinBoundary` are "the same"
(up to the fact that one takes an instruction and the other an array of
operands), there's no reason to use the latter when looking at a single
instruction.
2024-07-24 11:28:00 -07:00
swift-ci
f1ea924a51 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-24 10:14:18 -07:00
Allan Shortlidge
66e2f972ab Merge pull request #75432 from tshortli/maccatalyst-upstream
Upstream missing macCatalyst support
2024-07-24 09:58:04 -07:00
swift-ci
7203e893f7 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-23 21:14:07 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Nate Chandler
042241af55 [NFC] MoveOnlyAddressChecker: Use isWithinBoundary
Switch back to the API meant for a single instruction now that it
properly handles dead-end regions.
2024-07-23 13:38:35 -07:00
Nate Chandler
812891cf81 [NFC] PrunedLiveness: Clarified boundary API.
When checking whether an instruction is contained in a liveness
boundary, a pointer to a DeadEndBlocks instance must always be passed.
When the pointer is null, it is only checked that the instruction occurs
within the direct live region.  When the pointer is non-null, it is
checked whether the instruction occurs within the region obtained by
extending the live region up to the availability boundary within
dead-end regions that are adjacent to the non-lifetime-ending portion of
the liveness boundary.
2024-07-23 13:38:35 -07:00
swift-ci
80f3a32db1 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-23 13:13:20 -07:00