Skip to content

return_call with call.without.effects optimizes incorrectly #8693

@stevenfontanella

Description

@stevenfontanella

In the following module, $f always returns 1.

(module
  (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (param funcref) (result i32)))
  (func $g (result i32)
    (i32.const 1)
  )
  (func $f (result i32)
    (return_call $call-without-effects (ref.func $g))
    (unreachable)
  )
)

But when optimized with bin/wasm-opt -all --vacuum a.wat -S -o - (from the current main), we end up with the following module which returns 0:

(module
 (type $0 (func (result i32)))
 (type $1 (func (param funcref) (result i32)))
 (import "binaryen-intrinsics" "call.without.effects" (func $call-without-effects (type $1) (param funcref) (result i32)))
 (func $g (type $0) (result i32)
  (i32.const 1)
 )
 (func $f (type $0) (result i32)
  (i32.const 0)
 )
)

The problem is that call.without.effects doesn't set a branchesOut effect. Although call.without.effects assumes that the call body has no effects, the return_call does have the effect of branching out which isn't reflected correctly here.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions