-
Notifications
You must be signed in to change notification settings - Fork 801
Closed
Description
Sources:
- frem float miscompilation emscripten-core/emscripten#5399
- f32::rem fails on wasm32-unknown-emscripten rust-lang/rust#42629
invoking asm2wasm
on following input:
function () {
"almost asm";
var STACKTOP = 0, STACK_MAX = 0;
var Math_fround=global.Math.fround;
function _foo($0,$1) {
$0 = Math_fround($0);
$1 = Math_fround($1);
var $2 = Math_fround(0), label = 0, sp = 0;
sp = STACKTOP;
$2 = Math_fround($0 % $1);
return (Math_fround($2));
}
return { _foo: _foo };
}
will lead to wasm validation error:
[wasm-validator error in function $_foo] 3 != 4: call param types must match, on
[f64] (call $f64-rem
[f32] (get_local $0)
[f32] (get_local $1)
)
(on argument 0)
[wasm-validator error in function $_foo] 3 != 4: call param types must match, on
[f64] (call $f64-rem
[f32] (get_local $0)
[f32] (get_local $1)
)
(on argument 1)
(module
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 0 0 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
(global $STACKTOP (mut i32) (i32.const 0))
(global $STACK_MAX (mut i32) (i32.const 0))
(export "_foo" (func $legalstub$_foo))
(func $_foo (param $$0 f32) (param $$1 f32) (result f32)
(local $$2 f32)
(local $label i32)
(local $sp i32)
(set_local $sp
(get_global $STACKTOP)
)
(set_local $$2
(f32.demote/f64
(call $f64-rem
(get_local $$0)
(get_local $$1)
)
)
)
(return
(get_local $$2)
)
)
(func $legalstub$_foo (param $0 f64) (param $1 f64) (result f64)
(f64.promote/f32
(call $_foo
(f32.demote/f64
(get_local $0)
)
(f32.demote/f64
(get_local $1)
)
)
)
)
)
Metadata
Metadata
Assignees
Labels
No labels