Skip to content

Commit ac59711

Browse files
Add test for unreachable ref
1 parent 8a0e725 commit ac59711

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/passes/GlobalEffects.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#include "ir/effects.h"
2525
#include "ir/module-utils.h"
26-
#include "ir/subtypes.h"
2726
#include "pass.h"
2827
#include "support/strongly_connected_components.h"
2928
#include "wasm.h"

test/lit/passes/global-effects-closed-world.wast

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,30 @@
343343
(call $indirect-calls (local.get $ref))
344344
)
345345
)
346+
347+
(module
348+
(type $t (func (param i32)))
349+
;; CHECK: (func $calls-unreachable (type $0)
350+
;; CHECK-NEXT: (block ;; (replaces unreachable CallRef we can't emit)
351+
;; CHECK-NEXT: (drop
352+
;; CHECK-NEXT: (unreachable)
353+
;; CHECK-NEXT: )
354+
;; CHECK-NEXT: (drop
355+
;; CHECK-NEXT: (unreachable)
356+
;; CHECK-NEXT: )
357+
;; CHECK-NEXT: (unreachable)
358+
;; CHECK-NEXT: )
359+
;; CHECK-NEXT: )
360+
(func $calls-unreachable (export "calls-unreachable")
361+
(call_ref $t (unreachable))
362+
)
363+
364+
;; CHECK: (func $f (type $0)
365+
;; CHECK-NEXT: (call $calls-unreachable)
366+
;; CHECK-NEXT: )
367+
(func $f
368+
;; $t looks like it has no effects, but unreachable is passed in,
369+
;; so preserve the trap.
370+
(call $calls-unreachable)
371+
)
372+
)

0 commit comments

Comments
 (0)