diff --git a/fncompiler.go b/fncompiler.go index 37e12ed7..c02d9895 100644 --- a/fncompiler.go +++ b/fncompiler.go @@ -301,16 +301,17 @@ func (fn *funcCompiler) popAddr(offset uint64) ast.Expr { if fn.memory.is64 { fn.helpers.add("p64") addr = convert(addr, "p64") + } else if *unsafe || offset != 0 { + // Widen so inlined accesses share a type for bounds-check proofs. + addr = convert(addr, "uint32", "uint64") } else { + // Keep safe zero-offset addresses uint32. + // Remove this branch once safe helpers inline (#69). addr = convert(addr, "uint32") } if offset == 0 { return addr } - - if !fn.memory.is64 { - addr = convert(addr, "uint64") - } return &ast.BinaryExpr{Op: token.ADD, X: addr, Y: uintLit(offset)} } diff --git a/testdata/regression/shared_export/shared_export.go b/testdata/regression/shared_export/shared_export.go index dc288461..395aa915 100644 --- a/testdata/regression/shared_export/shared_export.go +++ b/testdata/regression/shared_export/shared_export.go @@ -45,7 +45,7 @@ func (m *wasmMemory) Waiters() *sync.Map { return m.waiters } func (m *Module) Xwait0() int32 { - t0 := atomic_wait32(m.memory, uint32(i32(0)), uint32(i32(0)), i64(0), m.waiters) + t0 := atomic_wait32(m.memory, uint64(uint32(i32(0))), uint32(i32(0)), i64(0), m.waiters) return t0 } func (m *Module) Xmemory() Memory {