summaryrefslogtreecommitdiff
path: root/src/passes/MergeBlocks.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-071-5/+5
|
* Remove 'none' type as a branch target in ReFinalize (#2492)Alon Zakai2019-12-041-2/+2
| | | | | | | | | | | | | | | | | 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.
* Multivalue type creation and inspection (#2459)Thomas Lively2019-11-221-5/+5
| | | | | | | | | | | | | Adds the ability to create multivalue types from vectors of concrete value types. All types are transparently interned, so their representation is still a single uint32_t. Types can be extracted into vectors of their component parts, and all the single value types expand into vectors containing themselves. Multivalue types are not yet used in the IR, but their creation and inspection functionality is exposed and tested in the C and JS APIs. Also makes common type predicates methods of Type and improves the ergonomics of type printing.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reflected new renamed instruction names in code and tests: - `get_local` -> `local.get` - `set_local` -> `local.set` - `tee_local` -> `local.tee` - `get_global` -> `global.get` - `set_global` -> `global.set` - `current_memory` -> `memory.size` - `grow_memory` -> `memory.grow` - Removed APIs related to old instruction names in Binaryen.js and added APIs with new names if they are missing. - Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent name clashes. - Resolved several TODO renaming items in wasm-binary.h: - `TableSwitch` -> `BrTable` - `I32ConvertI64` -> `I32WrapI64` - `I64STruncI32` -> `I64SExtendI32` - `I64UTruncI32` -> `I64UExtendI32` - `F32ConvertF64` -> `F32DemoteI64` - `F64ConvertF32` -> `F64PromoteF32` - Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to `BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for consistency.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-13/+28
| | | 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-60/+78
| | | 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
* No exit runtime pass (#1816)Alon Zakai2018-12-131-1/+1
| | | When emscripten knows that the runtime will not be exited, it can tell codegen to not emit atexit() calls (since those callbacks will never be run). This saves both code size and startup time. In asm2wasm the JSBackend does it directly. For the wasm backend, this pass does the same on the output wasm.
* Merge-Blocks improvements (#1760)Alon Zakai2018-11-261-18/+57
| | | | | | | | | | | | | | | | | | | | | | Previously we didn't try to merge a block into the parent if the block had a name. This lets us merge part of it, that is: (block (..a..) (block $child (..b..) (.. some br to $child ..) (..c..) ) ) => (block (..a..) (..b..) ;; moved out (block $child (.. some br to $child ..) (..c..) ) ) This is beneficial for 2 reasons: the child may now be a singleton, so we can remove the block; or, now that we canonicalized the br-containing code to the head of the child, we may be able to turn it into an if.
* Fix a merge-blocks fuzz bug (#1755)Alon Zakai2018-11-191-56/+0
| | | | | | * Moving blocks into if arms may change the block type, and the code we had was written under the assumption that was not true. * Move block sinking merge-blocks => remove-unused-brs, as it's more natural there. that pass refinalizes everything anyhow
* Optimize an if exit block into an if arm (#1749)Alon Zakai2018-11-151-1/+40
| | | If an if is enclosed in a block which is only used to exit one arm, move it into that arm, so it can be better optimized. Similar to what we did for loops in #1736.
* MergeBlocks: canonicalize loop exit block position on the inside (#1736)Alon Zakai2018-11-141-1/+19
| | | | * move a loop exit block (block with a name, and one child which is the loop) into the loop in MergeBlocks, as that is better for other passes
* Fix a merge-blocks fuzz bug (#1730)Alon Zakai2018-11-081-1/+18
| | | | | | | | | | | | | | | If a block has code after an unreachable element, it makes merging to an outer block tricky - the child block may be unreachable, but the parent have a return type, (block (result i32) .. (block (unreachable) (nop) ) ) It's ok to end an unreachable block with a nop, but not a typed one. To avoid this, if a child block has dce-able code, just ignore it.
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-4/+0
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* Merge loop tails up (#1543)Alon Zakai2018-05-101-29/+93
| | | | | | | | | | | | | | | E.g. ``` (block .. (loop $l .. (br_if $l (..)) .. code that does not branch to the loop top ) .. that code could be moved here .. ) ``` Moving the code out of the loop may help the loop body become a singleton expression, and is more readable anyhow.
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-2/+2
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-2/+2
| | | 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).
* properly handle merging of blocks with concrete unreachable elements in the ↵Alon Zakai2017-08-061-6/+10
| | | | middle
* handle merging blocks with items after an unreachable, that if merged would ↵Alon Zakai2017-08-061-9/+6
| | | | be invalid. stop on the unreachable, it is easier and better
* fix merge-blocks bug with replacing an unreachable block with a concrete ↵Alon Zakai2017-08-051-4/+5
| | | | final element (which is never reached)
* fix merge-blocks logic: ensure that optimize() does not change the outside typeAlon Zakai (kripken)2017-08-051-36/+67
|
* don't move code around a drop-block when the block contains unreachables, ↵Alon Zakai2017-08-051-22/+32
| | | | which can cause type changes in the outside. dce should be run on that anyhow
* review commentsAlon Zakai (kripken)2017-07-311-5/+5
|
* don't remove values from breaks if the values have side effectsAlon Zakai (kripken)2017-07-301-11/+23
|
* when finalizing a block in MergeBlocks, use its type, so that we don't need ↵Alon Zakai2017-07-241-1/+1
| | | | to consider type changes for its parent (changing it from a forced i32 to an unreachable might mean the parent needs to become unreachable too)
* Optimizer support for atomic instructions (#1094)Derek Schuff2017-07-211-9/+18
| | | | | | * Teach EffectAnalyzer not to reorder atomics wrt other memory operations. * Teach EffectAnalyzer not to reorder host operations with memory operations * Teach various passes about the operands of AtomicRMW and AtomicCmpxchg * Factor out some functions in DeadCodeElimination and MergeBlocks
* fix merge-blocks logic in call, call_indirect, select, we need to avoid any ↵Alon Zakai (kripken)2017-07-141-6/+15
| | | | danger of moving something past a side effect ; also fix an asm2wasm bug with call_indirect fixups; the call target may be a block, which we need to look through
* handle an unreachable block with a reachable final element in merge-blocksAlon Zakai (kripken)2017-07-141-0/+9
|
* fix handling of unreachable br values in merge-blocksAlon Zakai (kripken)2017-07-111-1/+7
|
* add the option to seek named breaks, not just taken breaks; refactor headers ↵Alon Zakai (kripken)2017-07-111-1/+2
| | | | to make this practical
* Support new result syntax for if/loop/block (#1047)Sam Clegg2017-06-121-1/+1
| | | | | | Support both syntax formats in input since the old spec tests still need to be parsable.
* Address review feedback for #1014 (#1016)Alon Zakai2017-05-181-2/+2
| | | | | | * address review feedback for #1014
* Validate finalization (#1014)Alon Zakai2017-05-181-2/+19
| | | | | | | * 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.
* Default Walker subclasses to using Visitor<SubType> (#921)jgravelle-google2017-02-231-3/+3
| | | | Most module walkers use PostWalker<T, Visitor<T>>, let that pattern be expressed as simply PostWalker<T>
* Improve handling of implicit traps (#898)Alon Zakai2017-02-061-5/+5
| | | | | | | | * add --ignore-implicit-traps option, and by default do not ignore them, to properly preserve semantics * implicit traps can be reordered, but are side effects and should not be removed * add testing for --ignore-implicit-traps
* use MixedArena in asm.js astAlon Zakai (kripken)2017-01-311-1/+1
|
* fix a reordering bug in merge-blocks (#846)Alon Zakai2016-11-251-2/+6
|
* optimize child blocks in merge-blocks when we drop values in them, they may ↵Alon Zakai2016-10-291-60/+73
| | | | have new subchild blocks
* fix break value removal in merge-blocks: a br_if's type changes without a ↵Alon Zakai2016-10-291-1/+10
| | | | value, so finalize the node, and remove the drop
* handle the case of a br_if whose value is used in merge-blocksAlon Zakai2016-10-291-14/+38
|
* move drop into blocks, dropping all the breaks as well, when possibleAlon Zakai2016-09-071-8/+58
|
* add drop and tee expressionsAlon Zakai2016-09-071-0/+19
|
* Add initialization functions for passes to avoid missing pass registration ↵Jukka Jylänki2016-06-211-1/+3
| | | | due to linker dead code elimination. Fixes #577.
* move function parallelism to pass and pass runner, which allows more ↵Alon Zakai2016-06-031-1/+3
| | | | efficient parallel execution (#564)
* fix a merge-blocks bug where we merged named blocksAlon Zakai2016-05-251-1/+1
|
* move blocks outside in merge-blocks so that they can be merged laterAlon Zakai2016-05-241-0/+124
|
* add an ArenaVector for internal array allocations in expression nodesAlon Zakai2016-04-261-1/+1
|
* create a UnifiedExpressionVisitor for passes that want a single visitor ↵Alon Zakai2016-04-181-1/+1
| | | | function, to avoid confusion with having both visit* and visitExpression in a single pass (#357)
* Function parallelism (#343)Alon Zakai2016-04-151-0/+2
| | | | * allow traversals to mark themselves as function-parallel, in which case we run them using a thread pool. also mark some thread-safety risks (interned strings, arena allocators) with assertions they modify only on the main thread
* dyn_cast => dynCastAlon Zakai2016-04-111-1/+1
|
* De-recurse traversals (#333)Alon Zakai2016-04-111-1/+1
| | | | | | | | | | | | * refactor core walking to not recurse * add a simplify-locals test * reuse parent's non-branchey scan logic in SimpleExecutionWalker, reduce code duplication * update wasm.js * rename things following comments