File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -383,13 +383,14 @@ struct DAE : public Pass {
383383 while (1 ) {
384384 if (infoMap[name].unusedParams .has (i)) {
385385 // Great, it's not used. Check if none of the calls has a param with
386- // side effects, as that would prevent us removing them (flattening
387- // should have been done earlier).
386+ // side effects that we cannot remove (as if we can remove them, we
387+ // will simply do that when we remove the parameter). Note: flattening
388+ // the IR beforehand can help here.
388389 bool callParamsAreValid =
389390 std::none_of (calls.begin (), calls.end (), [&](Call* call) {
390391 auto * operand = call->operands [i];
391392 return EffectAnalyzer (runner->options , *module , operand)
392- .hasSideEffects ();
393+ .hasUnremovableSideEffects ();
393394 });
394395 // The type must be valid for us to handle as a local (since we
395396 // replace the parameter with a local).
Original file line number Diff line number Diff line change 1+ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
3+ ;; RUN: foreach %s %t wasm-opt --dae --all-features -tnh -S -o - | filecheck %s
4+
5+ (module
6+ ;; CHECK: (type $none_=>_none (func))
7+
8+ ;; CHECK: (type $ref?|$struct|_=>_none (func (param (ref null $struct))))
9+
10+ ;; CHECK: (type $struct (struct (field i32)))
11+ (type $struct (struct_subtype (field i32 ) data ))
12+
13+ ;; CHECK: (func $target
14+ ;; CHECK-NEXT: (local $0 i32)
15+ ;; CHECK-NEXT: (nop)
16+ ;; CHECK-NEXT: )
17+ (func $target (param $x i32 )
18+ (nop )
19+ )
20+
21+ ;; CHECK: (func $caller (param $ref (ref null $struct))
22+ ;; CHECK-NEXT: (call $target)
23+ ;; CHECK-NEXT: )
24+ (func $caller (param $ref (ref null $struct ))
25+ (call $target
26+ ;; This might trap in theory, but in traps-never-happen mode which is
27+ ;; enabled here, we can ignore and remove such side effects, allowing us
28+ ;; to optimize away this parameter which is never used.
29+ (struct.get $struct 0
30+ (local.get $ref )
31+ )
32+ )
33+ )
34+ )
You can’t perform that action at this time.
0 commit comments