Commit Graph

1065 Commits

Author SHA1 Message Date
Erik Eckstein
abbd9d3fd6 OSSALifetimeCompletion: need to look through borrowed-from when creating an end_borrow
Fixes a verifier crash

rdar://134728428
2024-09-03 14:46:13 +02:00
nate-chandler
b3fd194e56 Merge pull request #76095 from nate-chandler/lifetime-completion/20240826/1
[LifetimeCompletion] Avoid instruction list walk.
2024-08-30 12:35:06 -07:00
Nate Chandler
d669c1d220 [LifetimeCompletion] Avoid instruction list walk.
When computing the available region, a forward walk is done from the
non-lifetime-ending boundary of the live region.  That boundary consists
of (1) the target blocks of boundary edges, (2) dead defs, and (3) last
users which are non-consuming.  This forward walk is done at the block
level, so neither the specific dead def (for (2)) nor specific last
non-consuming user (for (3)) is required to perform the walk; indeed
currently these are computed and then immediately used only to obtain
the blocks in which they appear and then discarded.  Avoid computing the
specific dead defs and specific last non-consuming users by switching to
a lower-fidelity liveness boundary computation via
`PrunedLivenessBlockBoundary`.
2024-08-26 16:24:51 -07:00
Nate Chandler
86cd9603da [PrunedLiveness] Add lower detail boundary.
To enable those clients which care only about _blocks_ whose
instructions or dead-defs make up the liveness boundary to avoid
iterating instruction lists, enhance boundary computation with a second
type (`PrunedLivenessBlockBoundary`) and migrate some methods from
liveness onto the boundary types to enable dispatching on the boundary
type to do only the amount of analysis that's necessary.
2024-08-26 16:04:57 -07:00
Erik Eckstein
c8e74b8393 Generic specialization: change the mangling for dropped metatype arguments
Instead of adding a "flag" (`m` in `...Tgm5`) make it more generic to allow to drop any unused argument.
Add all dropped arguments with a `t<n-1>` (where `<n-1>` is empty for n === 0). For example `...Ttt2g5`.
2024-08-26 10:43:15 +02:00
Erik Eckstein
c96b196ffa SwiftCompilerSources: bridge SILLinkage
Make SILLInkage available in SIL as `SIL.Linkage`.
Also, rename the misleading Function and GlobalVariable ABI `isAvailableExternally` to `isDefinedExternally`
2024-08-22 08:56:27 +02:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Erik Eckstein
50e22f986c SIL: allow atomic operations in @_noLocks functions
https://github.com/swiftlang/swift/issues/74407
2024-08-01 13:38:39 +02:00
Nate Chandler
3c18f532c7 [Test] Underscored linear_liveness.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:25 -07:00
Nate Chandler
e5a6974edd [Test] Underscored scoped_address_liveness.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:25 -07:00
Nate Chandler
3589246778 [Test] Underscored fieldsensitive_multidefuse_liverange.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:25 -07:00
Nate Chandler
5a93b7d7d5 [Test] Underscored visit_inner_adjacent_phis.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:18 -07:00
Nate Chandler
1fbc526bc8 [Test] Underscored find_borrow_introducers.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:18 -07:00
Nate Chandler
a3922144f6 [Test] Underscored find_enclosing_defs.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:18 -07:00
Nate Chandler
7119b9e713 [Test] Underscored has_pointer_escape.
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:18 -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
Nate Chandler
e0da318129 [PrunedLiveness] Fix extended boundary check.
The areUsesWithinBoundary/areUsesOutsideBoundary methods take the
dead-ends because the region that they're checking for containment
within contains more than just (is a (non-strict) superset of) the
pruned live region.  On the other hand, the region also contains _less_
than (is a (non-strict) subset of) the available region.  Instructions
are in this extended region only if they're in a dead-end block which is
forwards reachable from the non-lifetime-ending liveness boundary.
2024-07-22 21:51:34 -07:00
Meghana Gupta
06faf98251 Update Array bounds check optimization's isIdentifiedUnderlyingArrayObject 2024-07-10 03:32:27 -07: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
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
Meghana Gupta
ab3eaf2441 Merge pull request #71881 from meg-gupta/fixmem2reg
Fix mem2reg of lexical enum stack locations
2024-06-30 05:31:24 -07:00
Meghana Gupta
79acb5ac47 Fix ownership of move-only enums in SIL 2024-06-29 22:58:45 -07:00
Nate Chandler
99b9059a97 [PrunedLiveness] Branch summary merges to ending.
A branch instruction that is both a lifetime-ending user and also a
non-lifetime-ending of a value should be regarded as a lifetime-ending
user.

Without this, utilities that rely on PrunedLiveness such as
`LinearLiveness` and `InteriorLiveness` both incorrectly report that a
branch featuring a value and also a reborrow or guaranteed phi are
non-ending.

