summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* wasm-emscripten-finalize: Add tableSize to metadata (#1826)Sam Clegg2018-12-149-0/+9
| | | | This allows emscripten to generate table of the correct size. Right now is simply defaults to creating a table to size 1024.
* SIMD (#1820)Thomas Lively2018-12-1314-1237/+13383
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* No exit runtime pass (#1816)Alon Zakai2018-12-132-0/+47
| | | 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.
* Don't error on too many locals - just oom (#1822)Alon Zakai2018-12-131-0/+0
| | | I think I added this error for fuzzing, but it is harmful as it prevents a module with too many locals from being loaded - if we could load it, we might be able to optimize it to have fewer locals...
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-119-9/+18
|
* wasm-ctor-eval: handle the stack going either up or downAlon Zakai2018-12-113-0/+33
|
* Use template magic for tracing expressions (#1815)Thomas Lively2018-12-102-16/+16
|
* Remove unused tests from test/dot_s (#1814)Sam Clegg2018-12-0740-3383/+0
| | | | We have a bug open (#1813) to verify that we don't loose coverage but there is no point in keeping these unused files for now.
* Format metadata json using mutliple lines for readability (#1804)Sam Clegg2018-12-059-9/+336
|
* Fix initializerFunctions output by wasm-emscripten-finalize (#1803)Sam Clegg2018-12-058-8/+8
| | | I broke this to be alwasy empty in #1795.
* Properly optimize loop values (#1800)Alon Zakai2018-12-0515-5794/+5885
| | | Remove the existing hack, and optimize them just like we do for ifs and blocks. This is now able to handle a few more cases than before.
* remove unnecessary constraint on remove-unused-br optimization of if-br-* ↵Alon Zakai2018-12-043-8/+51
| | | | into br_if,* - we can handle a concretely typed if as well, which can happen at the end of a block (#1799)
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-0411-1472/+1513
|
* Run coalesce-locals after the final simplify-locals.Alon Zakai (kripken)2018-12-0418-3618/+3431
| | | | | | We now emit more sets and tees of if-elses from simplify-locals, and coalesce-locals is necessary to remove them if they are ineffectual, that is, if no get will read them.
* Improve selectification in remove-unused-brsAlon Zakai (kripken)2018-12-045-52/+89
| | | | | | | | 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.
* Speculate in simplify-locals that it is worth turning an if intoAlon Zakai (kripken)2018-12-0422-3226/+3608
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | an if-else. If an if sets a local, (if (..condition..) (set_local $x (..value..)) ) we can turn it into (set_local $x (if (..condition..) (..value..) (get_local $x) ) ) This increases code size and adds a branch in the if, but allows the set to be optimized into a tee or optimized out entirely. In the worst case, other optimizations can break up an if with a copy in one of its arms later. Includes a determinism fix for EquivalentSets, which this patch triggered.
* Move if copy logic from coalesce-locals to remove-unused-brs.Alon Zakai (kripken)2018-12-043-22/+332
| | | | | | | | | | | | | | | | | | | | | | | 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.
* wasm-emscripten-finalize: ensure table/memory imports use emscripten's ↵Sam Clegg2018-12-038-16/+16
| | | | | | | | expected names (#1795) This means lld can emscripten can disagree about the naming of these imports and emscripten-wasm-finalize will take care of paper over the differences.
* Add --strip that removes debug info (#1787)Alon Zakai2018-12-032-0/+15
| | | | This is sort of like --strip on a native binary. The more specific use case for us is e.g. you link with a library that has -g in its CFLAGS, but you don't want debug info in your final executable (I hit this with poppler now). We can make emcc pass this to binaryen if emcc is not building an output with intended debug info.
* Fuzzing: log values during execution (#1779)Alon Zakai2018-11-302-793/+1092
| | | | | | | | 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.
* Add support for a mutable globals as a Feature (#1785)Sam Clegg2018-11-306-0/+63
| | | | | This picks up from #1644 and indeed borrows the test case from there.
* Add v128 type (#1777)Thomas Lively2018-11-294-3/+6
|
* LocalCSE fuzz fix: invalidate the set operations too (#1778)Alon Zakai2018-11-282-0/+43
| | | | | 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.
* Start to implement #1764 (#1776)Alon Zakai2018-11-282-0/+145
| | | | | | This adds a first instance of the rules discussed in #1764 , specifically, x == y || x > y => x >= y
* Stricter Canonicalization (#1774)Alon Zakai2018-11-2727-19858/+20422
| | | 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.
* ReFinalize fuzz fix (#1771)Alon Zakai2018-11-272-0/+45
| | | | | | 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.
* Relooper: Merge consecutive blocks (#1770)Alon Zakai2018-11-269-441/+590
| | | That is, A -> B where no other branches go to B. In that case we are guaranteed to not increase code size.
* Branches only invalidate side effects (#1765)Alon Zakai2018-11-264-7118/+7115
| | | 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.
* Merge-Blocks improvements (#1760)Alon Zakai2018-11-2613-11394/+11917
| | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #1761 from juj/minify_exportsjuj2018-11-222-0/+15024
|\ | | | | minify_exports
| * Adjust MinifyImportsAndExports to optionally minify the export names, ↵Jukka Jylänki2018-11-222-0/+15024
| | | | | | | | sometimes that is not desirable.
* | Relooper CFG optimizations (#1759)Alon Zakai2018-11-2126-558/+3066
|/ | | | | | | | | | | | | | | | 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.
* Use getTempRet0/setTempRet0 in LegalizeJSInterface.cpp (#1709)Sam Clegg2018-11-2019-388/+300
| | | | | | | | | | | | | | | | 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 (#1753)Alon Zakai2018-11-209-125/+212
| | | | | | * 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
* Reject all nonexistent instructions in sexp format (#1756)Thomas Lively2018-11-195-10/+6
|
* Fix a merge-blocks fuzz bug (#1755)Alon Zakai2018-11-1920-6369/+6610
| | | | | | * 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
* Generate sexp instruction parser (#1754)Thomas Lively2018-11-195-7/+11
| | | Also fix broken tests surfaced by the new parser.
* Optimize an if exit block into an if arm (#1749)Alon Zakai2018-11-1516-51403/+50965
| | | 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.
* Don't try to optimize away unused names in RemoveUnusedBrs (#1750)Alon Zakai2018-11-1514-246/+225
| | | | | 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.
* MergeBlocks: canonicalize loop exit block position on the inside (#1736)Alon Zakai2018-11-148-77/+108
| | | | * 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
* Handle EM_ASM functions in Tables (#1739)Jacob Gravelle2018-11-142-0/+77
| | | | | Not at all sure why we're seeing any there, but it's easy enough to handle that we might as well.
* Restructure ifs with a value (#1743)Alon Zakai2018-11-142-0/+113
| | | 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.
* ReFinalize fix (#1742)Alon Zakai2018-11-145-17/+62
| | | | | | | 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.
* Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)Derek Schuff2018-11-142-0/+61
| | | | This writes the data section into a file suitable for use with emscripten's --memory-init-file flag
* Better fuzzing (#1735)Alon Zakai2018-11-131-1083/+777
| | | | | | * 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).
* fix flipping in dataflow graph generation (#1732)Alon Zakai2018-11-083-107/+201
| | | 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.
* Rename tableBase/memoryBase to __table_base/__memory_base (#1731)Sam Clegg2018-11-08151-408/+474
|
* Fix a merge-blocks fuzz bug (#1730)Alon Zakai2018-11-082-21/+134
| | | | | | | | | | | | | | | 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.
* Fix a DataFlowOpts bug (#1729)Alon Zakai2018-11-072-0/+21
| | | | | | | 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.
* Fix a bug with (add (sub 0 X) Y) => (sub Y X) (#1727)Alon Zakai2018-11-072-0/+53
| | | | | 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