summaryrefslogtreecommitdiff
path: root/src/cfg/Relooper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Remove our bespoke `make_unique` implementation (#5613)Thomas Lively2023-03-311-1/+1
| | | | This code predates our adoption of C++14 and can now be removed in favor of `std::make_unique`, which should be more efficient.
* Switch from `typedef` to `using` in C++ code. NFC (#5258)Sam Clegg2022-11-151-3/+3
| | | | This is more modern and (IMHO) easier to read than that old C typedef syntax.
* Modernize code to C++17 (#3104)Max Graey2021-11-221-49/+31
|
* Fix Relooper leaking Branches (#3097)Daniel Wirtz2020-09-081-47/+62
| | | Fixes the `Relooper` leaking `Branch`es in `Optimizer::SkipEmptyBlocks`, by refactoring the API so a `std::unique_ptr` is ensured for each `Block`, `Branch` and `Shape` upon adding to the relooper.
* Refactor hashing (#3023)Daniel Wirtz2020-08-121-18/+18
| | | | | | | | | * Unifies internal hashing helpers to naturally integrate with std::hash * Removes the previous custom implementation * Computed hashes are now always size_t * Introduces a hash_combine helper * Fixes an overwritten partial hash in Relooper.cpp
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-071-5/+5
|
* Add BYN_ENABLE_ASSERTSION option to allow assertions to be disabled. (#2500)Sam Clegg2019-12-041-0/+2
| | | | | | | | We always enable assertions by default, but this options allows for a build without them. Fix all errors in the ASSERTIONS=OFF build, even though we don't normally build this its good to keep it building.
* Remove 'none' type as a branch target in ReFinalize (#2492)Alon Zakai2019-12-041-1/+1
| | | | | | | | | | | | | | | | | That was needed for super-old wasm type system, where we allowed (block $x (br_if $x (unreachable) (nop) ) ) That is, we differentiated "taken" branches from "named" ones (just referred to by name, but not actually taken as it's in unreachable code). We don't need to differentiate those any more. Remove the ReFinalize code that considered it, and also remove the named/taken distinction in other places.
* Fix bug and leak in relooper merge consecutive blocks (#2159)hobby82019-06-071-2/+9
| | | | | | | | | | | | | | | | | | Fixes in Relooper merge consecutive blocks: Entry block getting removed when it is part of a loop: bb1->AddBranchTo(bb2, nullptr); bb1->AddBranchTo(bb3, ...); bb2->AddBranchTo(bb1, nullptr); bb3->AddBranchTo(bb4, nullptr); relooper.AddBlock(bb1); relooper.AddBlock(bb2); relooper.AddBlock(bb3); relooper.AddBlock(bb4); relooper.Calculate(bb1); Branches memory leak
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-22/+44
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-204/+340
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* Code style improvements (#1868)Alon Zakai2019-01-151-3/+3
| | | | * Use modern T p = v; notation to initialize class fields * Use modern X() = default; notation for empty class constructors
* standardize on 'template<' over 'template <' (i.e., remove a space) (#1782)Alon Zakai2018-11-291-1/+1
|
* Relooper: Merge consecutive blocks (#1770)Alon Zakai2018-11-261-0/+40
| | | That is, A -> B where no other branches go to B. In that case we are guaranteed to not increase code size.
* Relooper CFG optimizations (#1759)Alon Zakai2018-11-211-10/+471
| | | | | | | | | | | | | | | | Previously the relooper would do some optimizations when deciding when to use an if vs a switch, how to group blocks, etc. This PR adds an additional pre-optimization phase with some basic but useful simplify-cfg style passes, * Skip empty blocks when they have just one exit. * Merge exiting branches when they are equivalent. * Canonicalize block contents to make such comparisons more useful. * Turn a trivial one-target switch into a simple branch. This can help in noticeable ways when running the rereloop pass, e.g. on LLVM wasm backend output. Also: * Binaryen C API changes to the relooper, which now gets a Module for its constructor. It needs it for the optimizations, as it may construct new nodes. * Many relooper-fuzzer improvements. * Clean up HashType usage.
* Modernize relooper code (#1738)Alon Zakai2018-11-131-161/+158
| | | Use c++11 auto, iterators, etc.
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-1/+1
| | | The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
* relooper improvementsAlon Zakai (kripken)2017-05-201-1/+6
|
* Validate finalization (#1014)Alon Zakai2017-05-181-0/+22
| | | | | | | * validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
* Re-reloop pass (#1009)Alon Zakai2017-05-161-0/+1
| | | | | This adds a pass that converts to a CFG, runs the relooper, and re-generates wasm from that. This depends on flatten-control-flow being run before. The main goal here is to help code generators other than asm2wasm (which already receives relooped code from fastcomp).
* finalize interim ifs in relooper, and other if handling issues (#940)Alon Zakai2017-03-131-0/+3
|
* Fix emitting of unreachable block/if/loop (#911)Alon Zakai2017-02-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | * an unreachable block is one with an unreachable child, plus no breaks * document new difference between binaryen IR and wasm * fix relooper missing finalize * add a bunch of tests * don't assume that test/*.wast files print to themselves exactly; print to from.wast. this allows wast tests with comments in them * emit unreachable blocks as (block .. unreachable) unreachable * if without else and unreachable ifTrue is still not unreachable, it should be none * update wasm.js * cleanups * empty blocks have none type
* Require unique names in binaryen IR (#746)Alon Zakai2016-10-061-1/+5
|
* loops no longer have an out label and other upstream loop updatesAlon Zakai2016-09-071-1/+1
|
* Replace std::unique<T>(new T()) with make_unique<T>().Logan Chien2016-08-261-1/+1
| | | | | | | | | | | | | | | | This commit modernize the code base by replacing: std::unique_ptr<T>(new T(...)) with: make_unique<T>(...) or: wasm::make_unique<T>(...) This is a step closer to adopt C++14 std::make_unique<T>(...).
* avoid label variable usage in relooper for forward branches, just use a ↵Alon Zakai2016-07-201-34/+91
| | | | stack of blocks for them. after this change, only irreducible control flow should cause label variable usage
* refactor calling of MakeMultiple in relooperAlon Zakai2016-07-181-5/+4
|
* remove an unneeded param in the relooperAlon Zakai2016-07-181-4/+5
|
* remove some old code in relooperAlon Zakai2016-07-181-28/+3
|
* fix relooper leakAlon Zakai2016-07-121-0/+3
|
* Relooper switch support (#617)Alon Zakai2016-07-021-65/+134
| | | | | | * support switches in relooper and c api * update relooper fuzzer for switches
* finalize blocks properly in relooper (#600)Alon Zakai2016-06-241-1/+7
|
* use separate internal opcodes for binary variantsAlon Zakai2016-05-181-1/+1
|
* use separate internal opcodes for unary variantsAlon Zakai2016-05-181-1/+1
|
* Change NULL to nullptr. Quiet Visual C++ 2015 optimizer errors by using ↵BSalita2016-05-111-6/+6
| | | | "!!". (#465)
* Import emscripten's relooper, port it to the binaryen AST, and provide a C ↵Alon Zakai2016-05-051-0/+881
API (#434) also ignore libstdc++ bug in ubsan