Stream: git-wasmtime

Topic: wasmtime / issue #13538 Inlining changes behavior of memo...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2026 at 17:53):

alexcrichton opened issue #13538:

This input:

(component
  (core module $M
    (memory (export "mem") 1)
    (func (export "writeit") (param i32 i32)
      (i32.store (local.get 0) (local.get 1)))
  )
  (core instance $m (instantiate $M))
  (core module $N
    (import "" "mem" (memory 1))
    (import "" "writeit" (func $writeit (param i32 i32)))
    (func (export "g") (result i32)
      (i32.load (i32.const 0))
      drop
      (call $writeit (i32.const 0) (i32.const 123))
      (i32.load (i32.const 0)))
  )
  (core instance $n (instantiate $N
      (with "" (instance
        (export "mem" (memory $m "mem"))
        (export "writeit" (func $m "writeit"))))))
  (func (export "g") (result u32) (canon lift (core func $n "g"))))

changes behavior with inlining:

$ cargo run -- -C inlining=n --invoke 'g()' repro.wat
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime -C inlining=n --invoke 'g()' repro.wat`
123
$ cargo run -- -C inlining=y --invoke 'g()' repro.wat
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime -C inlining=y --invoke 'g()' repro.wat`
0

An LLM-produced report is here and this looks like a regression after #13525 and #13354 -- cc @fitzgen

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2026 at 19:49):

fitzgen assigned fitzgen to issue #13538.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2026 at 20:01):

fitzgen commented on issue #13538:

Ooo this is a good one.

We can sometimes resolve this by turning the imported memory alias region into a precise defined memory alias region when the importing module is always instantiated with the same memory (e.g. it is instantiated exactly once). However, if it is instantiated multiple times with multiple different memories, then we can't do that because sometimes the imported memory might alias and other times it might not. We would need monomorphization to keep applying precise alias regions.

I guess the conservative fix, when we don't have a single precise memory to reference, would be to make accesses to exported memories use the imported memory alias region (potentially only when inlining is also enabled).

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2026 at 20:10):

fitzgen commented on issue #13538:

I guess the conservative fix, when we don't have a single precise memory to reference, would be to make accesses to exported memories use the imported memory alias region (potentially only when inlining is also enabled).

And we could potentially only do this for the memories that can flow into an ambiguous import, as well, fwiw.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2026 at 22:59):

fitzgen closed issue #13538:

This input:

(component
  (core module $M
    (memory (export "mem") 1)
    (func (export "writeit") (param i32 i32)
      (i32.store (local.get 0) (local.get 1)))
  )
  (core instance $m (instantiate $M))
  (core module $N
    (import "" "mem" (memory 1))
    (import "" "writeit" (func $writeit (param i32 i32)))
    (func (export "g") (result i32)
      (i32.load (i32.const 0))
      drop
      (call $writeit (i32.const 0) (i32.const 123))
      (i32.load (i32.const 0)))
  )
  (core instance $n (instantiate $N
      (with "" (instance
        (export "mem" (memory $m "mem"))
        (export "writeit" (func $m "writeit"))))))
  (func (export "g") (result u32) (canon lift (core func $n "g"))))

changes behavior with inlining:

$ cargo run -- -C inlining=n --invoke 'g()' repro.wat
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime -C inlining=n --invoke 'g()' repro.wat`
123
$ cargo run -- -C inlining=y --invoke 'g()' repro.wat
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `/home/alex/code/wasmtime2/target/debug/wasmtime -C inlining=y --invoke 'g()' repro.wat`
0

An LLM-produced report is here and this looks like a regression after #13525 and #13354 -- cc @fitzgen


Last updated: Jul 29 2026 at 05:03 UTC