Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/passes/DeadArgumentElimination2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ struct DAE2 : public Pass {
// This pass changes locals and parameters.
bool invalidatesDWARF() override { return true; }

// Optimizer already handles non-nullable local fixups on modified functions
// before global type rewriting updates referenced function types.
bool requiresNonNullableLocalFixups() override { return false; }

// Analysis lattice.
Used used;

Expand Down
59 changes: 59 additions & 0 deletions test/lit/passes/dae2.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3599,6 +3599,65 @@
)
)

(module
;; CHECK: (type $0 (func (param i32)))

;; CHECK: (global $g (mut anyref) (ref.null none))
(global $g (mut anyref) (ref.null none))

;; CHECK: (func $test (type $0) (param $x i32)
;; CHECK-NEXT: (local $unused anyref)
;; CHECK-NEXT: (if
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (local.set $unused
;; CHECK-NEXT: (ref.i31
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (else
;; CHECK-NEXT: (local.set $unused
;; CHECK-NEXT: (ref.i31
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (global.set $g
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (local.get $unused)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (param $unused (ref any)) (param $x i32)
;; The initial parameter value is never read because both arms overwrite
;; $unused before the global.set. Removing the parameter turns $unused into
;; a non-nullable local whose sets do not structurally dominate the get, so
;; Optimizer must handle the fixup internally.
(if
(local.get $x)
(then
(local.set $unused
(ref.i31
(i32.const 0)
)
)
)
(else
(local.set $unused
(ref.i31
(i32.const 1)
)
)
)
)
(global.set $g
(local.get $unused)
)
)
)

(module
;; CHECK: (type $struct (struct))
(type $struct (struct))
Expand Down
Loading