Commit Graph

15 Commits

Author SHA1 Message Date
Andrew Trick
b0f2ca03a7 AccessUtils: allow mark_deps to be tracked by the EnclosingScope.
This encourages AccessPathWalker clients to handle enclosing mark_deps. In
some cases, it is necessary. The accessBaseWithScopes API now provides both
nested begin_access and mark_dependence.
2025-01-11 15:40:22 -08:00
Andrew Trick
5fc103b8ac [NFC] AccessUtils: add accessBaseWithScopes
And simplify enclosingAccessScope.

These two APIs now directly compute what is being asked for. Previously, each
invocation of enclosingAccessScope would recompute the base and all nested
scopes, but throw away that information. Sometimes we do not want to compute
that information, and other times we need all of it. Instead, provide separate
APIs that do exactly what is needed.

These are common APIs used by other utilities. This avoids quadratic traversals in those
cases. It is also easier to understand and debug.

These utilities will be used in LifetimeDependenceScopeFixup.
2024-11-18 01:37:00 -08:00
Andrew Trick
0fb3cb96de [NFC] Add AccessBase.address
LifetimeDependence uses the address of the AccessBase to compute liveness. It is
more convenient to switch over all AccessBase kinds here rather than force all
clients to do it.
2024-11-18 01:37:00 -08:00
Andrew Trick
ec0026f7e5 [NFC] AccessBase: correct initialization from pointer_to_address
AccessBase already identifies a base address as either a .global (addressor) or
a .pointer. When initializing an AccessBase from a pointer_to_address, precisely
identify one of these kinds of accesses, rather than simply marking it
.unidentified.

This used to be a special case in the AccessPathWalker. But that's not the right
place to handle it.
2024-11-18 01:37:00 -08:00
Erik Eckstein
f0633d5638 AccessUtils: support computing "constant" access paths
Add `Value.constantAccessPath`. It is like `accessPath`, but ensures that the projectionPath only contains "constant" elements.
This means: if the access contains an `index_addr` projection with a non-constant index, the `projectionPath` does _not_ contain the `index_addr`.
Instead, the `base` is an `AccessBase.index` which refers to the `index_addr`.
2024-11-04 19:26:44 +01:00
Alexander Cyon
c18a24e499 [SwiftCompilerSources] Fix typos 2024-08-08 22:22:39 -07:00
Erik Eckstein
def3b6fab0 AccessUtils: recognize addressor calls of globals as a "global" access base
Makes e.g. alias analysis more precise in the early stage of the pass pipeline where addressor calls are not inlined, yet.
2024-08-05 17:12:46 +02:00
Erik Eckstein
ceda41ca90 AccessUtils: fix handling of store_borrow in AccessBase.isDistinct
The result of a store_borrow can "escape" to other access bases, like a "pointer" access base.
Then a store-borrow access base is _not_ distinct from such another base.
2024-07-29 17:33:46 +02:00
Erik Eckstein
983d95509d AccessUtils: do a simple type-based alias analysis in AccessBase.isDistinct
If the operand types (which are classes) of `ref_element_addr` or `ref_tail_addr` differ, then we know those can't be the same objects.
2024-07-29 17:33:46 +02:00
Andrew Trick
a0b2ae9c2c Add AccessBase.storeBorrow.
Don't treat StoreBorrow addresses as unknown bases. While they are never the base of a formal access, they are returned
as the AccessBase when querying the enclosing scope of an address.
2024-03-22 11:51:58 -07:00
Andrew Trick
e3198ed38e Fix AccessUtils.swift to use the project_box reference root. 2024-02-26 00:20:46 -08:00
Andrew Trick
7574c1fede Fix AccessUtils Value.referenceRoot to handle ForwardingInstructions.
This fixes all analyses that use AccessUtils in the presence of new
forwarding instructions. This is also needed for consistency with the
C++ source base. And for general sanity.

Utilities that walk the use-def chain should never hard-code a list of
opcodes that happened to work with some specific pass. Passes should
never assume that a basic SIL utility handles specific SIL operations
a certain way. Instead, the utility needs to be defined in terms of
SIL semantics. In this case, the utility is supposed to handle all
instructions that semantically forward ownership of a reference.
2024-02-26 00:20:46 -08:00
Andrew Trick
03bda631f1 AccessUtils: comment typo 2024-02-12 09:57:14 -08:00
Andrew Trick
17319fa843 Improve the AddressUtils and OwnershipLiveness APIs 2024-01-30 08:38:57 -08:00
Erik Eckstein
ec4c815506 SwiftCompilerSources: move WalkUtils and AccessUtils from the Optimizer module to the SIL module
Those utilities are conceptually part of the SIL definition.
2023-12-01 19:20:13 +01:00