eeckstein
d1ec089c72
Merge pull request #72088 from language-core/main
...
chore: fix some comments
2024-03-06 10:08:50 +01:00
Andrew Trick
31b3a91912
Merge pull request #71703 from atrick/lifetime-extend
...
LifetimeDependenceScopeFixup: fix handling of returned dependence
2024-03-05 23:17:21 -08:00
Andrew Trick
3bee32639b
LifetimeDependenceDefUseWalker: use LocalVariableReachableUses.
2024-03-05 18:08:16 -08:00
Andrew Trick
ffe9c48976
Add LocalVariableUtils
...
This includes a reaching-def analysis that can be used by diagnostic passes. Diagnostics should be flow-sensitive.
2024-03-05 18:08:16 -08:00
Andrew Trick
75f2f88bce
Add AddressOwnershipLiveRange
...
A live range representing the ownership of addressible memory.
This live range represents the minimal guaranteed lifetime of the object being addressed. Uses of derived addresses
may be extended up to the ends of this scope without violating ownership.
.liveOut objects (@in_guaranteed, @out and globals) have no instruction range.
.local objects (alloc_stack, yield, @in, @inout) report the single live range of the full assignment that reaches
this address.
.owned values (boxes and references) simply report OSSA liveness.
.borrow values report each borrow scope's range. The effective live range is their intersection. A valid use must
lie within
2024-03-05 17:08:13 -08:00
Andrew Trick
e84bcf520f
Add computeBorrowLiveRange
...
Compute the live range for the borrow scopes of a guaranteed value. This returns a separate instruction range for
each of the value's borrow introducers. Unioning those ranges would be incorrect. We typically want their
intersection.
2024-03-05 17:08:13 -08:00
Andrew Trick
d01d74e20c
LifetimeDependenceDiagnostics: find the correct variable introducer.
2024-03-05 17:08:13 -08:00
Andrew Trick
73f7f8f28a
Add NonEscapingClosureDefUseWalker
...
To find all effective applications of partial_apply [on-stack].
2024-03-05 17:08:13 -08:00
Andrew Trick
a3fe978cc4
LifetimeDependenceUtils: handle borrowed ProjectBox
2024-03-05 17:08:13 -08:00
Andrew Trick
5c956f7437
Review feedback; only rewrite access scopes when necessary
2024-03-05 17:08:13 -08:00
Andrew Trick
7dea051bf6
Review feedback; Builder.createEndAccess()
2024-03-05 17:08:13 -08:00
Andrew Trick
d1a75e725c
LifetimeDependenceScopeFixup: handle non-dominated dependent uses.
2024-03-05 17:08:13 -08:00
Andrew Trick
1122cc445f
LifetimeDependenceScopeFixup: fix handling of returned dependence
...
Only rewrite the mark_dependence to depend on the function argument when the
dependent value is actually returned.
Also, find all uses even if an escaping use is seen.
2024-03-05 17:08:13 -08:00
Andrew Trick
8aa1d91a2c
LifetimeDependence: clarify log headers
2024-03-05 17:08:13 -08:00
Andrew Trick
ef940c5297
Redesign gatherBorrowIntroducers to return BeginBorrowValues.
...
This avoids a lot of confusion because the callers expect this type. Fixing it just required some redundancy and
bridging in the EnclosigValues implementation.
2024-03-05 17:08:13 -08:00
Andrew Trick
a0c85be52c
OwnershipLiveness: handle ProjectBox like an interior pointer.
2024-03-05 17:08:13 -08:00
Alejandro Alonso
1752b48a78
Merge pull request #71997 from Azoy/fix-zero-init-escape
...
[EscapeAnalysis] Handle atomic instructions in escape analysis
2024-03-05 13:44:46 -08:00
Alejandro Alonso
254e4f041f
Handle atomic instructions in escape analysis
...
Split atomic loads/stores
no more guard
invert condition
2024-03-05 08:32:51 -08:00
cui fliter
127077b3aa
chore: fix some comments
...
Signed-off-by: cui fliter <imcusg@gmail.com >
2024-03-05 17:23:22 +08:00
Andrew Trick
7aab3c54ec
Factor InstructionRange.beginningInstruction for use elsewhere.
2024-03-04 16:03:54 -08:00
Erik Eckstein
8137adf89e
SwiftCompilerSources: support Undef.parentFunction and PlaceholderValue.parentFunction
...
After support in the C++ SIL, we can implement parentFunction for those values in swift, too.
It simplifies a few things.
2024-03-01 09:07:12 +01:00
Michael Gottesman
11f0ff6e32
[sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
...
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.
rdar://123484595
2024-02-27 13:14:47 -08:00
Meghana Gupta
4fe0429705
Merge pull request #71880 from meg-gupta/ossasilcombine
...
Add silcombines for destructure_tuple and destructure_struct
2024-02-26 14:01:05 -08:00
Meghana Gupta
7508a90af0
Enable destructure_struct/destructure_tuple simplifications in silcombine
2024-02-26 10:58:08 -08:00
Andrew Trick
56126e9db9
Fix LetPropertyLowering to correctly find mark_uninitialized uses.
2024-02-26 00:20:46 -08:00
Andrew Trick
a7e4e900c4
Fix LifetimeDependenceUtils to use OwnershipTransitionInstruction
2024-02-26 00:20:46 -08:00
Andrew Trick
5fc50a0092
AddressUtils: refactor the findSingleInitializer API.
2024-02-25 10:29:15 -08:00
Andrew Trick
a3cbc28078
SwiftCompilerSources: Add enum BeginAccess.AccessKind
...
So we can switch over it.
2024-02-25 10:22:06 -08:00
Erik Eckstein
a13a6e0bf7
SIL: verify forwarding conformances
...
Verify that the C++ view of forwarding instructions agrees with the swift ForwardInstruction conformances.
2024-02-22 07:12:11 +01:00
Erik Eckstein
71fcae7fe8
SwiftCompilerSources: add the ability to implement SIL verification in swift
2024-02-22 07:12:10 +01:00
Meghana Gupta
12ac8042ab
Handle YieldInst in LifetimeDependenceUtils
2024-02-19 15:28:04 -08:00
Andrew Trick
41043948c1
LifetimeDependenceDiagnostics: enable mutably borrowed lifetimes.
...
This allows basic prototyping. A separate analysis will ensure no
mutation of the original value during the borrow.
2024-02-15 02:39:34 -08:00
Andrew Trick
68037faa61
LifetimeDependenceScopeFixup: handle nested access
...
After extending access scopes, rewrite the mark_depenendence to be on
the outermost scope.
2024-02-13 22:22:28 -08:00
Andrew Trick
f0b04004ff
LifetimeDepenenceUtils; improve VariableIntroducerUseDefWalker
...
Stop at formal access to a mutable variable.
2024-02-13 20:57:02 -08:00
Andrew Trick
bc0f60afc9
LifetimeDependenceDiagnostics: cleanup. remove unused code.
2024-02-13 20:57:02 -08:00
Meghana Gupta
75bd5b08dd
Add LifetimeDependenceScopeFixup pass
2024-02-13 16:52:01 -08:00
Andrew Trick
c440cca939
Merge pull request #71570 from atrick/lifetime-inherit
...
LifetimeDependenceInsertion: do not emit inherited dependencies.
2024-02-12 23:02:14 -08:00
eeckstein
77cd7b5e87
Merge pull request #71554 from eeckstein/fix-escape-utils
...
EscapeUtils: fix escape result in case an address is stored
2024-02-13 07:13:51 +01:00
Andrew Trick
ecf2e36717
LifetimeDependenceDiagnostics: FIXME for @_unsafeNonEscapableResult
...
Reminder to add a builtin to reliably enforce this unsafe attribute.
2024-02-12 20:05:25 -08:00
Andrew Trick
1cdf9d56ac
LifetimeDefUseWalker handles inherited dependencies.
...
This is needed when we don't insert mark_dependence.
2024-02-12 20:05:24 -08:00
Andrew Trick
ade2ed6ddb
LifetimeDependenceInsertion: do not emit inherited dependencies.
...
These were always redundant. And there is no way to emit them
correctly for valid OSA when the original dependence scope is in the
caller.
NFC without:
-enable-experimental-feature NonescapableTypes
-enable-lifetime-dependence-diagnostics
2024-02-12 20:05:21 -08:00
Andrew Trick
2e7c29cdf5
Restrict findSingleInitializer @out arguments.
...
The client should handle @in/@inout arguments differently.
2024-02-12 20:03:38 -08:00
Andrew Trick
c4eab6a54a
Merge pull request #71266 from atrick/lifetime-insertion
...
Add the LifetimeDependenceInsertion pass.
2024-02-12 13:07:03 -08:00
Nate Chandler
f9ee089c04
[Test] Added troubleshooting note.
2024-02-12 10:23:13 -08:00
Andrew Trick
8c092911ef
Add the LifetimeDependenceInsertion pass.
...
Insert mark_dependence [nonescaping] markers at every lifetime
introducer that produces a lifetime-dependent value.
2024-02-12 09:57:14 -08:00
Andrew Trick
274c47877f
LifetimeDepenenceDiagnostics improvements
...
Better handling of @_unsafeNonescapableResult
Improve diagnostic clarity.
2024-02-12 09:57:14 -08:00
Andrew Trick
af39b0fb1f
LifetimeDependenceUtils improvements
...
Improve noescape function handling. Use the mayEscape API.
Improve handling of @_unsafeNonescapableResult.
Improve handling of initialized scopes. Use findSingleInitializer.
2024-02-12 09:57:14 -08:00
Andrew Trick
ac457abab9
LifetimeDependenceUseDefWalker: track the owner of the value.
2024-02-12 09:57:14 -08:00
Andrew Trick
b08f2dedf1
Add AccessBase.findSingleInitializer
2024-02-12 09:57:14 -08:00
Andrew Trick
63413916a1
LifetimeDependenceDiagnostics; handle @_unsafeNonescapableResult.
2024-02-12 09:57:14 -08:00