diff options
author | Alon Zakai <azakai@google.com> | 2023-05-10 13:33:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 13:33:50 -0700 |
commit | b1dba91a6bf881b5bfa68da7bb56bbb3bbf90a0a (patch) | |
tree | f3dc4097e70742aa09c2965b99529f95f3a08876 /src/passes/Inlining.cpp | |
parent | c5c223943770412b2ebd7d9f23fce8c11cf5982e (diff) | |
download | binaryen-b1dba91a6bf881b5bfa68da7bb56bbb3bbf90a0a.tar.gz binaryen-b1dba91a6bf881b5bfa68da7bb56bbb3bbf90a0a.tar.bz2 binaryen-b1dba91a6bf881b5bfa68da7bb56bbb3bbf90a0a.zip |
Gate all partial inlining behind the partial-inlining-ifs flag (#5710)
#4191 meant to do that, I think, but only did so for "pattern B". This does it
for all patterns, and adds assertions.
In theory this could regress code that benefits from partial inlining of
"pattern A" (since this PR stops doing it by default), but I did not see a significant
difference on any benchmarks, and it is easy to re-enable that behavior by
doing --partial-inlining-ifs=1.
Diffstat (limited to 'src/passes/Inlining.cpp')
-rw-r--r-- | src/passes/Inlining.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp index 229842e12..3326b7370 100644 --- a/src/passes/Inlining.cpp +++ b/src/passes/Inlining.cpp @@ -57,7 +57,7 @@ enum class InliningMode { // This function cannot be inlinined in any way. Uninlineable, // This function can be inlined fully, that is, normally: the entire function - // can be inlined. This is in contrast to partial inlining, see below. + // can be inlined. This is in contrast to split/partial inlining, see below. Full, // This function cannot be inlined normally, but we can use split inlining, // using pattern "A" or "B" (see below). @@ -611,6 +611,9 @@ struct FunctionSplitter { // split on very specific patterns we believe are worth handling in that // manner). InliningMode getSplitDrivenInliningMode(Function* func, FunctionInfo& info) { + const Index MaxIfs = options.inlining.partialInliningIfs; + assert(MaxIfs > 0); + auto* body = func->body; // If the body is a block, and we have breaks to that block, then we cannot @@ -692,7 +695,6 @@ struct FunctionSplitter { // without an else. // Find the number of ifs. - const Index MaxIfs = options.inlining.partialInliningIfs; Index numIfs = 0; while (getIf(body, numIfs) && numIfs <= MaxIfs) { numIfs++; @@ -847,6 +849,7 @@ private: Function* inlineable = copyFunction(func, "inlineable-B"); const Index MaxIfs = options.inlining.partialInliningIfs; + assert(MaxIfs > 0); // The inlineable function should only have the ifs, which will call the // outlined heavy work. @@ -1066,10 +1069,11 @@ struct Inlining : public Pass { } // When optimizing heavily for size, we may potentially split functions in - // order to inline parts of them. - if (getPassOptions().optimizeLevel >= 3 && !getPassOptions().shrinkLevel) { - functionSplitter = - std::make_unique<FunctionSplitter>(module, getPassOptions()); + // order to inline parts of them, if partialInliningIfs is enabled. + auto& options = getPassOptions(); + if (options.optimizeLevel >= 3 && !options.shrinkLevel && + options.inlining.partialInliningIfs) { + functionSplitter = std::make_unique<FunctionSplitter>(module, options); } } |