brson / miri

An experimental compiler from Rust to WebAssembly (inactive - do not use)
Apache License 2.0
209 stars 15 forks source link

MIR IR versus LLVM IR for WASM generation #22

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

I am not sure if it is or not the right place for asking that, and maybe this question does not make sense, but I would be very interested to know what are your thoughts about generating WASM bytecode from MIR IR versus just reusing the LLVM IR -> WASM target under development on LLVM side.

Do you expect both approaches to be doable for Rust in the future? What are the advantages of creating WASM bytecode from MIR IR?

Thanks in advance for your feedback.

sunfishcode commented 8 years ago

Through at least the mediumish-term future, the LLVM IR -> wasm compilation path is expected to produce more efficient code, as it will have the advantage of using the full LLVM optimizer, while the mir2wasm backend is expected to have faster compile times.

There are also some interesting bigger-picture opportunities in mir2wasm, as it will help the Rust compiler be more aware of how it's using LLVM. And, it may help establish a path for the development of other backend options as well.

brson commented 8 years ago

In the near-term the LLVM->wasm is the easier path, though initially we'll probably be using the fastcomp asm.js backend to LLVM, not the wasm backend. See this thread for progress on that front.

As @sunfishcode says the primary advantages of MIR->wasm are compile-time performance and benefits to rustc's architecture by supporting multiple backends.

ghost commented 8 years ago

Thanks for your feedback!