Skip to content

Commit 9e040e5

Browse files
committed
feat: Update Passes
1 parent b28725c commit 9e040e5

File tree

2 files changed

+238
-55
lines changed

2 files changed

+238
-55
lines changed

src/passes.ml

Lines changed: 122 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ let avoid_reinterprets = "avoid-reinterprets"
1212
(** removes arguments to calls in an lto-like manner *)
1313
let dae = "dae"
1414

15-
(** removes arguments to calls in an lto-like manner, and optimizes where we removed *)
15+
(** removes arguments to calls in an lto-like manner, and optimizes where we
16+
removed *)
1617
let dae_optimizing = "dae-optimizing"
1718

1819
(** refine and merge abstract (never-created) types *)
@@ -36,12 +37,18 @@ let const_hoisting = "const-hoisting"
3637
(** propagate constant struct field values *)
3738
let cfp = "cfp"
3839

40+
(** propagate constant struct field values, using ref.test *)
41+
let cfp_reftest = "cfp-reftest"
42+
3943
(** removes unreachable code *)
4044
let dce = "dce"
4145

4246
(** forces all loads and stores to have alignment 1 *)
4347
let dealign = "dealign"
4448

49+
(** propagate debug location from parents or previous siblings to child nodes *)
50+
let propagate_debug_locs = "propagate-debug-locs"
51+
4552
(** instrument the wasm to convert NaNs into 0 at runtime *)
4653
let denan = "denan"
4754

@@ -66,6 +73,9 @@ let duplicate_function_elimination = "duplicate-function-elimination"
6673
(** emit the target features section in the output *)
6774
let emit_target_features = "emit-target-features"
6875

76+
(** modify the wasm (destructively) for closed-world *)
77+
let enclose_world = "enclose-world"
78+
6979
(** leaves just one function (useful for debugging) *)
7080
let extract_function = "extract-function"
7181

@@ -75,7 +85,8 @@ let extract_function_index = "extract-function-index"
7585
(** flattens out code, removing nesting *)
7686
let flatten = "flatten"
7787

78-
(** emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work *)
88+
(** emulates function pointer casts, allowing incorrect indirect calls to
89+
(sometimes) work *)
7990
let fpcast_emu = "fpcast-emu"
8091

8192
(** reports function metrics *)
@@ -84,15 +95,14 @@ let func_metrics = "func-metrics"
8495
(** generate dynCall fuctions used by emscripten ABI *)
8596
let generate_dyncalls = "generate-dyncalls"
8697

87-
(** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *)
98+
(** generate dynCall functions used by emscripten ABI, but only for functions
99+
with i64 in their signature (which cannot be invoked via the wasm table
100+
without JavaScript BigInt support). *)
88101
let generate_i64_dyncalls = "generate-i64-dyncalls"
89102

90103
(** generate global effect info (helps later passes) *)
91104
let generate_global_effects = "generate-global-effects"
92105

93-
(** generate Stack IR *)
94-
let generate_stack_ir = "generate-stack-ir"
95-
96106
(** refine the types of globals *)
97107
let global_refining = "global-refining"
98108

@@ -102,18 +112,34 @@ let gsi = "gsi"
102112
(** globally optimize GC types *)
103113
let gto = "gto"
104114

105-
(** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *)
115+
(** Grand Unified Flow Analysis: optimize the entire program using information
116+
about what content can actually appear in each location *)
106117
let gufa = "gufa"
107118

119+
(** GUFA plus add casts for all inferences *)
120+
let gufa_cast_all = "gufa-cast-all"
121+
108122
(** GUFA plus local optimizations in functions we modified *)
109123
let gufa_optimizing = "gufa-optimizing"
110124

125+
(** optimizes J2CL specific constructs. *)
126+
let optimize_j2cl = "optimize-j2cl"
127+
128+
(** Merges itable structures into vtables to make types more compact *)
129+
let merge_j2cl_itables = "merge-j2cl-itables"
130+
111131
(** apply more specific subtypes to type fields where possible *)
112132
let type_refining = "type-refining"
113133

134+
(** apply more specific subtypes to type fields where possible (using GUFA) *)
135+
let type_refining_gufa = "type-refining-gufa"
136+
114137
(** replace GC allocations with locals *)
115138
let heap2local = "heap2local"
116139

140+
(** optimize heap (GC) stores *)
141+
let heap_store_optimization = "heap-store-optimization"
142+
117143
(** inline __original_main into main *)
118144
let inline_main = "inline-main"
119145

@@ -132,8 +158,8 @@ let jspi = "jspi"
132158
(** legalizes i64 types on the import/export boundary *)
133159
let legalize_js_interface = "legalize-js-interface"
134160

135-
(** legalizes i64 types on the import/export boundary in a minimal manner, only on things only JS will call *)
136-
let legalize_js_interface_minimally = "legalize-js-interface-minimally"
161+
(** legalizes the import/export boundary and prunes when needed *)
162+
let legalize_and_prune_js_interface = "legalize-and-prune-js-interface"
137163

138164
(** common subexpression elimination inside basic blocks *)
139165
let local_cse = "local-cse"
@@ -147,6 +173,9 @@ let log_execution = "log-execution"
147173
(** lower all uses of i64s to use i32s instead *)
148174
let i64_to_i32_lowering = "i64-to-i32-lowering"
149175

176+
(** instrument the build with code to intercept specific function calls *)
177+
let trace_calls = "trace-calls"
178+
150179
(** instrument the build with code to intercept all loads and stores *)
151180
let instrument_locals = "instrument-locals"
152181

@@ -162,6 +191,13 @@ let limit_segments = "limit-segments"
162191
(** lower loads and stores to a 64-bit memory to instead use a 32-bit one *)
163192
let memory64_lowering = "memory64-lowering"
164193

194+
(** alias for memory64-lowering *)
195+
let table64_lowering = "table64-lowering"
196+
197+
(** Lower memory.copy and memory.fill to wasm mvp and disable the bulk-memory
198+
feature. *)
199+
let llvm_memory_copy_fill_lowering = "llvm-memory-copy-fill-lowering"
200+
165201
(** packs memory into separate segments, skipping zeros *)
166202
let memory_packing = "memory-packing"
167203

@@ -177,17 +213,24 @@ let merge_locals = "merge-locals"
177213
(** reports metrics *)
178214
let metrics = "metrics"
179215

180-
(** minifies import names (only those, and not export names), and emits a mapping to the minified ones *)
216+
(** minifies import names (only those, and not export names), and emits a
217+
mapping to the minified ones *)
181218
let minify_imports = "minify-imports"
182219

183-
(** minifies both import and export names, and emits a mapping to the minified ones *)
220+
(** minifies both import and export names, and emits a mapping to the minified
221+
ones *)
184222
let minify_imports_and_exports = "minify-imports-and-exports"
185223

186-
(** minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well *)
224+
(** minifies both import and export names, and emits a mapping to the minified
225+
ones, and minifies the modules as well *)
187226
let minify_imports_and_exports_and_modules =
188227
"minify-imports-and-exports-and-modules"
189228

190-
(** apply the assumption that asyncify imports always unwind, and we never rewind *)
229+
(** Split types into minimal recursion groups *)
230+
let minimize_rec_groups = "minimize-rec-groups"
231+
232+
(** apply the assumption that asyncify imports always unwind, and we never
233+
rewind *)
191234
let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind"
192235

193236
(** apply the assumption that asyncify never unwinds *)
@@ -202,7 +245,8 @@ let monomorphize_always = "monomorphize-always"
202245
(** combines multiple memories into a single memory *)
203246
let multi_memory_lowering = "multi-memory-lowering"
204247

205-
(** combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data *)
248+
(** combines multiple memories into a single memory, trapping if the read or
249+
write is larger than the length of the memory's data *)
206250
let multi_memory_lowering_with_bounds_checks =
207251
"multi-memory-lowering-with-bounds-checks"
208252

@@ -212,13 +256,27 @@ let nm = "nm"
212256
(** (re)name all heap types *)
213257
let name_types = "name-types"
214258

259+
(** mark functions as no-inline *)
260+
let no_inline = "no-inline"
261+
262+
(** mark functions as no-inline (for full inlining only) *)
263+
let no_full_inline = "no-full-inline"
264+
265+
(** mark functions as no-inline (for partial inlining only) *)
266+
let no_partial_inline = "no-partial-inline"
267+
268+
(** lower nontrapping float-to-int operations to wasm mvp and disable the
269+
nontrapping fptoint feature *)
270+
let llvm_nontrapping_fptoint_lowering = "llvm-nontrapping-fptoint-lowering"
271+
215272
(** reduces calls to code that only runs once *)
216273
let once_reduction = "once-reduction"
217274

218275
(** optimizes added constants into load/store offsets *)
219276
let optimize_added_constants = "optimize-added-constants"
220277

221-
(** optimizes added constants into load/store offsets, propagating them across locals too *)
278+
(** optimizes added constants into load/store offsets, propagating them across
279+
locals too *)
222280
let optimize_added_constants_propagate = "optimize-added-constants-propagate"
223281

224282
(** eliminate and reuse casts *)
@@ -227,9 +285,6 @@ let optimize_casts = "optimize-casts"
227285
(** optimizes instruction combinations *)
228286
let optimize_instructions = "optimize-instructions"
229287

230-
(** optimize Stack IR *)
231-
let optimize_stack_ir = "optimize-stack-ir"
232-
233288
(** pick load signs based on their uses *)
234289
let pick_load_signs = "pick-load-signs"
235290

@@ -245,7 +300,8 @@ let optimize_for_js = "optimize-for-js"
245300
(** computes compile-time evaluatable expressions *)
246301
let precompute = "precompute"
247302

248-
(** computes compile-time evaluatable expressions and propagates them through locals *)
303+
(** computes compile-time evaluatable expressions and propagates them through
304+
locals *)
249305
let precompute_propagate = "precompute-propagate"
250306

251307
(** print in s-expression format *)
@@ -269,15 +325,15 @@ let print_function_map = "print-function-map"
269325
(** alias for print_function_map *)
270326
let symbolmap = "symbolmap"
271327

272-
(** print out Stack IR (useful for internal debugging) *)
273-
let print_stack_ir = "print-stack-ir"
274-
275328
(** removes operations incompatible with js *)
276329
let remove_non_js_ops = "remove-non-js-ops"
277330

278331
(** removes imports and replaces them with nops *)
279332
let remove_imports = "remove-imports"
280333

334+
(** removes memory initialization *)
335+
let remove_memory_init = "remove-memory-init"
336+
281337
(** removes memory segments *)
282338
let remove_memory = "remove-memory"
283339

@@ -297,15 +353,15 @@ let remove_unused_names = "remove-unused-names"
297353
(** remove unused private GC types *)
298354
let remove_unused_types = "remove-unused-types"
299355

356+
(** sorts functions by name (useful for debugging) *)
357+
let reorder_functions_by_name = "reorder-functions-by-name"
358+
300359
(** sorts functions by access frequency *)
301360
let reorder_functions = "reorder-functions"
302361

303362
(** sorts globals by access frequency *)
304363
let reorder_globals = "reorder-globals"
305364

306-
(** sorts globals by access frequency (even if there are few) *)
307-
let reorder_globals_always = "reorder-globals-always"
308-
309365
(** sorts locals by access frequency *)
310366
let reorder_locals = "reorder-locals"
311367

@@ -324,25 +380,31 @@ let safe_heap = "safe-heap"
324380
(** sets specified globals to specified values *)
325381
let set_globals = "set-globals"
326382

383+
(** write data segments to a file and strip them from the module *)
384+
let separate_data_segments = "separate-data-segments"
385+
327386
(** remove params from function signature types where possible *)
328387
let signature_pruning = "signature-pruning"
329388

330389
(** apply more specific subtypes to signature types where possible *)
331390
let signature_refining = "signature-refining"
332391

333-
(** lower sign-ext operations to wasm mvp and disable the sign extension feature *)
392+
(** lower sign-ext operations to wasm mvp and disable the sign extension feature
393+
*)
334394
let signext_lowering = "signext-lowering"
335395

336396
(** miscellaneous globals-related optimizations *)
337397
let simplify_globals = "simplify-globals"
338398

339-
(** miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants *)
399+
(** miscellaneous globals-related optimizations, and optimizes where we replaced
400+
global.gets with constants *)
340401
let simplify_globals_optimizing = "simplify-globals-optimizing"
341402

342403
(** miscellaneous locals-related optimizations *)
343404
let simplify_locals = "simplify-locals"
344405

345-
(** miscellaneous locals-related optimizations (no nesting at all; preserves flatness) *)
406+
(** miscellaneous locals-related optimizations (no nesting at all; preserves
407+
flatness) *)
346408
let simplify_locals_nonesting = "simplify-locals-nonesting"
347409

348410
(** miscellaneous locals-related optimizations (no tees) *)
@@ -372,6 +434,23 @@ let ssa = "ssa"
372434
(** ssa-ify variables so that they have a single assignment, ignoring merges *)
373435
let ssa_nomerge = "ssa-nomerge"
374436

437+
(** gathers wasm strings to globals *)
438+
let string_gathering = "string-gathering"
439+
440+
(** lift string imports to wasm strings *)
441+
let string_lifting = "string-lifting"
442+
443+
(** lowers wasm strings and operations to imports *)
444+
let string_lowering = "string-lowering"
445+
446+
(** same as string-lowering, but encodes well-formed strings as magic imports *)
447+
let string_lowering_magic_imports = "string-lowering-magic-imports"
448+
449+
(** same as string-lowering-magic-imports, but raise a fatal error if there are
450+
invalid strings *)
451+
let string_lowering_magic_imports_assert =
452+
"string-lowering-magic-imports-assert"
453+
375454
(** deprecated; same as strip-debug *)
376455
let strip = "strip"
377456

@@ -393,18 +472,33 @@ let strip_eh = "strip-eh"
393472
(** strip the wasm target features section *)
394473
let strip_target_features = "strip-target-features"
395474

475+
(** translate old Phase 3 EH instructions to new ones with exnref *)
476+
let translate_to_exnref = "translate-to-exnref"
477+
396478
(** replace trapping operations with clamping semantics *)
397479
let trap_mode_clamp = "trap-mode-clamp"
398480

399481
(** replace trapping operations with js semantics *)
400482
let trap_mode_js = "trap-mode-js"
401483

484+
(** optimize trivial tuples away *)
485+
let tuple_optimization = "tuple-optimization"
486+
487+
(** mark all leaf types as final *)
488+
let type_finalizing = "type-finalizing"
489+
402490
(** merge types to their supertypes where possible *)
403491
let type_merging = "type-merging"
404492

405493
(** create new nominal types to help other optimizations *)
406494
let type_ssa = "type-ssa"
407495

496+
(** mark all types as non-final (open) *)
497+
let type_unfinalizing = "type-unfinalizing"
498+
499+
(** removes removes unnecessary subtyping relationships *)
500+
let unsubtyping = "unsubtyping"
501+
408502
(** removes local.tees, replacing them with sets and gets *)
409503
let untee = "untee"
410504

0 commit comments

Comments
 (0)