mustflow 2.116.0 → 2.116.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/source-anchors.js +11 -0
- package/package.json +1 -1
- package/templates/default/i18n.toml +72 -6
- package/templates/default/locales/en/.mustflow/skills/INDEX.md +37 -11
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/SKILL.md +477 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-diagnostics-abi-linker-checklist.md +778 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-generators-properties-checklist.md +501 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-test-strategy-differential-checklist.md +498 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/debug-symbol-symbolication-checklist.md +412 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/ir-design-ssa-pass-pipeline-checklist.md +759 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/miscompile-reduction-ir-checklist.md +434 -0
- package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/SKILL.md +55 -36
- package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/references/path-containment-handle-checklist.md +251 -0
- package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/SKILL.md +133 -32
- package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/references/file-upload-parser-ssrf-resource-checklist.md +306 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/SKILL.md +310 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-concurrency-model-checking-smt-checklist.md +457 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-contracts-modeling-checklist.md +434 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-memory-bounds-ci-checklist.md +509 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/SKILL.md +439 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-harness-campaign-checklist.md +379 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-oracle-triage-ci-checklist.md +307 -0
- package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/SKILL.md +48 -28
- package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/references/operation-ordering-stale-write-checklist.md +259 -0
- package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/SKILL.md +329 -0
- package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/references/input-boundary-security-checklist.md +319 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/SKILL.md +306 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/input-session-state-checklist.md +298 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/remote-input-transport-interaction-checklist.md +328 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/SKILL.md +353 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-diagnostics-recovery-checklist.md +267 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-execution-closure-performance-checklist.md +428 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-gc-verification-checklist.md +457 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-semantics-runtime-checklist.md +391 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/SKILL.md +294 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/modal-loop-reentrancy-checklist.md +290 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/nested-modal-state-lifetime-checklist.md +297 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/SKILL.md +252 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/dns-network-resolution-checklist.md +394 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/language-symbol-resolution-checklist.md +282 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/module-package-loader-resolution-checklist.md +352 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/SKILL.md +103 -17
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/cst-ast-lowering-checklist.md +260 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/lexer-tokenization-checklist.md +397 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-serialization-compatibility-checklist.md +164 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-traversal-rewrite-checklist.md +209 -0
- package/templates/default/locales/en/.mustflow/skills/race-condition-review/SKILL.md +68 -11
- package/templates/default/locales/en/.mustflow/skills/race-condition-review/references/race-reproduction-memory-model-checklist.md +268 -0
- package/templates/default/locales/en/.mustflow/skills/routes.toml +151 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/SKILL.md +343 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-auth-stream-resume-checklist.md +413 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-handoff-protocol-checklist.md +485 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/SKILL.md +267 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/admission-decision-recovery-checklist.md +308 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/two-phase-transition-checklist.md +229 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/SKILL.md +300 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-affinity-event-loop-checklist.md +277 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-dispatch-lifecycle-checklist.md +292 -0
- package/templates/default/manifest.toml +115 -1
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
# IR Design, SSA, and Pass Pipeline Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when designing or changing compiler intermediate-representation layers, semantic
|
|
4
|
+
and storage contracts, progressive lowering, CFG and SSA form, canonicalization, analysis
|
|
5
|
+
preservation, or optimization-pipeline ordering.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
1. [IR semantic contract](#ir-semantic-contract)
|
|
10
|
+
2. [Layer decision ledger](#layer-decision-ledger)
|
|
11
|
+
3. [Source AST HIR MIR and LIR boundaries](#source-ast-hir-mir-and-lir-boundaries)
|
|
12
|
+
4. [Lowering information budget](#lowering-information-budget)
|
|
13
|
+
5. [Mixed-level legality](#mixed-level-legality)
|
|
14
|
+
6. [Effects and speculation](#effects-and-speculation)
|
|
15
|
+
7. [Semantic storage ABI and machine types](#semantic-storage-abi-and-machine-types)
|
|
16
|
+
8. [Explicit conversion values](#explicit-conversion-values)
|
|
17
|
+
9. [Ownership capability tokens](#ownership-capability-tokens)
|
|
18
|
+
10. [Ownership ABI and borrow flow](#ownership-abi-and-borrow-flow)
|
|
19
|
+
11. [Lifetime allocation view and provenance](#lifetime-allocation-view-and-provenance)
|
|
20
|
+
12. [Fact provenance scope and generation](#fact-provenance-scope-and-generation)
|
|
21
|
+
13. [Effect capture and speculation axes](#effect-capture-and-speculation-axes)
|
|
22
|
+
14. [Memory model and SSA limits](#memory-model-and-ssa-limits)
|
|
23
|
+
15. [Exceptional suspension and deoptimization control](#exceptional-suspension-and-deoptimization-control)
|
|
24
|
+
16. [Value symbol and source identity](#value-symbol-and-source-identity)
|
|
25
|
+
17. [Verifier ownership](#verifier-ownership)
|
|
26
|
+
18. [IR mutation transaction](#ir-mutation-transaction)
|
|
27
|
+
19. [Canonical-form windows](#canonical-form-windows)
|
|
28
|
+
20. [Text form replay and version boundary](#text-form-replay-and-version-boundary)
|
|
29
|
+
21. [Phi edge semantics](#phi-edge-semantics)
|
|
30
|
+
22. [Phi placement and sealed construction](#phi-placement-and-sealed-construction)
|
|
31
|
+
23. [Phi select and speculation](#phi-select-and-speculation)
|
|
32
|
+
24. [Critical duplicate and exceptional edges](#critical-duplicate-and-exceptional-edges)
|
|
33
|
+
25. [CFG mutation and SSA repair](#cfg-mutation-and-ssa-repair)
|
|
34
|
+
26. [Loop closure and irreducible control](#loop-closure-and-irreducible-control)
|
|
35
|
+
27. [SSA destruction](#ssa-destruction)
|
|
36
|
+
28. [Pass contracts](#pass-contracts)
|
|
37
|
+
29. [Information-aware pass ordering](#information-aware-pass-ordering)
|
|
38
|
+
30. [Normalization and cleanup budgets](#normalization-and-cleanup-budgets)
|
|
39
|
+
31. [Inlining promotion and scalarization](#inlining-promotion-and-scalarization)
|
|
40
|
+
32. [Propagation CFG simplification and deletion](#propagation-cfg-simplification-and-deletion)
|
|
41
|
+
33. [Loop transformation pipeline](#loop-transformation-pipeline)
|
|
42
|
+
34. [Target-lowering boundary](#target-lowering-boundary)
|
|
43
|
+
35. [Instrumentation profile and debug placement](#instrumentation-profile-and-debug-placement)
|
|
44
|
+
36. [Pipeline interaction evidence](#pipeline-interaction-evidence)
|
|
45
|
+
37. [Failure matrix](#failure-matrix)
|
|
46
|
+
38. [Invariants](#invariants)
|
|
47
|
+
39. [Skill handoffs](#skill-handoffs)
|
|
48
|
+
|
|
49
|
+
## IR semantic contract
|
|
50
|
+
|
|
51
|
+
Define an IR by meaning, not by its node classes or textual grammar.
|
|
52
|
+
|
|
53
|
+
For every operation, specify:
|
|
54
|
+
|
|
55
|
+
- operand and result domains;
|
|
56
|
+
- fixed-width, mathematical, trapping, wrapping, saturating, poison, or undefined arithmetic;
|
|
57
|
+
- memory reads, writes, allocation, release, and ordering;
|
|
58
|
+
- exception, trap, cancellation, suspension, deoptimization, and non-return behavior;
|
|
59
|
+
- alias, provenance, lifetime, alignment, and synchronization promises;
|
|
60
|
+
- control successors and edge-defined values;
|
|
61
|
+
- externally observable effects and source-language refinement.
|
|
62
|
+
|
|
63
|
+
A parser accepting the operation proves syntax only. An optimizer needs enough semantic facts to
|
|
64
|
+
decide whether it may delete, duplicate, reorder, combine, speculate, or lower that operation.
|
|
65
|
+
|
|
66
|
+
## Layer decision ledger
|
|
67
|
+
|
|
68
|
+
Describe each IR layer with one reviewable ledger:
|
|
69
|
+
|
|
70
|
+
- information present and intentionally absent;
|
|
71
|
+
- invariants and legal states;
|
|
72
|
+
- semantic types and control-flow form;
|
|
73
|
+
- effects and exceptional paths;
|
|
74
|
+
- identity and source-provenance model;
|
|
75
|
+
- analyses and transforms that consume it;
|
|
76
|
+
- producer and next lowering stage;
|
|
77
|
+
- verifier and negative fixtures;
|
|
78
|
+
- serialization and replay status;
|
|
79
|
+
- target and data-layout dependencies;
|
|
80
|
+
- creation, retention, and disposal lifetime.
|
|
81
|
+
|
|
82
|
+
Do not define a layer by labels such as `HIR`, `MIR`, or `LIR`; those names have no portable level
|
|
83
|
+
contract. Add a layer when consumers require conflicting invariants or information lifetimes. Merge
|
|
84
|
+
two layers when they carry the same meaning, invariants, and consumers and only copy nodes between
|
|
85
|
+
them.
|
|
86
|
+
|
|
87
|
+
## Source AST HIR MIR and LIR boundaries
|
|
88
|
+
|
|
89
|
+
Use source-oriented representations to preserve syntax, recovery, macro or generated provenance,
|
|
90
|
+
and user intent. Do not force malformed or recovered source into a fake valid semantic tree.
|
|
91
|
+
|
|
92
|
+
Move into a high-level semantic IR after the source constructs needed for parsing and expansion are
|
|
93
|
+
resolved enough that semantic consumers no longer need every surface variant. Preserve resolved
|
|
94
|
+
declaration identity, types available at that point, user-facing origin, and any unlowered intent
|
|
95
|
+
needed by diagnostics or language analysis.
|
|
96
|
+
|
|
97
|
+
Introduce a typed high-level layer when overload resolution, implicit conversions, automatic
|
|
98
|
+
reference behavior, pattern typing, or destruction decisions require completed type information
|
|
99
|
+
before executable control flow can be made explicit.
|
|
100
|
+
|
|
101
|
+
Treat a mid-level executable IR as the boundary where evaluation order, temporaries, places, moves,
|
|
102
|
+
copies, calls, continuations, cleanup, and language-level failure paths become explicit. Enter a
|
|
103
|
+
low-level or machine layer only when target widths, legal register types, calling convention,
|
|
104
|
+
addressing modes, instruction constraints, or physical-resource choices become part of the state.
|
|
105
|
+
|
|
106
|
+
## Lowering information budget
|
|
107
|
+
|
|
108
|
+
Treat lowering as controlled information destruction.
|
|
109
|
+
|
|
110
|
+
Before lowering an operation or type, record:
|
|
111
|
+
|
|
112
|
+
- which consumers still need its high-level intent;
|
|
113
|
+
- which legality or profitability questions become harder afterward;
|
|
114
|
+
- which source and semantic identity must survive;
|
|
115
|
+
- which effects and control paths are expanded;
|
|
116
|
+
- which new invariants the lower layer requires;
|
|
117
|
+
- which equivalence or refinement relation checks the conversion;
|
|
118
|
+
- whether mixed high- and low-level forms may coexist.
|
|
119
|
+
|
|
120
|
+
Delay lowering until the last relevant high-level consumer has run. Do not expect later pointer,
|
|
121
|
+
loop, or branch patterns to reconstruct ownership, tensor shape, pattern intent, exception regions,
|
|
122
|
+
or domain-specific operations reliably.
|
|
123
|
+
|
|
124
|
+
## Mixed-level legality
|
|
125
|
+
|
|
126
|
+
Allow progressive lowering only with an explicit legality contract.
|
|
127
|
+
|
|
128
|
+
Classify operations, types, regions, or dialects as:
|
|
129
|
+
|
|
130
|
+
- legal in the current target state;
|
|
131
|
+
- illegal and required to be eliminated;
|
|
132
|
+
- dynamically legal under a named predicate;
|
|
133
|
+
- temporarily legal only inside a bounded conversion region;
|
|
134
|
+
- materialization or bridge operations with explicit direction and lifetime.
|
|
135
|
+
|
|
136
|
+
Define whether conversion is partial or complete and what proves completion. Verify every rewritten
|
|
137
|
+
region immediately. Do not permit high- and low-level variants to coexist merely because a generic
|
|
138
|
+
node container can hold both.
|
|
139
|
+
|
|
140
|
+
## Effects and speculation
|
|
141
|
+
|
|
142
|
+
Represent effects as first-class semantic information. Include more than generic memory reads and
|
|
143
|
+
writes:
|
|
144
|
+
|
|
145
|
+
- allocation and release;
|
|
146
|
+
- I/O and host interaction;
|
|
147
|
+
- traps, exceptions, panic, and non-return;
|
|
148
|
+
- atomics and synchronization;
|
|
149
|
+
- runtime or thread-local state;
|
|
150
|
+
- suspension, resume, yield, and cancellation;
|
|
151
|
+
- deoptimization and stack-map dependencies;
|
|
152
|
+
- volatile, ordered, or externally observed actions.
|
|
153
|
+
|
|
154
|
+
Give simple consumers a conservative question such as whether an operation is movable,
|
|
155
|
+
duplicable, eliminable, or speculatable. Preserve a more detailed effect summary for stronger
|
|
156
|
+
analyses. A missing effect must force conservatism, not permission.
|
|
157
|
+
|
|
158
|
+
## Semantic storage ABI and machine types
|
|
159
|
+
|
|
160
|
+
Separate what a value means from how a target stores, passes, and executes it.
|
|
161
|
+
|
|
162
|
+
Keep source and mid-level semantic types independent of:
|
|
163
|
+
|
|
164
|
+
- pointer width and endianness;
|
|
165
|
+
- physical alignment and padding;
|
|
166
|
+
- register classes and legal machine widths;
|
|
167
|
+
- ABI argument and return locations;
|
|
168
|
+
- vector splitting, widening, or lane padding;
|
|
169
|
+
- object-header and runtime-layout details.
|
|
170
|
+
|
|
171
|
+
Use an explicit progression such as semantic type, storage type, ABI type, and machine type when
|
|
172
|
+
those contracts differ. Introduce data layout and storage types at a named boundary, ABI types when
|
|
173
|
+
calling-convention placement and hidden parameters become relevant, and machine types when legal
|
|
174
|
+
register or instruction representations take over. Prove each representation mapping for size,
|
|
175
|
+
alignment, valid bit patterns, ownership, and conversion. Do not leave machine selection to guess
|
|
176
|
+
layout, and do not contaminate target-independent transforms with physical details before they can
|
|
177
|
+
use them correctly.
|
|
178
|
+
|
|
179
|
+
## Explicit conversion values
|
|
180
|
+
|
|
181
|
+
Represent a type or abstraction transition with a new value and an explicit boundary operation.
|
|
182
|
+
Keep the source and target values alive together until every source-level consumer is rewritten or
|
|
183
|
+
retired.
|
|
184
|
+
|
|
185
|
+
For each conversion, record:
|
|
186
|
+
|
|
187
|
+
- source and destination representation;
|
|
188
|
+
- data layout, address space, and ABI context;
|
|
189
|
+
- ownership and lifetime transferred, retained, split, or consumed;
|
|
190
|
+
- facts preserved, weakened, or destroyed;
|
|
191
|
+
- materialization or bridge operations inserted for old consumers;
|
|
192
|
+
- verifier proving that no source-typed use remains after completion.
|
|
193
|
+
|
|
194
|
+
Do not change an existing value's type in place and leave consumers to infer which contract now
|
|
195
|
+
applies. A string carrying the old type name is provenance for diagnostics at best; it does not
|
|
196
|
+
preserve the executable semantics of the old value.
|
|
197
|
+
|
|
198
|
+
## Ownership capability tokens
|
|
199
|
+
|
|
200
|
+
Model exclusive release authority as a non-forgeable, non-copyable capability rather than a Boolean
|
|
201
|
+
pointer attribute.
|
|
202
|
+
|
|
203
|
+
Track:
|
|
204
|
+
|
|
205
|
+
- allocation identity carried by the capability;
|
|
206
|
+
- creation, move, split-if-allowed, merge-if-allowed, return, and consume transitions;
|
|
207
|
+
- pointer and view values that may alias the allocation without owning release authority;
|
|
208
|
+
- exactly-once release on normal, failure, exceptional, cancellation, and suspension paths;
|
|
209
|
+
- invalid use of a consumed or stale token;
|
|
210
|
+
- concrete lowering into handles, flags, wrappers, or runtime ownership state.
|
|
211
|
+
|
|
212
|
+
Use a dedicated opaque or linear type whose ordinary value operations cannot synthesize a valid
|
|
213
|
+
owner. A copied integer or Boolean is not ownership simply because a later pass interprets it that
|
|
214
|
+
way.
|
|
215
|
+
|
|
216
|
+
## Ownership ABI and borrow flow
|
|
217
|
+
|
|
218
|
+
Define ownership separately at function and external boundaries.
|
|
219
|
+
|
|
220
|
+
For every parameter and result, classify whether it is borrowed, owned, shared, mutable, escaping,
|
|
221
|
+
consumed, returned as an alias of an input, or newly allocated. Include callbacks, tail calls,
|
|
222
|
+
exceptions, unwinding, suspension, and foreign wrappers.
|
|
223
|
+
|
|
224
|
+
Represent a borrow as a permission whose creation dominates every use and whose end covers every
|
|
225
|
+
path after the final use under the IR's control-flow contract. At joins, carry borrow state through
|
|
226
|
+
block arguments or another explicit dataflow value. At loops, distinguish a loop-carried borrow
|
|
227
|
+
from an iteration-local reborrow. Keep alias analysis, which asks whether addresses may overlap,
|
|
228
|
+
separate from permission checking, which asks whether simultaneous access is allowed.
|
|
229
|
+
|
|
230
|
+
## Lifetime allocation view and provenance
|
|
231
|
+
|
|
232
|
+
Model object lifetime as a state machine over an allocation identity and epoch, not as a destructor
|
|
233
|
+
location or raw address interval.
|
|
234
|
+
|
|
235
|
+
Separate:
|
|
236
|
+
|
|
237
|
+
- allocation identity and lifetime epoch;
|
|
238
|
+
- numeric address and address space;
|
|
239
|
+
- base, offset, shape, stride, and view bounds;
|
|
240
|
+
- live, uninitialized, initialized, moved, retired, and dead states as needed;
|
|
241
|
+
- storage reuse that starts a new lifetime at the same address;
|
|
242
|
+
- release authority and non-owning aliases;
|
|
243
|
+
- provenance exposure, address extraction, and pointer reconstruction.
|
|
244
|
+
|
|
245
|
+
A lifetime hint for stack optimization does not prove destructor execution or heap release. Equal
|
|
246
|
+
addresses across epochs do not imply one object. Non-overlapping views may still share one release
|
|
247
|
+
identity. Preserve these distinctions until the consumer that owns lifetime, alias, or release
|
|
248
|
+
correctness has discharged them.
|
|
249
|
+
|
|
250
|
+
## Fact provenance scope and generation
|
|
251
|
+
|
|
252
|
+
Treat every optimization fact as a scoped proof object with an expiry rule.
|
|
253
|
+
|
|
254
|
+
Record at least:
|
|
255
|
+
|
|
256
|
+
- proposition and subject identity;
|
|
257
|
+
- origin analysis, contract, assumption, or runtime guard;
|
|
258
|
+
- domain, region, function, loop, call, or alias scope;
|
|
259
|
+
- allocation identity and lifetime epoch when memory is involved;
|
|
260
|
+
- IR generation or mutation version;
|
|
261
|
+
- status such as proven, assumed, unknown, or contradicted;
|
|
262
|
+
- consumers permitted to use the fact;
|
|
263
|
+
- mutations that preserve, recompute, weaken, or drop it.
|
|
264
|
+
|
|
265
|
+
At control-flow joins, retain only facts justified on every incoming path unless the IR represents a
|
|
266
|
+
path-dependent disjunction explicitly. When values are merged, keep facts true of the merged value,
|
|
267
|
+
not the union of unrelated promises. When a mutation changes memory, identity, layout, or control,
|
|
268
|
+
advance the relevant generation and make older facts unavailable until revalidated.
|
|
269
|
+
|
|
270
|
+
## Effect capture and speculation axes
|
|
271
|
+
|
|
272
|
+
Model effects, pointer capture, and speculation as related but independent axes.
|
|
273
|
+
|
|
274
|
+
Distinguish:
|
|
275
|
+
|
|
276
|
+
- read, write, allocate, release, and synchronization;
|
|
277
|
+
- address capture, provenance capture, and escape;
|
|
278
|
+
- trap, exception, non-return, cancellation, and suspension;
|
|
279
|
+
- host, I/O, runtime, thread-local, volatile, and ordered effects;
|
|
280
|
+
- movable, duplicable, eliminable, and speculatable predicates.
|
|
281
|
+
|
|
282
|
+
An operation may capture a pointer without reading memory, or trap without writing memory. Absence
|
|
283
|
+
of an effect interface means unknown, not pure. Require each transformation to ask the exact
|
|
284
|
+
question it needs rather than treating `no memory write` as permission to move, duplicate, or erase.
|
|
285
|
+
|
|
286
|
+
## Memory model and SSA limits
|
|
287
|
+
|
|
288
|
+
Treat scalar SSA as a def-use representation for values, not as a solution to memory identity.
|
|
289
|
+
|
|
290
|
+
Model or analyze:
|
|
291
|
+
|
|
292
|
+
- alias sets and disjointness evidence;
|
|
293
|
+
- allocation identity and pointer provenance;
|
|
294
|
+
- object and subobject lifetime;
|
|
295
|
+
- load and store ordering;
|
|
296
|
+
- atomic mode and synchronization scope;
|
|
297
|
+
- volatile and externally visible access;
|
|
298
|
+
- calls and unknown effects;
|
|
299
|
+
- memory versions or reaching definitions under may-alias relationships.
|
|
300
|
+
|
|
301
|
+
Require memory transforms to cite the alias, lifetime, effect, and ordering facts that make them
|
|
302
|
+
legal. If the memory model is incomplete, stay conservative or narrow the optimization contract.
|
|
303
|
+
|
|
304
|
+
## Exceptional suspension and deoptimization control
|
|
305
|
+
|
|
306
|
+
Put every executable continuation in the control-flow model when it affects dominance, liveness,
|
|
307
|
+
cleanup, or value availability.
|
|
308
|
+
|
|
309
|
+
Represent normal return, exceptional unwind, trap, suspension, resume, yield, deoptimization,
|
|
310
|
+
cancellation, and non-return paths with explicit successors or an equally precise region contract.
|
|
311
|
+
State on which edge a call result becomes available. Keep cleanup and ownership transitions tied to
|
|
312
|
+
the actual path.
|
|
313
|
+
|
|
314
|
+
Do not store a possible unwind or suspension only as metadata next to an ordinary returning call.
|
|
315
|
+
Transforms must see paths that constrain motion, phi inputs, resource release, and stack maps.
|
|
316
|
+
|
|
317
|
+
## Value symbol and source identity
|
|
318
|
+
|
|
319
|
+
Separate these identities:
|
|
320
|
+
|
|
321
|
+
- SSA or temporary value identity;
|
|
322
|
+
- declaration and symbol identity;
|
|
323
|
+
- source construct and user-visible operation identity;
|
|
324
|
+
- allocation or storage identity;
|
|
325
|
+
- debug variable and scope identity;
|
|
326
|
+
- clone, inline, macro, specialization, or transform origin.
|
|
327
|
+
|
|
328
|
+
Equal values do not imply equal declarations or source objects. Cloned nodes do not automatically
|
|
329
|
+
represent new user operations. Preserve a stable origin chain across lowering, inlining, cloning,
|
|
330
|
+
folding, and code generation so diagnostics, incremental caches, profiles, and debug information can
|
|
331
|
+
relate optimized artifacts to the right source entity.
|
|
332
|
+
|
|
333
|
+
## Verifier ownership
|
|
334
|
+
|
|
335
|
+
Give every IR stage and transition an owning verifier. Define `required`, `forbidden`, and
|
|
336
|
+
`guaranteed` invariants for the stage instead of weakening one global verifier until it accepts every
|
|
337
|
+
temporary state.
|
|
338
|
+
|
|
339
|
+
Order verification so later checks may rely on earlier ones:
|
|
340
|
+
|
|
341
|
+
1. container, operand-count, result-count, terminator, and structural integrity;
|
|
342
|
+
2. local type, attribute, property, and operation constraints;
|
|
343
|
+
3. trait or interface contracts;
|
|
344
|
+
4. region, CFG, dominance, ownership, effect, and cross-operation semantics;
|
|
345
|
+
5. target layout, ABI, or machine constraints when their context exists.
|
|
346
|
+
|
|
347
|
+
Use a generic defensive printer for malformed artifacts. Do not invoke a custom printer whose own
|
|
348
|
+
preconditions are the broken invariants being diagnosed.
|
|
349
|
+
|
|
350
|
+
Check the relevant subset of:
|
|
351
|
+
|
|
352
|
+
- type and operation legality;
|
|
353
|
+
- block termination and successor shape;
|
|
354
|
+
- predecessor and edge multiplicity;
|
|
355
|
+
- dominance and edge-defined values;
|
|
356
|
+
- phi or block-argument agreement;
|
|
357
|
+
- region isolation and nesting;
|
|
358
|
+
- effect, ownership, and lifetime rules;
|
|
359
|
+
- target and calling-convention constraints;
|
|
360
|
+
- absence of operations forbidden after a lowering stage;
|
|
361
|
+
- analysis currency where it can be checked.
|
|
362
|
+
|
|
363
|
+
Place verifier calls after parsing, generation, lowering, canonicalization, mutation, and every
|
|
364
|
+
transform in debug or validation lanes. Build negative fixtures by violating one named invariant at
|
|
365
|
+
a time.
|
|
366
|
+
|
|
367
|
+
Make invalid IR difficult to construct. Derive typed builders, required properties, parsers,
|
|
368
|
+
printers, and local verification from one operation schema where the repository supports that
|
|
369
|
+
pattern. Restrict raw construction to parsers, deserializers, fuzzers, reducers, and other named
|
|
370
|
+
escape hatches.
|
|
371
|
+
|
|
372
|
+
Keep specialized verifiers independent where the evidence differs:
|
|
373
|
+
|
|
374
|
+
- SSA verifier for live definitions, use-list symmetry, edge arity, terminators, dominance, and
|
|
375
|
+
stale references;
|
|
376
|
+
- ownership verifier for capability-token flow, borrows, moves, escape, and exactly-once release;
|
|
377
|
+
- effect and speculation verifier for motion, duplication, deletion, trap, and capture claims;
|
|
378
|
+
- layout and ABI verifier for size, alignment, address space, aggregate layout, hidden parameters,
|
|
379
|
+
promotions, and caller-callee mapping;
|
|
380
|
+
- semantic refinement checker for whether a structurally valid transform preserves the permitted
|
|
381
|
+
observable behaviors within its supported model.
|
|
382
|
+
|
|
383
|
+
Attack the verifier itself. Starting from valid IR, remove operands, change types, reorder block
|
|
384
|
+
arguments, remove terminators, duplicate owner capabilities, move lifetime ends, overstate
|
|
385
|
+
alignment, leak alias scope, or retain a stale generation. Require stable rejection with the stage,
|
|
386
|
+
operation, invariant identity, location, and related definition; an assertion or verifier crash is a
|
|
387
|
+
verifier defect.
|
|
388
|
+
|
|
389
|
+
## IR mutation transaction
|
|
390
|
+
|
|
391
|
+
Treat an IR mutation and all dependent analysis changes as one transaction.
|
|
392
|
+
|
|
393
|
+
For each mutation API, define:
|
|
394
|
+
|
|
395
|
+
- values, blocks, edges, regions, symbols, and effects changed;
|
|
396
|
+
- analyses updated incrementally;
|
|
397
|
+
- analyses invalidated and recomputed before reuse;
|
|
398
|
+
- worklists, caches, profile data, debug origins, and source maps updated;
|
|
399
|
+
- verifier point before the next consumer;
|
|
400
|
+
- rollback or failure behavior for multi-step rewrites.
|
|
401
|
+
- fact transitions for type, ownership, borrow, lifetime, alias, provenance, alignment, range,
|
|
402
|
+
effect, capture, layout, profile, and target facts using preserve, recompute, weaken, or drop.
|
|
403
|
+
|
|
404
|
+
Do not publish a half-mutated CFG while old dominance, loop, memory, liveness, or call-graph results
|
|
405
|
+
remain queryable. Preserve only analyses whose dependency set the mutation demonstrably leaves
|
|
406
|
+
unchanged. Default unspecified preservation to invalidation. In audit lanes, recompute every analysis
|
|
407
|
+
a pass claims to preserve and compare the full semantic result rather than trusting cache identity.
|
|
408
|
+
|
|
409
|
+
## Canonical-form windows
|
|
410
|
+
|
|
411
|
+
Treat a canonical form as a consumer precondition with an ownership window, not as permanent
|
|
412
|
+
beautification.
|
|
413
|
+
|
|
414
|
+
For each form, name:
|
|
415
|
+
|
|
416
|
+
- the pass that establishes it;
|
|
417
|
+
- the verifier or predicate that recognizes it;
|
|
418
|
+
- the consumers that require it;
|
|
419
|
+
- transformations allowed to break it;
|
|
420
|
+
- the point where it is re-established or no longer required;
|
|
421
|
+
- compile-time and code-size cost of maintaining it.
|
|
422
|
+
|
|
423
|
+
Examples include loop preheaders, latches, dedicated exits, loop-closed SSA, normalized branches,
|
|
424
|
+
and legalized operation sets. Avoid global invariants that force unrelated passes to undo and redo
|
|
425
|
+
the same structure.
|
|
426
|
+
|
|
427
|
+
## Text form replay and version boundary
|
|
428
|
+
|
|
429
|
+
Provide a deterministic, parseable representation for stage-local debugging and tests.
|
|
430
|
+
|
|
431
|
+
Require:
|
|
432
|
+
|
|
433
|
+
- stable ordering or explicit normalization;
|
|
434
|
+
- parse-print-parse structural and semantic round trip;
|
|
435
|
+
- target, data-layout, feature, and schema context;
|
|
436
|
+
- bounded pass-before and pass-after dumps;
|
|
437
|
+
- minimal direct-stage reproduction;
|
|
438
|
+
- verifier diagnostics tied to stable invariant IDs;
|
|
439
|
+
- versioning and compatibility policy.
|
|
440
|
+
|
|
441
|
+
Keep an internal mutable representation separate from a long-lived exchange, plugin, cache, or file
|
|
442
|
+
format unless compatibility is an intentional product contract. Deterministic text is evidence and
|
|
443
|
+
replay infrastructure, not permission to freeze every internal implementation detail.
|
|
444
|
+
|
|
445
|
+
## Phi edge semantics
|
|
446
|
+
|
|
447
|
+
Model a phi or block argument as a value selected by the incoming edge, not as a sequential
|
|
448
|
+
assignment executed inside the destination block.
|
|
449
|
+
|
|
450
|
+
Verify:
|
|
451
|
+
|
|
452
|
+
- one input for every incoming edge, including duplicate edges when the IR distinguishes them;
|
|
453
|
+
- incoming values are available on their specific edges;
|
|
454
|
+
- exceptional or normal-only results are used only on valid successors;
|
|
455
|
+
- all phi decisions at a block entry are simultaneous;
|
|
456
|
+
- edge removal, retargeting, and insertion update every affected phi.
|
|
457
|
+
|
|
458
|
+
Do not key phi inputs only by predecessor block when one predecessor can contribute multiple edges
|
|
459
|
+
with different meanings.
|
|
460
|
+
|
|
461
|
+
## Phi placement and sealed construction
|
|
462
|
+
|
|
463
|
+
Place phi nodes from control and liveness facts, not visual guesses.
|
|
464
|
+
|
|
465
|
+
For batch construction, derive candidates from iterated dominance frontiers and prune values not
|
|
466
|
+
live at the join. For incremental direct SSA construction, keep incomplete phis in blocks whose
|
|
467
|
+
predecessor sets are still open, seal the block only when no more predecessors can arrive, then fill
|
|
468
|
+
and simplify its phis.
|
|
469
|
+
|
|
470
|
+
Exercise loop headers, backedges, unreachable predecessors, exception edges, and later edge
|
|
471
|
+
insertion. Sealing too early omits definitions; sealing too late grows redundant phis and lookup
|
|
472
|
+
cost. Require trivial-phi removal to preserve edge semantics and not rewrite a value to itself
|
|
473
|
+
through a cycle.
|
|
474
|
+
|
|
475
|
+
## Phi select and speculation
|
|
476
|
+
|
|
477
|
+
Do not replace a phi with a select solely because both choose between two values.
|
|
478
|
+
|
|
479
|
+
A phi chooses from the path already taken. A select evaluates a condition at its instruction point
|
|
480
|
+
and requires both candidate values to be available there. Before conversion, prove:
|
|
481
|
+
|
|
482
|
+
- both definitions dominate the select;
|
|
483
|
+
- moving or duplicating their computation is legal;
|
|
484
|
+
- traps, exceptions, poison, memory, and other effects are safe under speculation;
|
|
485
|
+
- control-dependent resource and lifetime behavior is preserved;
|
|
486
|
+
- the target cost model accepts the change when profitability matters.
|
|
487
|
+
|
|
488
|
+
An unexecuted division, load, allocation, or call cannot be hoisted merely to make a select-shaped
|
|
489
|
+
rewrite possible.
|
|
490
|
+
|
|
491
|
+
## Critical duplicate and exceptional edges
|
|
492
|
+
|
|
493
|
+
Split an edge when an edge-specific operation cannot be placed safely in either adjacent block.
|
|
494
|
+
|
|
495
|
+
Check:
|
|
496
|
+
|
|
497
|
+
- predecessors with multiple successors;
|
|
498
|
+
- destinations with multiple predecessors;
|
|
499
|
+
- duplicate edges to the same destination;
|
|
500
|
+
- switch or indirect-control multiplicity;
|
|
501
|
+
- exceptional, cleanup, suspend, and resume edges with insertion restrictions;
|
|
502
|
+
- branch weights, profile identity, source provenance, and loop membership after splitting.
|
|
503
|
+
|
|
504
|
+
Do not apply a generic critical-edge helper to an edge class whose region, exception, or target
|
|
505
|
+
contract forbids arbitrary blocks or instructions.
|
|
506
|
+
|
|
507
|
+
## CFG mutation and SSA repair
|
|
508
|
+
|
|
509
|
+
Combine branch retargeting, block cloning, jump threading, tail duplication, edge splitting, block
|
|
510
|
+
merging, and unreachable removal with SSA repair.
|
|
511
|
+
|
|
512
|
+
Update or recompute:
|
|
513
|
+
|
|
514
|
+
- phi inputs and edge multiplicity;
|
|
515
|
+
- dominance and post-dominance;
|
|
516
|
+
- loop and region membership;
|
|
517
|
+
- loop-closed SSA;
|
|
518
|
+
- memory SSA and alias summaries;
|
|
519
|
+
- liveness and reaching definitions;
|
|
520
|
+
- ownership or borrow facts;
|
|
521
|
+
- profile, debug, and source-origin data;
|
|
522
|
+
- worklists and cached handles.
|
|
523
|
+
|
|
524
|
+
Do not replace uses globally without proving the new definition dominates every rewritten use.
|
|
525
|
+
|
|
526
|
+
## Loop closure and irreducible control
|
|
527
|
+
|
|
528
|
+
Use loop-closed SSA or an equivalent boundary when loop transforms need local ownership of values
|
|
529
|
+
leaving the loop. Put exit values in exit-block phis so cloning, rotation, unswitching, and deletion
|
|
530
|
+
update a bounded interface.
|
|
531
|
+
|
|
532
|
+
Do not assume every cycle is a structured loop with one dominating header. Exercise irreducible
|
|
533
|
+
regions, exitless loops, unreachable cycles, exceptional exits, non-returning blocks, and multiple
|
|
534
|
+
latches. Keep cycle detection, loop-analysis semantics, and language-level structured control as
|
|
535
|
+
separate concepts.
|
|
536
|
+
|
|
537
|
+
## SSA destruction
|
|
538
|
+
|
|
539
|
+
Lower phi semantics to parallel copies on predecessor edges or equivalent split blocks.
|
|
540
|
+
|
|
541
|
+
Build the complete copy set before scheduling. Detect cycles such as simultaneous exchanges and use
|
|
542
|
+
temporary locations or a proven scheduling algorithm. Preserve register classes, subregisters,
|
|
543
|
+
widths, exceptional-edge restrictions, and liveness. Split critical edges where copies cannot be
|
|
544
|
+
placed without affecting another path.
|
|
545
|
+
|
|
546
|
+
Run coalescing only under interference and target constraints. Destroy SSA late enough to retain
|
|
547
|
+
sparse-analysis and optimization benefits, but before consumers require physical or two-address
|
|
548
|
+
machine constraints.
|
|
549
|
+
|
|
550
|
+
## Pass contracts
|
|
551
|
+
|
|
552
|
+
Give every pass a machine-checkable or reviewable contract:
|
|
553
|
+
|
|
554
|
+
- accepted IR layer and canonical forms;
|
|
555
|
+
- semantic and definedness preconditions;
|
|
556
|
+
- legal operation, type, effect, and target subset;
|
|
557
|
+
- transformations it may perform;
|
|
558
|
+
- structural and semantic postconditions;
|
|
559
|
+
- analyses preserved, updated, or invalidated;
|
|
560
|
+
- source, debug, profile, and identity obligations;
|
|
561
|
+
- termination, convergence, code-size, and compile-time budget;
|
|
562
|
+
- verifier and activation evidence.
|
|
563
|
+
|
|
564
|
+
An executed pass that declines every candidate does not exercise its transformation. Record trigger
|
|
565
|
+
and rejection reasons separately from pass invocation.
|
|
566
|
+
|
|
567
|
+
## Information-aware pass ordering
|
|
568
|
+
|
|
569
|
+
Build the pipeline from producer and consumer contracts.
|
|
570
|
+
|
|
571
|
+
For every adjacent pass pair, ask:
|
|
572
|
+
|
|
573
|
+
- did the producer establish the consumer's required form and analyses;
|
|
574
|
+
- did an earlier lowering destroy information a later transform needs;
|
|
575
|
+
- did a transform expose new cleanup or propagation opportunities;
|
|
576
|
+
- did code growth make a later analysis or transform unprofitable;
|
|
577
|
+
- did target information arrive early enough for legality and cost without infecting high-level
|
|
578
|
+
semantics;
|
|
579
|
+
- did instrumentation or debug mapping observe the intended program version;
|
|
580
|
+
- did analysis invalidation occur before the next query.
|
|
581
|
+
|
|
582
|
+
Do not arrange passes by name familiarity or one benchmark result.
|
|
583
|
+
|
|
584
|
+
## Normalization and cleanup budgets
|
|
585
|
+
|
|
586
|
+
Run normalization and cleanup around transformations that create their opportunities, not blindly
|
|
587
|
+
to a global fixed point.
|
|
588
|
+
|
|
589
|
+
Record:
|
|
590
|
+
|
|
591
|
+
- which rewrite families can enable one another;
|
|
592
|
+
- a monotonic measure or bounded iteration count;
|
|
593
|
+
- per-iteration IR change, code-size, compile-time, and memory cost;
|
|
594
|
+
- oscillation fingerprints;
|
|
595
|
+
- canonical-form conflicts between passes;
|
|
596
|
+
- no-change termination.
|
|
597
|
+
|
|
598
|
+
If two passes prefer opposite forms, define a phase owner or one-way boundary. Do not hide an
|
|
599
|
+
oscillation behind a timeout or a large arbitrary iteration limit.
|
|
600
|
+
|
|
601
|
+
## Inlining promotion and scalarization
|
|
602
|
+
|
|
603
|
+
Stage inlining by obligation and profitability. Separate mandatory semantic inlining from
|
|
604
|
+
profile- or cost-driven inlining and retain cleanup afterward. Too-early broad inlining duplicates
|
|
605
|
+
cold or unoptimized paths; too-late inlining hides constant arguments, devirtualization,
|
|
606
|
+
specialization, and interprocedural simplification.
|
|
607
|
+
|
|
608
|
+
Promote memory temporaries when doing so clarifies value flow for later analyses. Do not confuse
|
|
609
|
+
promotion with destroying high-level aggregates, vectors, tensors, ownership groups, or layout
|
|
610
|
+
intent. Scalarize only after the last consumer of the wider semantic structure and under a target or
|
|
611
|
+
cost contract that justifies it.
|
|
612
|
+
|
|
613
|
+
## Propagation CFG simplification and deletion
|
|
614
|
+
|
|
615
|
+
Treat constant propagation, branch simplification, unreachable elimination, phi folding, and dead
|
|
616
|
+
code deletion as a bounded cooperating group.
|
|
617
|
+
|
|
618
|
+
After propagation changes a condition, simplify the CFG and remove newly dead definitions. After
|
|
619
|
+
deletion and block merging, revisit phis and newly exposed constants. Bound repetition by actual
|
|
620
|
+
change and cost. Preserve effects, traps, exceptional paths, source identities, and debug or profile
|
|
621
|
+
mapping while deleting apparently unused operations.
|
|
622
|
+
|
|
623
|
+
Do not use one final output comparison as evidence that every intermediate analysis remained valid.
|
|
624
|
+
|
|
625
|
+
## Loop transformation pipeline
|
|
626
|
+
|
|
627
|
+
Prepare loop transforms with the structures and analyses they require:
|
|
628
|
+
|
|
629
|
+
- canonical loop entry, latch, and exits;
|
|
630
|
+
- loop-closed values;
|
|
631
|
+
- induction and trip-count facts;
|
|
632
|
+
- alias, dependence, effect, and memory-order evidence;
|
|
633
|
+
- profile and target cost information;
|
|
634
|
+
- code-size and register-pressure budgets.
|
|
635
|
+
|
|
636
|
+
Run destructive code-growth transforms in an order that does not erase vectorization, fusion,
|
|
637
|
+
distribution, or target opportunities prematurely. Keep legality separate from profitability. Apply
|
|
638
|
+
late unrolling or cleanup to remaining loops only after earlier consumers have made their decisions.
|
|
639
|
+
|
|
640
|
+
## Target-lowering boundary
|
|
641
|
+
|
|
642
|
+
Introduce target details in stages:
|
|
643
|
+
|
|
644
|
+
1. retain target-independent semantics while consulting target cost where safe;
|
|
645
|
+
2. legalize types and operations under explicit representation mappings;
|
|
646
|
+
3. select instructions into target-aware virtual-register form;
|
|
647
|
+
4. perform machine-level optimization and scheduling;
|
|
648
|
+
5. destroy SSA and allocate physical resources;
|
|
649
|
+
6. finalize frames, prologues, epilogues, relaxation, and late cleanup.
|
|
650
|
+
|
|
651
|
+
Do not commit to physical registers and opcodes before target-independent transforms finish. Do not
|
|
652
|
+
delay target legality, address modes, immediate limits, calling convention, or register constraints
|
|
653
|
+
until after decisions that require them.
|
|
654
|
+
|
|
655
|
+
## Instrumentation profile and debug placement
|
|
656
|
+
|
|
657
|
+
Place sanitizers, coverage, profile collection, stack maps, tracing, and debug propagation according
|
|
658
|
+
to the source or optimized program they are intended to observe.
|
|
659
|
+
|
|
660
|
+
Record:
|
|
661
|
+
|
|
662
|
+
- source operations that must remain instrumented;
|
|
663
|
+
- optimization that may merge, clone, or remove them;
|
|
664
|
+
- counter and profile identity through CFG changes;
|
|
665
|
+
- runtime effects introduced by instrumentation;
|
|
666
|
+
- ordering constraints with lowering and code generation;
|
|
667
|
+
- origin-chain updates after cloning and inlining;
|
|
668
|
+
- effect on optimization legality, code size, and timing.
|
|
669
|
+
|
|
670
|
+
Do not insert instrumentation at a convenient pass-manager hook without defining its observation
|
|
671
|
+
contract.
|
|
672
|
+
|
|
673
|
+
## Pipeline interaction evidence
|
|
674
|
+
|
|
675
|
+
Test passes individually and as interacting sequences.
|
|
676
|
+
|
|
677
|
+
Require a bounded matrix containing:
|
|
678
|
+
|
|
679
|
+
- verifier-after-each-transform lanes;
|
|
680
|
+
- pass-before and pass-after direct-stage fixtures;
|
|
681
|
+
- analysis recomputation comparisons;
|
|
682
|
+
- known prerequisite and cleanup sequences;
|
|
683
|
+
- alternate valid pass sequences where supported;
|
|
684
|
+
- random or generated valid pass-transition paths;
|
|
685
|
+
- optimization-before and optimization-after execution comparison;
|
|
686
|
+
- translation validation for supported transforms;
|
|
687
|
+
- code size, compile time, peak memory, spills, and cold-path growth;
|
|
688
|
+
- source, debug, profile, and instrumentation mapping.
|
|
689
|
+
|
|
690
|
+
Reduce a failing sequence while preserving the first violated contract, not merely the final wrong
|
|
691
|
+
output.
|
|
692
|
+
|
|
693
|
+
## Failure matrix
|
|
694
|
+
|
|
695
|
+
| Failure or design smell | Required response |
|
|
696
|
+
| --- | --- |
|
|
697
|
+
| Operation grammar exists but overflow or effects are unspecified. | Define the semantic contract before adding transforms. |
|
|
698
|
+
| A new IR layer differs only by node names. | Merge it or identify the conflicting invariant that justifies the layer. |
|
|
699
|
+
| Lowering erases intent needed by a later pass. | Move lowering after the consumer or preserve an explicit abstraction. |
|
|
700
|
+
| High- and low-level operations mix without legality rules. | Define partial or complete conversion and a verifier. |
|
|
701
|
+
| A value changes representation in place. | Create an explicit conversion result and retire old uses through a checked boundary. |
|
|
702
|
+
| Ownership is a copyable flag on a pointer. | Use a non-forgeable capability flow tied to allocation identity. |
|
|
703
|
+
| Borrow and alias analysis are treated as one fact. | Separate address overlap from access permission and lifetime. |
|
|
704
|
+
| A reused address is treated as the same object. | Track allocation identity and lifetime epoch independently from address. |
|
|
705
|
+
| Facts survive a merge or clone by union. | Retain only jointly proven facts and apply an explicit fact-transition rule. |
|
|
706
|
+
| A stale fact has no generation or invalidation owner. | Make it unavailable until recomputed or re-established by a guard. |
|
|
707
|
+
| Missing effect metadata is interpreted as pure. | Treat missing information as unknown and stay conservative. |
|
|
708
|
+
| Scalar SSA is treated as alias proof. | Add memory, provenance, lifetime, and effect analysis. |
|
|
709
|
+
| Unwind or suspension exists only as metadata. | Put the continuation into the control-flow contract. |
|
|
710
|
+
| CFG changes but preserved analyses remain queryable. | Update or invalidate them in the same mutation transaction. |
|
|
711
|
+
| Canonical form is maintained globally without a consumer. | Restrict it to an ownership window. |
|
|
712
|
+
| Phi input is keyed only by predecessor block. | Preserve incoming-edge multiplicity and availability. |
|
|
713
|
+
| Phi is replaced by select with trapping operands. | Prove speculation safety or keep control dependence. |
|
|
714
|
+
| SSA copies are emitted sequentially and overwrite a cycle. | Schedule a parallel-copy set with temporaries. |
|
|
715
|
+
| Cleanup passes oscillate. | Add a phase direction, monotonic measure, and bounded budget. |
|
|
716
|
+
| Target information arrives after legality decisions. | Move the required target contract earlier without leaking physical form upward. |
|
|
717
|
+
| Each pass passes alone but the pipeline miscompiles. | Preserve and reduce the first failing pass interaction. |
|
|
718
|
+
| The verifier accepts only positive fixtures. | Mutate one invariant at a time and require stable rejection diagnostics. |
|
|
719
|
+
| Structural verification is called semantic preservation. | Add an independent refinement, execution, or differential oracle. |
|
|
720
|
+
|
|
721
|
+
## Invariants
|
|
722
|
+
|
|
723
|
+
- Every IR operation has defined value, control, effect, failure, and memory semantics.
|
|
724
|
+
- Every IR layer names its information, invariants, consumers, verifier, lowering, and lifetime.
|
|
725
|
+
- Lowering destroys information only after the last declared consumer or through a checked mapping.
|
|
726
|
+
- Mixed-level IR has explicit legality and completion rules.
|
|
727
|
+
- Semantic types remain distinct from target storage and ABI types until a named boundary.
|
|
728
|
+
- Representation changes create explicit values and declare every preserved or destroyed fact.
|
|
729
|
+
- Ownership release authority is non-forgeable and distinct from pointer or view aliasing.
|
|
730
|
+
- Borrow permission, alias possibility, object lifetime, allocation identity, address, and provenance
|
|
731
|
+
remain separate facts.
|
|
732
|
+
- Every optimization fact names its origin, scope, epoch, generation, status, consumers, and
|
|
733
|
+
invalidating transitions.
|
|
734
|
+
- Missing or stale effects and analyses default to unknown or unavailable, not optimistic reuse.
|
|
735
|
+
- Exceptional, suspended, deoptimized, and non-returning behavior participates in control flow.
|
|
736
|
+
- Value, symbol, source, storage, and debug identities are not conflated.
|
|
737
|
+
- Every IR mutation updates or invalidates dependent analyses before another consumer runs.
|
|
738
|
+
- Every IR stage has ordered structural, local, region, ownership, effect, and target verification
|
|
739
|
+
appropriate to that stage.
|
|
740
|
+
- Every verifier rule has a focused negative or mutation fixture, and structural validity remains
|
|
741
|
+
distinct from semantic refinement.
|
|
742
|
+
- Phi inputs correspond to incoming edges and SSA destruction preserves parallel-copy semantics.
|
|
743
|
+
- Canonical forms exist for named consumers and bounded ownership windows.
|
|
744
|
+
- Pass ordering follows prerequisites, preserved information, target needs, and cost budgets.
|
|
745
|
+
- Pipeline interaction evidence localizes the first violated stage contract.
|
|
746
|
+
|
|
747
|
+
## Skill handoffs
|
|
748
|
+
|
|
749
|
+
- Use `compiler-engineering-review` for IR semantics, layer boundaries, CFG and SSA, analysis
|
|
750
|
+
preservation, pass pipelines, lowering, optimization, code generation, and compiler oracles.
|
|
751
|
+
- Use `parser-engineering-review` for lexer, CST, AST construction, syntax recovery, source ranges,
|
|
752
|
+
and incremental parse structure before semantic lowering.
|
|
753
|
+
- Use `formal-verification-review` for deductive refinement, bounded model checking, solver evidence,
|
|
754
|
+
or formal proof of an IR transform or pipeline relation.
|
|
755
|
+
- Use `fuzz-harness-review` for generic harness reset, mutation feedback, corpus, campaign,
|
|
756
|
+
sanitizer, crash minimization, and long-running fuzz operation.
|
|
757
|
+
- Use `race-condition-review` for concrete compiler-internal schedules, shared analysis caches,
|
|
758
|
+
concurrent mutation, and memory ordering.
|
|
759
|
+
- Use `test-maintenance` for deterministic stage and pipeline regression fixtures.
|