summaryrefslogtreecommitdiff
path: root/src/passes/Inlining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Inlining.cpp')
-rw-r--r--src/passes/Inlining.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 04e82579c..5ed68a783 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -43,26 +43,6 @@
namespace wasm {
-// A limit on how big a function to inline when being careful about size
-static const int CAREFUL_SIZE_LIMIT = 15;
-
-// A limit on how big a function to inline when being more flexible. In
-// particular it's nice that with this limit we can inline the clamp
-// functions (i32s-div, f64-to-int, etc.), that can affect perf.
-static const int FLEXIBLE_SIZE_LIMIT = 20;
-
-// A size so small that after optimizations, the inlined code will be
-// smaller than the call instruction itself. 2 is a safe number because
-// there is no risk of things like
-// (func $reverse (param $x i32) (param $y i32)
-// (call $something (local.get $y) (local.get $x))
-// )
-// in which case the reversing of the params means we'll possibly need
-// a block and a temp local. But that takes at least 3 nodes, and 2 < 3.
-// More generally, with 2 items we may have a local.get, but no way to
-// require it to be saved instead of directly consumed.
-static const int INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT = 2;
-
// Useful into on a function, helping us decide if we can inline it
struct FunctionInfo {
std::atomic<Index> calls;
@@ -77,20 +57,25 @@ struct FunctionInfo {
usedGlobally = false;
}
+ // See pass.h for how defaults for these options were chosen.
bool worthInlining(PassOptions& options) {
// if it's big, it's just not worth doing (TODO: investigate more)
- if (size > FLEXIBLE_SIZE_LIMIT) {
+ if (size > options.inlining.flexibleInlineMaxSize) {
return false;
}
// if it's so small we have a guarantee that after we optimize the
// size will not increase, inline it
- if (size <= INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT) {
+ if (size <= options.inlining.alwaysInlineMaxSize) {
return true;
}
// if it has one use, then inlining it would likely reduce code size
// since we are just moving code around, + optimizing, so worth it
// if small enough that we are pretty sure its ok
- if (calls == 1 && !usedGlobally && size <= CAREFUL_SIZE_LIMIT) {
+ // FIXME: move this check to be first in this function, since we should
+ // return true if oneCallerInlineMaxSize is bigger than
+ // flexibleInlineMaxSize (which it typically should be).
+ if (calls == 1 && !usedGlobally &&
+ size <= options.inlining.oneCallerInlineMaxSize) {
return true;
}
// more than one use, so we can't eliminate it after inlining,