Skip to content

Wasm NCG doesn't properly handle non-word-sized CmmSwitch scrutinees

Currently, the wasm NCG has an implicit assumption: all CmmSwitch scrutinees are 32-bit integers. This is not always true; #22864 (closed) is one counter-example with a 64-bit scrutinee. Also, subword scrutinees also seem to be possible, e.g. in ByteSwitch_cmm.cmm and cps012.cmm. Those may be miscompiled if the switch targets contain negative cases!

Anyway, in addition to fixing this issue, I'll also try to construct a test case that actually triggers miscompilation before the fix.

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