| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
| |
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.
|
|
|
| |
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
|
|
|
|
|
|
| |
Automated renaming according to
https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
|
|
|
|
| |
actually flow a value. fixes #1833 (#1835)
|
|
|
|
| |
into br_if,* - we can handle a concretely typed if as well, which can happen at the end of a block (#1799)
|
|
|
|
|
|
|
|
| |
We turned an if into a select when optimizing for size (and if
side effects etc. allow so). This patch improves that, doing it
not just when optimizing for size, but also when it looks
beneficial given the amount of work on both sides of the if. As
a result we can create selects in -O3 etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If copies is the case where an if arm is a get that feeds into
a set of the same local:
(set_local $x
(if (result i32)
(..condition..)
(..result)
(get_local $x)
)
)
We can rework this so that the if-else is only an if, which
executes the code path not going to the get.
This was done in coalesce-locals only because it is likely to
work there as after coalescing there are more copies. However,
the logic is of removing a branch, and so belongs in
remove-unused-brs, and fits alongside existing logic there
for handling ifs with an arm that is a br. Also refactor that
code so that the two optimizations can feed into each other.
|
|
|
|
|
|
| |
* Switch optimizations in remove-unused-brs: thread switch jumps, and turn a switch with all identical targets into a br
* refinalize in interm operations in remove-unused-brs, as we can be confused by it
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
| |
Rely on the dedicated pass for that. It's not worth the extra complexity to try, as we can't easily handle all the cases anyhow.
Add another run of the dedicated name-removing pass in the default passes.
|
|
|
| |
We previously had code to recreate an if from a block+branch when possible, but not when the block had a return value. This PR adds support to restructure that too, into an if with a value.
|
|
|
|
|
| |
The fuzzer found a bug with flowing of values in that pass: when one arm of an if is none-typed, we can't flow a value through the other. Odd the fuzzer didn't find this earlier, as it's been a bug since the pass was written years ago, but in practice it seems you need a specific set of circumstances on the outside for it to be hit.
The fix is to stop flowing a value in that case. Also, I realized after fixing it that the valueCanFlow global state variable is entirely unneeded. Removing it makes the pass significantly simpler: at all times, flows contains branches and values that might be flowing, and if the flow stops we remove them, etc. - we don't need an extra state variable to say if flowing is possible. So when we want to use the flows, we just check what is there (and then for a flowing branch we can remove it, and for a flowing value we can replace the branch with the value, etc., as in both cases they flow to the right place anyhow).
|
| |
|
|
|
|
|
| |
* remove-unused-brs: handle an if declared as returning a value despite having an unreachable condition
* simplify-locals: don't work on loops while the main pass is making changes, as set_locals are being tracked and modified.
|
|
|
|
|
|
| |
* Use an if return value when one side is unreachable.
* Undo an if return value if we can use a br_if instead
|
|
|
|
|
|
|
|
|
|
| |
Inspired by #1501
* remove unneeded appearances of the default switch target (at the front or back of the list of targets)
* optimize a switch with 0, 1 or 2 targets into an if or if-chain
* optimize a br_if br pair when they have the same target
Makes e.g. fastcomp libc++ 2% smaller. Noticeable improvements on other things like box2d etc.
|
|
|
|
| |
* rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implements #1309: subsequent br_ifs that compare the same value to various constants are converted into a br_table in a block,
(br_if $x (i32.eq (get_local $a) (i32.const 0)))
(br_if $y (i32.eq (get_local $a) (i32.const 1)))
(br_if $z (i32.eq (get_local $a) (i32.const 2)))
==>
(block $tablify
(br_table $x $y $z $tablify
(get_local $a)
)
)
The constants for when to apply this (e.g., not if the range of values would make a huge jump table) are fairly conservative, I think, but hard to tell. Probably should be tweaked based on our experience with the pass in practice later on.
|
|
|
| |
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).
|
|
|
|
| |
now that the type system has a proper unreachable, we don't need obviouslyDoesNotFlowOut
|
| |
|
|
|
|
| |
validation that was from when we differentiated reachable from unreachable breaks (#1166)
|
|
|
|
|
|
|
|
| |
* if a block has a concrete final element (or a break with a value), then even if it has an unreachable child, keep it with that concrete type. this means we no longe allow the silly case of a block with an unreachable in the middle and a concrete as the final element while the block is unreachable - after this change, the block would have the type of the final element
* if an if has a concrete element in one arm, make it have that type as a result, even if the if condition is unreachable, to parallel block
* make type rules for brs and switches simpler, ignore whether they are reachable or not. whether they are dead code should not affect how they influence other types in our IR.
|
| |
|
|
|
|
| |
with a value from the current state, not just set the global state as to whether we can flow or not (as it will be set later by other things)
|
|
|
|
| |
remove-unused-brs, as they are dead code anyhow, and it is pointless to work hard to handle the type changes
|
| |
|
|
|
|
| |
special handling to emit valid code
|
| |
|
|
|
|
| |
its outer block, we need to finalize the if first and then the block containing it
|
|
|
|
| |
to. since that's a fairly specific functionality needed in removeUnusedBrs, move it to there
|
|
|
|
| |
preserve it
|
|
|
|
| |
to make this practical
|
|
|
|
|
|
|
|
| |
* values cannot flow through an if without an else, they never return a value
* check pass tests in pass-debug mode too
* add missing finalization in binary reading
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
unnecessary complexity in that pass as well
|
|
|
|
| |
Most module walkers use PostWalker<T, Visitor<T>>, let that pattern be
expressed as simply PostWalker<T>
|
|
|
|
|
|
|
|
| |
* 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
|
| |
|
| |
|
|
|
|
| |
* add PassOptions structure, and use it for new -Os param to wasm-opt
|
|
|
|
|
|
| |
* type check using block/loop/if types provided in text and binary formats.
* print if and loop sigs which were missing.
* remove dsl from OptimizeInstructions as after those changes it needs rethinking.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|