I've reported an upstream LLVM bug for this but I want to track it on our side as well to track pulling in the fix. The gist of the issue is that this code:
extern {
fn return_one() -> u32;
fn panic() -> !;
}
#[no_mangle]
pub unsafe extern fn test() {
let tmp: bool = !(return_one() == 1);
if tmp { panic() }
if !tmp { panic() }
}
will execute successfully when compiled at O0:
<html>
<head>
<script>
const imports = {
env: {
return_one: function() { return 1; },
panic: function() { throw 'bad'; }
}
};
fetch('foo.wasm')
.then(r => r.arrayBuffer())
.then(r => WebAssembly.instantiate(r, imports))
.then(m => {
console.log('start');
m.instance.exports.test()
console.log('end');
})
.catch(e => console.error(e));
</script>
</head>
<body>
</body>
</html>
And it should certainly panic!
I'm currently hoping we can fix this upstream in LLVM before we need to work around it in rustc!
I've reported an upstream LLVM bug for this but I want to track it on our side as well to track pulling in the fix. The gist of the issue is that this code:
will execute successfully when compiled at O0:
And it should certainly panic!
I'm currently hoping we can fix this upstream in LLVM before we need to work around it in rustc!