summaryrefslogtreecommitdiff
path: root/src/passes/OnceReduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Improve OnceReduction comment (#6068)Alon Zakai2023-10-311-1/+7
| | | | Followup to #6061
* OnceReduction: Optimize bodies of trivial "once" functions (#6061)Alon Zakai2023-10-311-10/+112
| | | | In particular, if the body just calls another "once" function, then we can skip the early-exit logic.
* Refactor interaction between Pass and PassRunner (#5093)Thomas Lively2022-09-301-5/+9
| | | | | | | | | | | | | | Previously only WalkerPasses had access to the `getPassRunner` and `getPassOptions` methods. Move those methods to `Pass` so all passes can use them. As a result, the `PassRunner` passed to `Pass::run` and `Pass::runOnFunction` is no longer necessary, so remove it. Also update `Pass::create` to return a unique_ptr, which is more efficient than having it return a raw pointer only to have the `PassRunner` wrap that raw pointer in a `unique_ptr`. Delete the unused template `PassRunner::getLast()`, which looks like it was intended to enable retrieving previous analyses and has been in the code base since 2015 but is not implemented anywhere.
* [NFC] Mark modifiesBinaryenIR=false in more places (#4869)Alon Zakai2022-08-031-0/+2
|
* Modernize code to C++17 (#3104)Max Graey2021-11-221-9/+5
|
* SimplifyGlobals: Detect trivial read-only-to-write functions (#4257)Alon Zakai2021-10-191-0/+3
| | | | | | | | | | | | | | | | | | | | | We already detected code that looks like if (foo == 0) { foo = 1; } That "read only to write" pattern occurs also in functions, like this: function bar() { if (foo == 0) return; foo = 1; } This PR detects that pattern. It moves code around to share almost all the logic with the previous pattern (the git diff is not that useful there, sadly, but looking at them side by side that should be obvious). This helps in j2cl on some common clinits, where the clinit function ends up empty, which is exactly this pattern.
* Optimize away dominated calls to functions that run only once (#4111)Alon Zakai2021-09-031-0/+444
Some functions run only once with this pattern: function foo() { if (foo$ran) return; foo$ran = 1; ... } If that global is not ever set to 0, then the function's payload (after the initial if and return) will never execute more than once. That means we can optimize away dominated calls: foo(); foo(); // we can remove this To do this, we find which globals are "once", which means they can fit in that pattern, as they are never set to 0. If a function looks like the above pattern, and it's global is "once", then the function is "once" as well, and we can perform this optimization. This removes over 8% of static calls in j2cl.