On Sat, Jun 8, 2019 at 9:00 AM Zoltan Varga <[email protected]> wrote:
> >> >> Yes, it's true that noinline is lost after LLVM IR, so binaryen >> optimizations may inline things you didn't expect. Note that this was true >> with the asm.js backend before as well, as it also ran the binaryen >> optimizer, but whether something is inlined depends on lots of stuff so >> maybe it wasn't as noticeable. >> >> If you do the link step with -O0 then it won't run the Binaryen optimizer >> at all, and just do a simple link, which avoids this. But that won't help >> for a release build where you do want to optimize during link to get the >> best code size. Are you just surprised by the inlining, or is this causing >> a problem for you? If it's a problem, we can add support for disabling >> inlining in binaryen. >> >> Not really a problem, was just suprising. > Ok, thanks. We should probably document this somewhere, since I agree it can be confusing. I'll look into that. >> >>> - The final link still takes a lot of time even when all the inputs are >>> wasm object files. Most time seems to be spent in wasm-opt from binaryen. >>> Does wasm-opt do >>> link-time optimization only, or it still does basic optimizations which >>> are presumably already done by llvm before emitting the wasm object files ? >>> >>> >> Related to the above, if you link with -O0 then it won't optimize in >> Binaryen, and the link step will be just a simple fast link (it also won't >> do various JS optimizations, so again it's good for an incremental build >> but not for release). >> >> In my tests, wasm-opt does seem to save around 10% from the executable > size, even if the inputs are wasm object files created by emcc -Oz. Do the > savings come from whole program optimization, or wasm-opt is doing some > per-function optimizations that the llvm backend currently cannot do ? > > It's a combination of the two. The LLVM wasm backend doesn't emit some wasm patterns like ifs (it emits br_ifs) and block/if return values. Binaryen can optimize wasm into using those patterns. And also binaryen does whole program optimization, like duplicate function elimination, dead argument elimination, inlining, etc.. The code to pick those passes is here: https://github.com/WebAssembly/binaryen/blob/master/src/passes/pass.cpp#L399 Binaryen does whole-program optimization because most people don't use LLVM's LTO (in part due to the slow compile times of compiling bitcode at link; Binaryen is much simpler and lighter-weight, and also runs using multiple cores, so the time is less of a problem). And also we want binaryen to be good at optimizing non-LLVM code too. - Alon > Zoltan > >> - Alon >> >> >> >>> thanks >>> >>> Zoltan >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "emscripten-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/emscripten-discuss/bc24cc24-412f-460f-88cd-956d06b619a4%40googlegroups.com >>> <https://groups.google.com/d/msgid/emscripten-discuss/bc24cc24-412f-460f-88cd-956d06b619a4%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpROVLaJLGQj_CEumryq0Xh2kWoAc3UfkNBBE%3Db-F_p_EA%40mail.gmail.com >> <https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpROVLaJLGQj_CEumryq0Xh2kWoAc3UfkNBBE%3Db-F_p_EA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/CAJR-0p-SO8ZVFZbyCzSf89TgUNOPf0-bYH7mz2dxc3XPRxX-%3Dg%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAJR-0p-SO8ZVFZbyCzSf89TgUNOPf0-bYH7mz2dxc3XPRxX-%3Dg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpQ%2BtWn2EBF607iWp9K5MVc2cTObk31EpgRmtwbEwoEy%2BQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
