Commit Graph

5521 Commits

Author SHA1 Message Date
Nate Chandler
f952b0cc7e [PrunedLiveness] Removed invalidate.
The method doesn't do what clients expect.
2023-05-02 11:51:53 -07:00
Nate Chandler
dfe2c00155 [SIL] Added operator bool to ref. 2023-05-02 11:51:52 -07:00
nate-chandler
2984f0a236 Merge pull request #65417 from nate-chandler/rdar108514447
[SemanticARCOpts] Promote moved load [copy]s to load_borrows.
2023-04-27 06:59:02 -07:00
Nate Chandler
b686e81085 [OwnershipUtils] Add move as OwnedValueIntroducer. 2023-04-25 11:37:30 -07:00
Michael Gottesman
c577055100 [move-only] Instead of using AccessUseVisitor to visit addresses use TransitiveAddressVisitor.
This makes it so that the move address checker is not dependent on starting the
traversal at a base object. I also included verifier checks that the API can
visit all address uses for:

1. project_box.
2. alloc_stack.
3. ref_element_addr.
4. ref_tail_addr.
5. global_addr_inst.

this is because this visitor is now apart of the SIL API definition as being
able to enumerate /all/ addresses derived from a specific chosen address value.

This is a refactoring NFCI change.

rdar://108510644
2023-04-25 10:51:03 -07:00
nate-chandler
28bbbd5614 Merge pull request #65114 from nate-chandler/nfc/20230412/2/delete-duplicate-api
[SIL] NFC: Removed visitBorrowIntroducingUserResults.
2023-04-24 15:20:16 -07:00
Nate Chandler
6ad9581bd6 [SIL] NFC: Clarified doc comment. 2023-04-24 10:38:11 -07:00
Meghana Gupta
3d75abc570 Add an option to force boundary completion of lexical values 2023-04-21 22:41:22 -07:00
Slava Pestov
ce5bef8f4d Merge pull request #65361 from slavapestov/sil-type-subst-cloner-sillyness
SIL: TypeSubstCloner::remapASTType() should not call getLoweredRValueType()
2023-04-21 18:52:32 -04:00
Slava Pestov
8bb3248ab3 SIL: TypeSubstCloner::remapASTType() should not call getLoweredRValueType()
SILCloner::visitScalarPackIndexInst() was calling remapASTType() on
a PackType. This was becoming a SILPackType, which would then crash
in a cast<>.
2023-04-21 14:17:08 -04:00
Nate Chandler
5b6c1d6660 [SIL] Accesses to globals are deinit barriers.
Accesses to globals can't be reordered with deinits since deinits could
read such globals.

rdar://98542123
2023-04-20 18:02:41 -07:00
Slava Pestov
7fa676e53d SIL: Introduce SILType::hasParameterizedExistential() 2023-04-18 12:54:49 -04:00
Meghana Gupta
fa4f3a5642 Update assertion for partial_apply [on_stack] lifetime ends in lifetime completion
Since partial_apply [on_stack] is considered as a BorrowingOperand now,
and BorrowingOperand::visitScopeEndingUses can be called on the its forwarded values
lifetime ends, update the assertion to reflect this.
2023-04-14 16:00:24 -07:00
John McCall
9bf4e8c4a3 Remove a couple of over-eager assertions.
The best substitutions we can easily find in nested functions for
captured local variables are the forwarding substitutions of the
current environment.  These should be fine for type-substitution
purposes but do not necessarily match the generic signature of the
original variable's environment, which can trip these assertions.
Unfortunately, I can't think of an easy way to weaken these
assertions sufficiently to cover this case.

This should fix the source-compat suite regression reported in
rdar://107642925.
2023-04-14 02:04:47 -04:00
Meghana Gupta
264d86d26c Implement InteriorLivenessVisitor::handleInnerBorrow for all BorrowingOperand kinds
Not all BorrowingOperand introduce a BorrowedValue. Add a new api to get the defining value
for use in InteriorLivenessVisitor::handleInnerBorrow.
2023-04-12 14:42:23 -07:00
Nate Chandler
b1ccb59f01 [SIL] NFC: Removed visitBorrowIntroUserResults.
It's equivalent to getBorrowIntroducingUserResult except that it's less
convenient to use.  There's only ever one result, so there's no need for
a visitor.  Updated all users to call getBorrowIntroducingUserResult
instead.
2023-04-12 13:41:42 -07:00
Nate Chandler
0fceb33905 [SIL] NFC: Marked function const.
Make it available on const instances.
2023-04-12 13:29:05 -07:00
Meghana Gupta
6cefbb303a Handle partial_apply [on_stack] lifetime ends in the visitor 2023-04-11 13:56:42 -07:00
Erik Eckstein
7d70a70acf SIL: add the drop_deinit instruction
his instruction is a marker for a following destroy instruction to suppress the call of the move-only type's deinitializer.
2023-04-11 10:25:48 +02:00
Meghana Gupta
6854bbef1f Merge pull request #64975 from meg-gupta/fixborrowcompletion
Fix ossa borrow completion
2023-04-06 18:28:49 -04:00
nate-chandler
417bc5a7f5 Merge pull request #64964 from nate-chandler/lexical-lifetime-elim-lexical-move
[LexicalLifetimeEliminator] Removed flag from move_values.
2023-04-06 13:57:28 -07:00
Meghana Gupta
85a580a96e Fix ossa borrow completion
end_borrow was not considered as a lifetime ending use,
leading to insertion of redundant end_borrows at boundaries.
2023-04-06 11:15:37 -07:00
Nate Chandler
b682d54ddc [LexLifetimeElim] Removed flag from moves.
When eliminating lexical lifetimes, also eliminate the lifetimes
introduced by move_values in addition to those introduced by
begin_borrow and communicated via alloc_stack.
2023-04-05 18:38:08 -07:00
John McCall
c11cbfa6ce [NFC] Convert this code to use canonical types 2023-04-05 16:58:49 -04:00
Andrew Trick
4bc9671e44 Merge pull request #64926 from atrick/fix-liveblocks
MultiDefPrunedLiveness: add support for arbitrary uses/defs.
2023-04-05 10:03:27 -07:00
Adrian Prantl
829491b230 Merge pull request #64551 from adrian-prantl/88274783
Rebase SILScope generation on top of ASTScope
2023-04-05 08:30:13 -07:00
Adrian Prantl
158772c2ab Rebase SILScope generation on top of ASTScope.
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
2023-04-04 15:20:11 -07:00
Andrew Trick
c9eb1aea91 MultiDefPrunedLiveness: add support for arbitrary uses/defs.
This now supports liveness holes within blocks where previously we
expected a phi def.

PrunedLiveness is streamlined for SSA liveness where we expect the
defs and uses to be related in the SSA def-use graph.
MultiDefPrunedLiveness was added on top of SSAPrunedLivenes to handle
extended SSA liveness that occurs with phis, but are still connected
in the def-use graph. Recently MultiDefPrunedLiveness was repurposed
for liveness of addressible storage. This means that we can now have
uses before defs in the same block without a corresponding phi.

Fortunately, handling this case is a straightforward extension of
MultiDefPrunedLiveness that does not complicate or penalize the
streamlined SSA case.
2023-04-04 10:22:32 -07:00
Andrew Trick
d44c7f3b99 [NFC] Move the updateForUse API into PrunedliveRange
PrunedLiveness only knows about the live blocks and uses.

The PrunedLiveRange subclass is now responsible for updating liveness
based on both the defs and uses. This is in preparation for handling
non-SSA liveness when uses occur before the first def.
2023-04-04 10:22:32 -07:00
Andrew Trick
20604ab234 PrunedLiveness: remove a useless flag.
This was recently introduced as a result of rebasing commits. It never
did anything useful on the main branch.
2023-04-04 10:22:32 -07:00
John McCall
9c9671b349 Merge pull request #64887 from rjmccall/vanishing-tuple-silgen
SILGen and SIL type lowering support for vanishing tuples
2023-04-04 12:41:29 -04:00
John McCall
30817b11dd Support vanishing tuples in the the general abstraction pattern routines. 2023-04-03 23:14:47 -04:00
Slava Pestov
3d9a79e4b1 Merge pull request #64777 from slavapestov/sil-optimizer-variadic-generics
SIL optimizer fixes for variadic generics
2023-04-03 11:30:03 -04:00
Slava Pestov
894b57eaf3 AST: Introduce TupleType::getNumScalarElements() 2023-04-02 23:04:00 -04:00
Michael Gottesman
43d8ab24f4 [move-only] Add a new type of mark_must_check initable_but_not_consumable.
This is used to teach the checker that the thing being checked is supposed to be
uninitialized at the mark_must_check point so that we don't put a destroy_addr
there.

The way this is implemented is that we always initially add
assignable_but_not_consumable but in DI once we discover that the assign we are
guarding is an init, we convert the assignable to its initable variant.

rdar://106525988
2023-03-31 17:32:58 -07:00
Adrian Prantl
af3b73a8ac Merge pull request #64590 from adrian-prantl/implicit-sillocation
Preserve the Implicit attribute in SILLocation. (NFC)
2023-03-30 13:46:51 -07:00
Andrew Trick
0c8ecb54bf Revert "MultiDefPrunedLiveness: add support for arbitrary uses/defs." 2023-03-28 17:43:42 -07:00
Andrew Trick
95a92fda30 Merge pull request #64625 from atrick/fix-liveblocks
MultiDefPrunedLiveness: add support for arbitrary uses/defs.
2023-03-28 14:19:42 -07:00
Allan Shortlidge
9a1a2c3b9d Merge pull request #64644 from tshortli/strip-unavailable-code
Introduce `-unavailable-decl-optimization`
2023-03-28 08:53:48 -07:00
Daniel Rodríguez Troitiño
eabafdf7d4 [NFC] Remove extra comma inside the macros.
The macros are all used with a semicolon after the macro invocation, so
the comma inside the macro and outside the macro are redundant. This
causes a warning in modern compilers with extra warnings enabled that it
is quite spammy in the output.

Remove the commas inside the macro to avoid the warning. This should not
have any meningful effect in the result.
2023-03-27 15:59:23 -07:00
Allan Shortlidge
ada0f09615 SILGen: Implement 'complete' unavailable decl optimization.
Avoid SIL lowering for declarations marked unavailable when
`-unavailable-decl-optimiation=complete` is specified.

Part of rdar://106674022
2023-03-27 11:40:54 -07:00
John McCall
3b3e53eb73 [NFC] Use InFlightSubstitution in the SIL type substituter 2023-03-25 18:54:14 -04:00
Andrew Trick
6b77b79ac8 MultiDefPrunedLiveness: add support for arbitrary uses/defs.
This now supports liveness holes within blocks where previously we
expected a phi def.

PrunedLiveness is streamlined for SSA liveness where we expect the
defs and uses to be related in the SSA def-use graph.
MultiDefPrunedLiveness was added on top of SSAPrunedLivenes to handle
extended SSA liveness that occurs with phis, but are still connected
in the def-use graph. Recently MultiDefPrunedLiveness was repurposed
for liveness of addressible storage. This means that we can now have
uses before defs in the same block without a corresponding phi.

Fortunately, handling this case is a straightforward extension of
MultiDefPrunedLiveness that does not complicate or penalize the
streamlined SSA case.
2023-03-24 18:40:31 -07:00
John McCall
a3c5e1664f Merge pull request #64575 from rjmccall/variadic-memberwise-initializers
Fixed memberwise initializers for structs with variadic-tuple properties
2023-03-24 12:24:38 -04:00
Andrew Trick
44fc97d340 [NFC] Move the updateForUse API into PrunedliveRange
PrunedLiveness only knows about the live blocks and uses.

The PrunedLiveRange subclass is now responsible for updating liveness
based on both the defs and uses. This is in preparation for handling
non-SSA liveness when uses occur before the first def.
2023-03-23 22:05:54 -07:00
Andrew Trick
13c60ae55a PrunedLiveness: remove a useless flag.
This was recently introduced as a result of rebasing commits. It never
did anything useful on the main branch.
2023-03-23 15:19:29 -07:00
Adrian Prantl
c5efebe784 Preserve the Implicit attribute in SILLocation. (NFC)
This change aims at reducing the need for SIL passes to check into the AST
storage of SILLocations. The end goal is to eventually merge this with the
autogenerated flag, but at the moment the emergent semantics of both properties
are not identical.
2023-03-23 14:59:05 -07:00
swift-ci
18fd92ef82 Merge pull request #64581 from atrick/fix-assert
PrunedLiveness; remove SWIFT_ASSERT_ONLY_DECL
2023-03-23 14:25:35 -07:00
nate-chandler
4ea51cfe33 Revert "Add a verify-di-hole assertion to SILBuilder." 2023-03-23 13:27:06 -07:00
Andrew Trick
fd03de4cd6 PrunedLiveness; remove SWIFT_ASSERT_ONLY_DECL
There's no value in hiding this flag in release builds.
I meant to remove SWIFT_ASSERT_ONLY_DECL in the previous commit.
2023-03-23 13:27:06 -07:00