Skip to content

Wasm backend doesn't handle ForeignHints

When the wasm NCG lowers a ccall, the ForeignHints of arguments and return value is not handled. This is fine for W32/W64, but in case of W8/W16, it leads to incorrect runtime behavior. For instance:

           _s11Q::P32 = R1;
           _s11R::I16 = I16[_s11Q::P32 + 3];
           _c12t::I32 = func16;
           _c12u::I16 = _s11R::I16;
           (_s11V::I16) = call "ccall" arg hints:  [‘signed’]  result hints:  [‘signed’] (_c12t::I32)(_c12u::I16);

Due to Cmm not tracking signedness at type-level, when we load _s11R, we always have to do i32.load16_u. Now, when it's passed as a ccall argument, given the signed hint, we must do an explicit i32.extend16_s first. And we didn't do that. Sigh. Leads to T20735 failure and possibly more.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information