Skip to content

Why does Emsctipten use wasm-opt given the great optimization from LLVM? #7190

Answered by kripken
Shawdox asked this question in Q&A
Discussion options

You must be logged in to vote

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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Shawdox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants