Skip to content

Dead-store-elimintation removes visible stores from divergent paths #14053

Description

@alexcrichton

This input:

(module
  (memory (export "mem") 1)
  (func (export "f") (param $p i32) (param $q i32)
    (i32.store (i32.const 0) (i32.const 111))
    (if (local.get $p)
      (then (i32.store (i32.const 0) (i32.const 222)))
      (else
        (i32.store (local.get $q) (i32.const 7))
        (loop (br 0))))
  )
  (func (export "get") (result i32) (i32.load (i32.const 0)))
)

(assert_trap (invoke "f" (i32.const 0) (i32.const 65536)) "out of bounds memory access")
(assert_return (invoke "get") (i32.const 111))

yields:

$ cargo run wast -O opt-level=0 repro.wast
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime wast -O opt-level=0 repro.wast`
$ cargo run wast repro.wast
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime wast repro.wast`
Error: failed to run script file 'repro.wast'

Caused by:
    0: failed directive on repro.wast:16
    1: result 0 didn't match
    2: expected                111 / 0x000000000000006f
actual                    0 / 0x0000000000000000

An LLM report, if useful, is here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingcraneliftIssues related to the Cranelift code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions