Skip to content

Commit a008c78

Browse files
Merge pull request #4607 from swiftwasm/main
[pull] swiftwasm from main
2 parents 81beeb2 + 74d43a6 commit a008c78

File tree

2 files changed

+133
-1
lines changed

2 files changed

+133
-1
lines changed

docs/proposals/SIL-Utilities.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Utilities for SIL optimizer passes
2+
This document lists a set of SIL utilities to be used by the Swift implementation of the SIL optimizer.
3+
4+
The purpose of this proposal is to do a better planning of what utilities we need in SIL optimizer passes.
5+
6+
We want to avoid a situation like we have in the C++ SIL optimizer, where a huge amount of (partly) redundant utilities exist. Many of those utilities have overlapping functionality, are difficult to discover and are poorly designed. We want to do better in the Swift SIL optimizer.
7+
8+
## Basic Data-Structures
9+
#### `Stack`
10+
11+
An allocation-free, array like data structure. To be used instead of `Swift.Array` wherever random-access is not needed.
12+
13+
**Related C++ utilities:** `llvm::SmallVector`, `Stack`
14+
**Status:** done
15+
16+
#### `BasicBlockSet`
17+
An extremely efficient implementation of a set of basic blocks.
18+
19+
**Related C++ utilities:** `BasicBlockSet`
20+
**Status:** done
21+
22+
#### `BasicBlockWorklist`
23+
To be used for all kind of basic-block work-list algorithms.
24+
25+
**Uses:** `Stack`, `BasicBlockSet`
26+
**Related C++ utilities:** `BasicBlockWorklist`
27+
**Status:** done
28+
29+
## Building SIL
30+
31+
#### `static Builder.insert(after:, insertFunc: (Builder) -> ())`
32+
Useful to insert instructions after a (potential) terminator instruction.
33+
34+
**Related C++ utilities:** `SILBuilderWithScope::insertAfter()`
35+
**Status:** done
36+
37+
## Instruction classifications
38+
We want to classify certain instructions into common groups so that passes can deal deal with the group instead of individual instruction opcodes. Optimization passes then don't need to be updated if new instructions are added to a group.
39+
40+
In Swift we can easily do this by introducing protocols to which instruction classes can conform to.
41+
42+
#### `ApplySite`
43+
44+
**Related C++ utilities:** `ApplySite`
45+
**Status:** exists; to-do: complete member variables/functions
46+
47+
#### `CastInstruction`
48+
Details need to be decided.
49+
50+
**Conforming instructions:** `UpcastInst`, `UncheckedRefCastInst`, etc.
51+
**Members:** ownership behavior, e.g. forwarding, etc.
52+
**Status:** to-do
53+
54+
#### `AddressProjectionInstruction`
55+
Details need to be decided.
56+
57+
**Conforming instructions:** `StructElementAddrInst`, `TupleElementAddrInst`
58+
**Members:** `var fieldIndex: Int`
59+
**Related C++ utilities:** `skipAddrProjections`
60+
**Status:** to-do
61+
62+
#### `AggregateInstruction`
63+
Details need to be decided.
64+
65+
**Conforming instructions:** `StructInst`, `TupleInst`
66+
**Status:** to-do
67+
68+
#### `ExtractInstruction`
69+
Details need to be decided.
70+
71+
**Conforming instructions:** `StructExtractInst`, `TupleExtractInst`
72+
**Status:** to-do
73+
74+
#### `BorrowScope`
75+
Details need to be decided.
76+
Maybe it's better to not do this as a protocol but just add an extension function `Value.introducesBorrowScope`. Reason: an `Argument` can be guaranteed or owned.
77+
78+
**Conforming instructions:** `BeginBorrowInst`, `Argument` with guaranteed ownership (however will do that), `LoadBorrowInst`
79+
**Status:** to-do
80+
81+
## SSA Traversal Utilities
82+
83+
#### Basic Walkers
84+
This is currently in progress. We'll probably have an up-walkers and down-walkers for both, addresses and non-address values.
85+
86+
**Uses:** instruction classifications
87+
**Related C++ utilities:** `AccessPath`, `RCIdentityAnalysis`, various def-use/use-def walkers in optimization passes.
88+
**Status:** in progress
89+
90+
#### `SmallProjectionPath`
91+
Describes a path of projections.
92+
93+
**Related C++ utilities:** `AccessPath`, `ProjectionPath`
94+
**Status:** done
95+
96+
#### `EscapeInfo`
97+
Escape analysis, which is used e.g. in stack promotion or alias analysis.
98+
99+
**Uses:** basic walkers, `SmallProjectionPath`
100+
**Related C++ utilities:** `EscapeAnalysis`, various def-use walkers in optimization passes.
101+
**Status:** done, but factoring out the walkers is in progress
102+
103+
#### `AccessPath`
104+
Details need to be decided.
105+
106+
**Uses:** basic walkers
107+
**Related C++ utilities:** `AccessPath`
108+
**Status:** to-do
109+
110+
## Control- and Dataflow
111+
112+
#### `BasicBlockRange`
113+
Defines a range from a dominating "begin" block to one or more "end" blocks. To be used for all kind of backward block reachability analysis.
114+
115+
**Uses:** `Stack`, `BasicBlockSet`, `BasicBlockWorklist`
116+
**Related C++ utilities:** `PrunedLiveBlocks`, `findJointPostDominatingSet()`
117+
**Status:** done
118+
119+
#### `InstructionRange`
120+
Like `BasicBlockRange`, but at the granularity of instructions.
121+
122+
**Uses:** `BasicBlockRange`
123+
**Related C++ utilities:** `PrunedLiveness`, `ValueLifetimeAnalysis`
124+
**Status:** done
125+
126+
## OSSA Utilities
127+
#### `Value.makeAvailable()` and `Value.copy(at:)`
128+
To be used where a value is copied in one block and used in another block.
129+
130+
**Uses:** `BasicBlockRange`
131+
**Related C++ utilities:** `makeValueAvailable()`, `OwnershipLifetimeExtender`
132+
**Status:** done

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public protocol DistributedActorSystem: Sendable {
6969
// - MARK: Actor Lifecycle
7070
/// Create an `ActorID` for the passed actor type.
7171
///
72-
/// This function is invoked by an distributed actor during its initialization,
72+
/// This function is invoked by a distributed actor during its initialization,
7373
/// and the returned address value is stored along with it for the time of its
7474
/// lifetime.
7575
///

0 commit comments

Comments
 (0)