Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Optimize emscripten targets with emcc #36899
With today's asmjs and wasm targets, we optimize the LLVM IR ourselves, and pass that IR to emcc. emcc has its own optimization options though, including but not limited to LLVM's optimization passes, so we should probably leave all optimizations to emcc. Likewise LTO should be delegated to emscripten.
So we need to change the backend to treat these targets as unoptimized in LLVM, and instead pass the optimization arguments to emcc during the "link" step. This may involve adding new features to the target spec, or possibly just special casing emscripten in the backend.
@Thinkofname Emscripten's current handling of exceptions is horrendous: it injects a try/catch block into almost every function. V8's optimizing compiler bails out on try/catch and other JS engines don't do well either.
So you basically need to disable LLVM-level exception handling if you want good performance on emscripten.
Fortunately, I believe (not tested!) that a workaround exists: lower
This is really an Emscripten bug. Perhaps someone could write a patch?