summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Fuzzer: Tweak constants during mutation as well (#3272)Alon Zakai2020-10-211-25/+25
| | | | Move the tweak function to an outer location, and call it from mutate() with some probability.
* Remove old/non-working SpillPointers pass (#3261)Sam Clegg2020-10-202-1629/+0
| | | | | | | | | And associated stack.h. The current stack.h clearly doesn't work with the llvm back as it assumes the stack grows up, which means non of these has been working or used in a long time. Rather than trying to fix this unused features its probably cleaner to just remove it for now and restore it rom git history if its someone that anyone actually wants to use in the future.
* Optimize signed division when RHS is signed minimum (#3221)Max Graey2020-10-202-3/+41
|
* Avoid name collisions in MemoryPacking (#3265)Alon Zakai2020-10-201-34/+34
| | | | | | | | | Such a collision can happen if we run the pass twice, and somehow it finds more to optimize. To make this easy, add a general utility for getting a unique name based on a root + a numeric suffix to avoid collisions. Fixes the second testcase in #3225
* Remove legacy asm.js tests (#3260)Sam Clegg2020-10-1922-13886/+0
| | | I don't think these files have been referenced since #3042 landed.
* Fix validateGlobally usage in validator, and an i64-to-i32 bug hidden by it ↵Alon Zakai2020-10-192-1/+33
| | | | | | | | | | | | | | (#3253) validateGlobally means that we can't do lookups on the module. A few places were missing that, or had it wrong. I think the reason for the wrong usages is that we used to have types on the module, and then removed that, so more is now validatable actually. This uncovered a real bug, where i64-to-32 would ignore an unreachable parameter of a call_indirect. That's bad, since if the type is i64, we need to replace it with two parameters. To fix that, just handle unreachability there, using the existing logic (which skips the call_indirect entirely in this case).
* Inlining fuzz fix: Notice ref.func function references in global inits (#3252)Alon Zakai2020-10-192-0/+23
| | | Such a reference may mean we cannot remove a function after inlining it.
* Optimize comparisons with 0/1 in boolean context (#3240)Max Graey2020-10-182-6/+45
| | | | | | | | | | i32(bool(x)) != 0 ==> i32(bool(x)) i64(bool(x)) & 1 ==> i64(bool(x)) Also: * clean up related matching rules in optimizeWithConstantOnRight * add more explanations about isPowerOf2Float & rename to isPowerOfTwoInvertibleFloat
* Remove now-redundant stack pointer manipulation passes (#3251)Sam Clegg2020-10-188-21/+14
| | | | The use of these passes was removed on the emscripten side in https://github.com/emscripten-core/emscripten/pull/12536.
* finalize: remove legacy support for "table" import (#3249)Sam Clegg2020-10-165-5/+5
| | | | | These days we always export the table, except in the case of dynamic linking, and even then we use the name `__indirect_function_table`.
* Only write explicit names to name section (#3241)Sam Clegg2020-10-152-2/+2
| | | | Fixes: #3226
* Fuzz fix for MemoryPacking on trampled data (#3222)Alon Zakai2020-10-154-3/+189
| | | | | | | | | | | | | I believe originally wasm did not allow overlapping segments, that is, where one memory segment tramples the data from a previous one. But then the spec changed its mind and we allowed it. Binaryen seems to have assumed the original case, and not checked for trampling. If there is a chance of trampling, we cannot optimize out zeros - the zero may have an effect if it tramples data from a previous segment. This does not occur in practice in LLVM output, which is why this wasn't a problem so far, I think. An existing testcase hit this issue, so I split it up.
* Assign import names consistently between text and binaryn reader (#3238)Sam Clegg2020-10-1418-50/+50
| | | | | | | | | The s-parser was assigning numbers names per-type where as the binaryn reader was using the global import count as the number to append. This change switches to use per-element count which I think it preferable as it increases the stability of the auto-generated names. e.g. memory is now always named `$mimport0`.
* [MemoryPacking] Emit the correct segment indices on memory.init (#3239)Thomas Lively2020-10-142-1/+38
| | | | | | | | | | | This PR fixes a bug in which the segment index of a memory.init instruction was incorrect in some circumstances. Specifically, the first segment index used in output memory.init instructions was always the index of the first segment created from splitting up the corresponding input segment. This was incorrect when the input memory.init had an offset that caused it to skip over that first emitted segment so that the first output memory.init should have referred to a subsequent output segment. Fixes #3225.
* Improve partial evaluation (#3236)Max Graey2020-10-142-0/+76
|
* PickLoadSigns fuzz fix: cannot make an atomic operation signed (#3235)Alon Zakai2020-10-132-0/+47
|
* Optimize power of two float divisions (#3018)Max Graey2020-10-134-7/+297
|
* EmscriptenPIC: Remove internalization of GOT entries (#3211)Sam Clegg2020-10-138-184/+39
| | | | | | | wasm-ld now does this better than binaryen and does it by default when linking and executable and optionally with `-Bsymbolic` when linking a shared library. See https://reviews.llvm.org/D89152
* Added Initial Memory64Lowering pass (#3230)Wouter van Oortmerssen2020-10-132-0/+197
| | | | This pass will convert a module with 64-bit loads and stores accessing a 64-bit memory to a regular 32-bit one. Pointers remain 64-bit but are truncated just before use.
* Optimize unsigned divisions when rhs is negative constant (#2991)Max Graey2020-10-132-2/+76
| | | | | | | | `(uint32_t)x / C` --> `x >= C`, where `C > 2^31` `(uint32_t)x / -1` --> `x != -1` and for `shrinkLevel == 0`: `(uint64_t)x / C` --> `uint64_t(x >= C)`, where `C > 2^63` `(uint64_t)x / -1` --> `x != -1`
* Update tests after landing PRs collided (#3232)Alon Zakai2020-10-131-195/+151
|
* Fuzzer: Do not emit random global.get/sets of the hang limit global (#3229)Alon Zakai2020-10-122-123/+539
| | | | | | | | | That global is for internal use. If we emit random sets to it, we could prevent it from doing its job of preventing an infinite loop (normally it decreases each time a loop runs or we recurse, until we reach 0 - if we set it to a nonzero value in that code, that would be bad). Random gets are less of a problem, but may be confusing when debugging a testcase.
* Rename Emscripten EHSjLj functions in wasm backend (#3191)Heejin Ahn2020-10-102-24/+0
| | | | | | | | | | | Now that we are renaming invoke wrappers and `emscripten_longjmp_jmpbuf` in the wasm backend, this deletes all related renaming routines and relevant tests. Depends on #3192. Addresses: #3043 and #3081 Companions: https://reviews.llvm.org/D88697 emscripten-core/emscripten#12399
* RemoveUnusedBrs fuzz fix for switches with a single target and with a value ↵Alon Zakai2020-10-092-0/+44
| | | | | | (#3220) We turn a br_table with a single target into a br, but we reverse the order of the condition and the value when doing so, which we forgot to take into account.
* Re-generate lld test inputs (#3212)Sam Clegg2020-10-094-42/+36
| | | | | | Generated by running: ./scripts/test/generate_lld_tests.py ./auto_update_tests.py
* Validate memory64 (#3202)Alon Zakai2020-10-085-5/+5
|
* Fuzz fix for DuplicateFunctionElimination (#3204)Alon Zakai2020-10-082-1/+22
| | | | The replaceFunctions utility replaced exports by name, but did not check the kind, so it could get confused when names happen to overlap.
* Add optimization rules for some shift operations (#3099)Max Graey2020-10-072-22/+231
| | | Specifically, truncates constant shift values that are greater than the number of bits available and optimizes out explicit masking of the shift value that is redundant with the implicit masking performed by shift operations.
* Revert some changes for #3193 (#3197)Max Graey2020-10-061-4/+4
| | | `(signed)x % (i32|i64).min_s ==> (x & (i32|i64).max_s)` is not valid unless compared to zero.
* fast-math: Fold `fp * -1` to `-fp` (#3189)Max Graey2020-10-053-4/+30
|
* Generalize transforms for #3153 (#3193)Max Graey2020-10-052-9/+155
| | | | | | | | | | | | | | Implement a more general (additional) version of #3153 which also handles negative constant divisors: `(int32)x % -4 == 0` --> `(x & 3) == 0` `x % -C_pot == 0` --> `(x & (abs(C_pot) - 1)) == 0` and special two-complement values as well: `(int32)x % 0x80000000 == 0` --> `(x & 0x7fffffff) == 0` `(int64)x % 0x8000000000000000 == 0` --> `(x & 0x7fffffffffffffff) == 0` as separete rules: `(int32)x % 0x80000000` --> `x & 0x7fffffff` `(int64)x % 0x8000000000000000` --> `x & 0x7fffffffffffffff` The [previous pr](https://github.com/WebAssembly/binaryen/pull/3153) didn't use these possibilities.
* Ordering correction fix in OptimizeInstructions for #3047 (#3195)Alon Zakai2020-10-052-1/+91
| | | | | | | | | | | | (found by the fuzzer) It is not valid to replace x | (y | x) ==> y | x, if x, y cannot be reordered. It is also not valid to replace x ^ (y ^ x) ==> y, if x, y cannot be reordered, for a more subtle reason: if they cannot be reordered then y can affect the value of x (the opposite is not possible as we checked x for side effects so that we could remove one copy). If so, then the second appearance of x could be different, if e.g. it reads a local y writes to. Whereas, if it's ok to reorder, then it's ok to do x ^ (y ^ x) ==> x ^ (x ^ y) ==> y.
* Let GenerateDynCalls generate dynCalls for invokes (#3192)Heejin Ahn2020-10-024-10/+42
| | | | | | This moves dynCall generating functionaity for invokes from `EmscriptenGlueGenerator` to `GenerateDynCalls` pass. So now `GenerateDynCalls` pass will take care of all cases we need dynCalls: functions in tables and invokes.
* Optimize "clear bit mask" combination to cyclic rotation over preinverted ↵Max Graey2020-10-012-0/+32
| | | | mask (#3184)
* Stop generating __growWasmMemory (#3180)Sam Clegg2020-10-0129-251/+28
| | | This depends on https://github.com/emscripten-core/emscripten/pull/12391
* Add C and JS APIs for fast math (#3188)Max Graey2020-10-012-0/+4
| | | Adds `BinaryenGetFastMath` and `BinaryenSetFastMath` to the C API, respectively `binaryen.getFastMath` and `binaryen.setFastMath` to the JS API.
* wasm2js: override incoming memory's grow method (#3185)Sam Clegg2020-09-3012-36/+46
| | | | | | | | | | This will allow for the completely removal of `__growWasmMemory` as a followup. We currently unconditionally generate this function in `generateMemoryGrowthFunction`. See #3180
* Update lld tests (#3182)Heejin Ahn2020-09-3013-16/+16
| | | | This updates lld tests by running generate_lld_tests.py with the latest toolchain.
* Remove unnecessary "new" on Table generation in wasm2js (#3163)Alon Zakai2020-09-302-2/+2
| | | It's not an actual constructor, just a JS function that returns the object.
* Add --fast-math mode (#3155)Alon Zakai2020-09-307-33/+212
| | | | | | | | | | | | Similar to clang and gcc, --fast-math makes us ignore corner cases of floating-point math like NaN changes and (not done yet) lack of associativity and so forth. In the future we may want to have separate fast math flags for each specific thing, like gcc and clang do. This undoes some changes (#2958 and #3096) where we assumed it was ok to not change NaN bits, but @binji corrected us. We can only do such things in fast math mode. This puts those optimizations behind that flag, adds tests for it, and restores the interpreter to the simpler code from before with no special cases.
* Fold i32.eqz(wrap_i64(x)) -> i64.eqz(x) where possible (#3181)Max Graey2020-09-302-0/+87
| | | Specifically, when `x` has at most 32 bits so that wrapping doesn't change its value.
* Simplify signed remainders compared with zero (#3153)Max Graey2020-09-292-1/+143
| | | | | | Specifically when the divisor is a power of two. `eqz((signed)x % C_pot)` -> `eqz(x & (C_pot - 1))` `(signed)x % C_pot != 0` -> `x & (C_pot - 1) != 0`
* Fix applying default / unify SExpr and Wasm builder names (#3179)Daniel Wirtz2020-09-3036-50/+50
| | | SExpressionWasmBuilder was not applying default memory and table import names on the memory and table, unlike on functions, globals and events, where it applies them. Also aligns default import names to use the same shorter forms as in binary parsing.
* GC: Add stubs for the remaining instructions (#3174)Daniel Wirtz2020-09-292-0/+24
| | | NFC, except adding most of the boilerplate for the remaining GC instructions. Each implementation site is marked with a respective `TODO (gc): theInstruction` in between the typical boilerplate code.
* Add also non-equal with zero simplification for boolean context (#3178)Max Graey2020-09-292-1/+17
|
* GC: Fuzzing support for i31 (#3169)Daniel Wirtz2020-09-295-200/+441
| | | Integrates `i31ref` types and instructions into the fuzzer, by assuming that `(i31.new (i32.const N))` is constant and hence suitable to be used in global initializers.
* Prototype extended-name-section proposal (#3162)Daniel Wirtz2020-09-2951-196/+239
| | | Implements the parts of the Extended Name Section Proposal that are trivially applicable to Binaryen, in particular table, memory and global names. Does not yet implement label, type, elem and data names.
* Fix regression in memory.fill due to Memory64 (#3176)Wouter van Oortmerssen2020-09-282-0/+8
| | | details: https://github.com/WebAssembly/binaryen/issues/3149
* Lower signed binops to unsigned binops when possible (#2988)Max Graey2020-09-283-19/+167
| | | This can unlock further instruction optimizations that do not apply to signed operations.
* Fix low_pc updating when the expression is right at the start (#3175)Alon Zakai2020-09-283-0/+506
| | | | | In that case LLVM emits the address of the declarations area (where locals are declared) of the function, which is even earlier than the instructions actual first byte. I'm not sure why it does this, but it's easy to handle.