-
Since Emscripten uses
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
One major reason is LTO-style optimizations like inlining between compilation units. clang only does that when LTO is enabled, but wasm has enough information for it, so wasm-opt can always do it. Otherwise, there is a lot of overlap between the two optimizers in basic passes like DCE etc. clang can do many things wasm-opt can't, like type-based aliasing, but to get the most out of it you need LLVM LTO, which can be slow. OTOH wasm-opt does have some wasm-specific optimizations that clang doesn't do yet (like sorting globals, packing segments, the (wasm-opt also has optimizations for wasm things that LLVM doesn't emit, like wasm GC. that can matter if you link wasm from clang with a GC language, for example) |
Beta Was this translation helpful? Give feedback.
One major reason is LTO-style optimizations like inlining between compilation units. clang only does that when LTO is enabled, but wasm has enough information for it, so wasm-opt can always do it.
Otherwise, there is a lot of overlap between the two optimizers in basic passes like DCE etc. clang can do many things wasm-opt can't, like type-based aliasing, but to get the most out of it you need LLVM LTO, which can be slow. OTOH wasm-opt does have some wasm-specific optimizations that clang doesn't do yet (like sorting globals, packing segments, the
if
structure, etc., things that are easier to do directly on wasm).(wasm-opt also has optimizations for wasm things that LLVM doesn't emit, li…