This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Protect float-to-integer conversions.
AbandonedPublic

Authored by sunfish on Oct 3 2017, 5:37 PM.

Details

Reviewers
None
Summary

LLVM's float-to-in conversions return undef in exceptional conditions, and may be speculated. WebAssemlby's traps, making them not safe for speculation. This patch changes LLVM codegen to emit a test so that code doesn't trap even with speculated conversions.

This patch is not yet tested. I'll add tests next time I circle back to this patch. In the mean time, it's here in case anyone wants to see it or try it out.

Diff Detail

Repository
rL LLVM

Event Timeline

sunfish created this revision.Oct 3 2017, 5:37 PM
sunfish abandoned this revision.Nov 27 2017, 5:19 PM

An improved version of this is now landed as r319128.

I also added support for the new opcodes proposed in the non-trapping fp-to-int conversion feature. https://github.com/WebAssembly/nontrapping-float-to-int-conversions/

I'm currently hoping that we don't need to give users fine-grained control over this feature, because it'll be unnecessary once non-trapping float-to-int conversions are available.