rdar://130427564
2024-06-28 08:49:20 -07:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
eeckstein
8dec8f6058 Merge pull request #74259 from eeckstein/fix-fixed-abi-runtime-effects
PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
2024-06-11 07:26:34 +02:00
nate-chandler
0351ecd6fb Merge pull request #74196 from nate-chandler/lifetime-completion/20240606/1
[LifetimeCompletion] Removed "with leaks" mode.
2024-06-10 11:32:44 -07:00
nate-chandler
a2b2087a5e Merge pull request #74198 from nate-chandler/rdar128900124
[MoveOnly] Call mutating methods on existentials.
2024-06-10 11:29:45 -07:00
Erik Eckstein
717880e844 PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
Non-loadable types don't necessarily need metadata, for example, structs with `@_rawLayout`

https://github.com/apple/swift/issues/73951
2024-06-10 18:25:08 +02:00
Nate Chandler
e2fcdb4524 [MoveOnlyAddressChecker] Handle init_exi_addr.
It's a pass-through for FSPL's purposes.

rdar://128900124
2024-06-06 19:04:41 -07:00
Nate Chandler
5dc3cf1296 [LifetimeCompletion] Removed "with leaks" mode.
Now that the two known issues which resulted in invalid SIL being
provided to lifetime completion have been addressed, tighten up the
completion done on the availability boundary not to allow leaks.
2024-06-06 16:48:46 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Nate Chandler
84da0ed4c5 [LifetimeCompletion] Add extend_lifetimes.
The new instructions are inserted after every "user" (according to
InteriorLiveness' SSAPrunedLiveness instance) outside the linear
liveness boundary.
2024-06-05 16:28:28 -07:00
Nate Chandler
087bf6a75b [LifetimeCompletion] NFC: Add helper.
It visits users discovered by an SSAPrunedLiveness instance (such as
that used by InteriorLiveness) which are outside the LinearLifetime
boundary.
2024-06-05 16:28:28 -07:00
Nate Chandler
65397fafb3 [NFC] LifetimeCompletion: Tweaked helper class.
VisitAvailabilityBoundary now has a single public method.
2024-06-05 16:28:28 -07:00
Nate Chandler
a52cc7ae19 [NFC] LifetimeCompletion: Note boundary kind.
When visiting an availability boundary, note what kind of end is
involved.  For now, there's only one.
2024-06-05 16:28:28 -07:00
Nate Chandler
81fa65772f [OwnershipLiveness] End at extend_lifetime.
When visiting consumes, also visit `extend_lifetime` instructions.
These instructions are not lifetime ending, but together with the
consumes, they enclose the users of a value.

Add a flag to LinearLiveness to control whether these instructions are
added so that the verifier can use verify that all such instructions
appear outside the linear lifetime boundary (not including them).
2024-06-05 16:28:28 -07:00
Nate Chandler
2a5d07522d [SIL] Add extend_lifetime instruction.
It indicates that the value's lifetime continues to at least this point.
The boundary formed by all consuming uses together with these
instructions will encompass all uses of the value.
2024-06-05 16:28:26 -07:00
Nate Chandler
77d26e1eff [NFC] LifetimeCompletion: Rename helper fn.
It visits the availability boundary, so call it
`visitAvailabilityBoundary`.  It's not clear what "unreachable lifetime
ends" are.
2024-06-05 16:27:45 -07:00
Nate Chandler
9d7db52bed [NFC] PrunedLiveness: Tweaked enum wrapper.
Clarify methods.  Unfortunately, without other changes I haven't
identified, the `enum class` can't be made an `enum` for ideal usage.
2024-06-05 16:27:45 -07:00
Andrew Trick
e06fc99667 Fix SILCombine to delete dead end_access instructions.
Otherwise, the SILVerifier will raise an error.

Fixes rdar://121599876 (SILCombine should delete instructions in
blocks dominated by cond_fail -1)
2024-05-31 23:01:34 -07:00
Nate Chandler
465886e1e4 [MoveOnlyAddressChecker] Handle open_exi_addr.
It's a pass-through for FSPL's purposes.
2024-05-23 12:26:43 -07:00
Andrew Trick
b88566a36c Merge pull request #73621 from atrick/fix-access-mark-uninit
Allow AddressUseDefWalker to continue past MarkUninitializedInst
2024-05-22 18:18:51 -07:00
nate-chandler
a570286201 Merge pull request #73647 from nate-chandler/rdar128077404
[PrunedLiveness] Fix boundary check for dead-ends.
2024-05-16 19:45:41 -07:00
Nate Chandler
9d42d69c0a [PrunedLiveness] Fix boundary check for dead-ends.
Consider dead, dead-end blocks within the availability boundary to be
within the boundary.

rdar://126965232
2024-05-16 15:53:06 -07:00
Nate Chandler
cd14f4cbed [NFC] PrunedLiveness: Factor out duplicated method
In preparation to make it more complex.
2024-05-15 19:23:11 -07:00