diff options
author | Alon Zakai <azakai@google.com> | 2022-12-14 16:17:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 16:17:09 -0800 |
commit | 5202fac7e7937035c0b7c95ec366e09006e317e0 (patch) | |
tree | 621b7bd54d9eb3612882dd1186319baf18536fb9 /test | |
parent | 319dcfb41dd663d9aad5f53cf70e52b5e9f97de8 (diff) | |
download | binaryen-5202fac7e7937035c0b7c95ec366e09006e317e0.tar.gz binaryen-5202fac7e7937035c0b7c95ec366e09006e317e0.tar.bz2 binaryen-5202fac7e7937035c0b7c95ec366e09006e317e0.zip |
Fix opt/shrink levels when running the optimizer multiple times (#5333)
Previously -O3 -O1 would run -O1 twice since the last flag set the global opt level
to 1, and then all invocations of the optimizer pipeline read that. This makes each
pipeline define its own opt level.
This has been a long-standing annoyance, which wasn't much noticed except that
with wasm GC there is more of a need to run the optimization pipeline more than
once. And sometimes it is nice to run different levels.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_passes.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/test_passes.py b/test/unit/test_passes.py index 2fe7f6263..25f844757 100644 --- a/test/unit/test_passes.py +++ b/test/unit/test_passes.py @@ -47,3 +47,21 @@ class PassesTest(utils.BinaryenTestCase): self.assertIn(pass_, passes) else: self.assertNotIn(pass_, passes) + + def test_O3_O1(self): + # When we run something like -O3 -O1 we should run -O3 followed by -O1 + # (and not -O1 -O1, which would be the case if the last commandline + # argument set a global opt level flag that was then used by all + # invocations of the full opt pipeline). + + # A pass that runs in -O3 but not -O1 + PASS_IN_O3_ONLY = 'precompute-propagate' + + # That pass is run in -O3 and -O3 -O1 etc. but not -O1 or -O1 -O1 + self.assertIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O3'])) + self.assertIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O3', '-O1'])) + self.assertIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O1', '-O3'])) + self.assertIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O3', '-O3'])) + + self.assertNotIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O1'])) + self.assertNotIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O1', '-O1'])) |