| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
| |
This error started showing up after: #1779
error: delete called on non-final 'wasm::ShellExternalInterface' that
has virtual functions but non-virtual destructor
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The wasm backend uses a wasm global (__stack_pointer) for the shadow
stack location. In order to make this work with shared libraries the
main module would have to export this global and shared libraries would
need to import it. This means we'd be relying of mutable globals which
are not yet implemented in all browsers.
This change allows is to move forward with shared libraries without
mutable global support by replacing all stack pointer access in shared
libraries with functions calls.
|
|
|
|
|
|
|
|
| |
Before we just looked at function return values when looking for differences before and after running some passes, while fuzzing. This adds logging of values during execution, which can represent control flow, monitor locals, etc., giving a lot more opportunities for the fuzzer to find problems.
Also:
* Clean up the sigToFunctionType function, which allocated a struct and returned it. This makes it safer by returning the struct by value, which is also easier to use in this PR.
* Fix printing of imported function calls without a function type - turns out we always generate function types in loading, so we didn't notice this was broken, but this new fuzzer feature hit it.
|
|
|
|
|
| |
This picks up from #1644 and indeed borrows the test case from there.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
We invalidated based on effects of set values, but not of the sets themselves. Without that, a set could be overridden by something irrelevant and we thought we could still reuse the old value.
Before this PR, the testcase would have the last set's value be optimized into a get, incorrectly.
|
|
|
|
|
|
| |
This adds a first instance of the rules discussed in #1764 , specifically,
x == y || x > y => x >= y
|
|
|
|
|
|
| |
Where reasonable from a readability perspective, remove default cases
in switches over types and instructions. This makes future feature
additions easier by making the compiler complain about each location
where new types and instructions are not yet handled.
|
|
|
| |
In OptimizeInstructions we canonicalized a const on the right side. This PR adds further canonicalization, of a get to the right, and of sorting by binary and unary op ids. This guarantees fixed orders for small combinations of instructions that can then be pattern-matched in a simple way in future PRs.
|
|
|
|
|
|
| |
If we refinalize after adding a value that flows out of a block, we need to fix up any branches that might exist without a value, which is possible if the branches were not taken in practice
Also refactor ReFinalize into a separate file.
|
|
|
| |
Reducing on text files can be useful as in binaryen the binary reading and writing has some noticeable effects (due to wasm and binaryen IR not being identical, while the text format is a closer match.
|
|
|
| |
Fixes #1766
|
|
|
| |
That is, A -> B where no other branches go to B. In that case we are guaranteed to not increase code size.
|
|
|
|
| |
may exist without a source map (#1733)
|
|
|
| |
Previously we assumed that we can't reorder a branching instruction and anything else. However, the only risk is when the other thing has side effects.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
minify_exports
|
| |
| |
| |
| | |
sometimes that is not desirable.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Its simpler if we always import these functions from
the embedder rather then synthesizing them various
placed.
This is part of a 4 part change:
LLVM: https://reviews.llvm.org/D53240
fastcomp: https://github.com/kripken/emscripten-fastcomp/pull/237
emscripten: https://github.com/kripken/emscripten/pull/7358
binaryen: https://github.com/kripken/emscripten/pull/7358
Fixes: https://github.com/kripken/emscripten/issues/7273
Fixes: https://github.com/kripken/emscripten/issues/7304
|
|
|
|
|
|
| |
* 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
|
|
|
| |
Also fix broken tests surfaced by the new parser.
|
|
|
|
|
| |
(#1751)
partially solves #1676.
|
|
|
| |
This tries to reduce by replacing targets with the default, and by shrinking the list of targets.
|
|
|
|
| |
This yields more useful information when something goes wrong.
|
|
|
| |
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.
|
|
|
|
| |
In this case we won't want generate any of the normal memory
helper functions (they come from the main module).
|
|
|
|
|
|
|
|
|
|
|
| |
Without this wasm-opt can't operation on emscripten-produced
SIDE_MODULES's which have zero sized memory imports.
Technically is not a validation failure if you have segments that
are larger than your initial memory, regardless of whether you
import them.
For non-imported memories it can be helpful though, so leaving it
in to catch those errors.
|
|
|
|
|
| |
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.
|
|
|
|
| |
`strpbrk` segfaults when `name.str` is nullptr, so check first.
|
|
|
|
| |
* 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
|
|
|
|
|
| |
Not at all sure why we're seeing any there, but it's easy enough to
handle that we might as well.
|
|
|
| |
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.
|
|
|
|
| |
do it properly later (#1744)
|
|
|
|
|
|
|
| |
Handle a corner case in ReFinalize, which incrementally re-types code after changes. The problem is that if we need to figure out the type of a block, we look to the last element flowing out, or to breaks with values. If there is no such last element, and the breaks are not taken - they have unreachable values - then they don't tell us the block's proper type. We asserted that in such a case the block still had a type, and didn't handle this.
To fix it, we could look on the parent to see what type would fit. However, it seem simpler to just remove untaken breaks/switches as part of ReFinalization - they carry no useful info anyhow. After removing them, if the block has no other signal of a concrete type, it can just be unreachable.
This bug existed for at least 1.5 years - I didn't look back further. I think it was noticed by the fuzzer now due to recent fuzzing improvements and optimizer improvements, as I just saw this bug found a second time.
|
|
|
|
| |
This writes the data section into a file suitable for use with emscripten's
--memory-init-file flag
|
|
|
| |
Use c++11 auto, iterators, etc.
|
|
|
| |
Necessary for simd, as we add a type with alignment >8. We were just broken on that before this PR.
|
|
|
|
|
|
| |
* Recombine function pieces after randomly generating them, by creating copies and moving them around. This gives a realistic probability to seeing duplicate expressions, which some optimizations look for, which otherwise the fuzzer would have almost never reached.
* Mutate function pieces after recombination, giving not only perfect duplicates but also near-duplicates.
These operations take into account the type, but not the nesting and uniqueness of labels, so we fix that up afterwards (when something is broken, we replace it with something trivial).
|
|
|
| |
For souper we need to flip some operations in DataFlow IR, since souper doesn't have any redundant ones. But we flipped not just left and right but also equal/not equal, which was wrong.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
We create some fake nodes for internal use, and were looking at one by mistake. This fixes that by
* Creating a non-ambiguous fake node, a call (which represents an unknown value properly, unlike a zero which we had before).
* Make DFO not rely on those values, if it knows a node is constant, apply those constant values.
Found by the fuzzer.
|
|
|
|
|
| |
We need to verify that the reordering is valid if there are side effects.
Original bug report: https://groups.google.com/forum/?nomobile=true#!topic/emscripten-discuss/HIlGf8o2Ato
|
|
|
|
|
| |
Not being able to evaluate a ctor is different to that ctor
being absent. This is masked a bug in emscripten where we
were spelling the names of the ctors wrong on the command line.
|