Skip to content

Inlining: Always inline single-use functions #3730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ struct InliningOptions {
// More generally, with 2 items we may have a local.get, but no way to
// require it to be saved instead of directly consumed.
Index alwaysInlineMaxSize = 2;
// Function size which we inline when there is only one caller.
// FIXME: this should logically be higher than flexibleInlineMaxSize.
Index oneCallerInlineMaxSize = 15;
// Function size which we inline when there is only one caller. By default we
// inline all such functions (as after inlining we can remove the original
// function).
Index oneCallerInlineMaxSize = -1;
// Function size above which we never inline, ignoring the various flexible
// factors (like whether we are optimizing for size or speed) that could
// influence us.
Expand Down
9 changes: 4 additions & 5 deletions src/tools/optimization-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,12 @@ struct OptimizationOptions : public ToolOptions {
.add("--one-caller-inline-max-function-size",
"-ocimfs",
"Max size of functions that are inlined when there is only one "
"caller (default " +
std::to_string(InliningOptions().oneCallerInlineMaxSize) +
"). Reason this is not unbounded is that some "
"implementations may have a hard time optimizing really large "
"functions",
"caller (default -1, which means all such functions are inlined)",
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
static_assert(InliningOptions().oneCallerInlineMaxSize ==
Index(-1),
"the help text here is written to assume -1");
passOptions.inlining.oneCallerInlineMaxSize =
static_cast<Index>(atoi(argument.c_str()));
})
Expand Down
2 changes: 1 addition & 1 deletion test/binaryen.js/inlining-options.js.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// alwaysInlineMaxSize=2
// flexibleInlineMaxSize=20
// oneCallerInlineMaxSize=15
// oneCallerInlineMaxSize=-1
// allowInliningFunctionsWithLoops=false
Loading