binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

Have a dual for `--no-inline` that will cause a function to be always inlined (modulo recursive inlining)

Open mkustermann opened this issue 4 months ago • 1 comments

wasm-opt has the --no-inline=<function-name-glob-pattern> argument which one can use to disallow inlining certain functions.

It would be great if we have a similar --prefer-inline=<function-name-glob-pattern> flag that tells binaryen to always inline certain functions irrespective of other flags (e.g. -Os may prevent it from being inlined as it would make size bigger, but do it nonetheless). Basically it would cause force inlining of those methods except in cases that would lead to issues (e.g. infinite recursive inlining)

From looking at wasm-opt --help --verbose it doesn't seem like there's such a flag atm.

mkustermann avatar Oct 14 '25 19:10 mkustermann

We have an --inline-main pass that inlines __original_main into main (important for LLVM output). We could extend that to get a list of functions to force-inline. I guess avoiding recursion would be the nontrivial part, as you say.

kripken avatar Oct 14 '25 19:10 kripken