summaryrefslogtreecommitdiff
path: root/test/lld
Commit message (Collapse)AuthorAgeFilesLines
* Support stack overflow checks in standalone mode (#2525)Alon Zakai2019-12-122-0/+343
| | | | | | | | | In normal mode we call a JS import, but we can't import from JS in standalone mode. Instead, just trap in that case with an unreachable. (The error reporting is not as good in this case, but at least it catches all errors and halts, and the emitted wasm is valid for standalone mode.) Helps emscripten-core/emscripten#10019
* Remove FunctionType (#2510)Thomas Lively2019-12-1121-166/+188
| | | | | | | | | | | | | | | | | Function signatures were previously redundantly stored on Function objects as well as on FunctionType objects. These two signature representations had to always be kept in sync, which was error-prone and needlessly complex. This PR takes advantage of the new ability of Type to represent multiple value types by consolidating function signatures as a pair of Types (params and results) stored on the Function object. Since there are no longer module-global named function types, significant changes had to be made to the printing and emitting of function types, as well as their parsing and manipulation in various passes. The C and JS APIs and their tests also had to be updated to remove named function types.
* Rename a couple of files that were missing in #2518 (#2521)Sam Clegg2019-12-104-0/+0
|
* Use wat over wast for text format filenames (#2518)Sam Clegg2019-12-0838-1/+1
|
* Regenerate lld test inputs (#2502)Sam Clegg2019-12-0517-829/+182
|
* Don't attempt to de-duplicate asm consts (#2422)Sam Clegg2019-11-045-10/+10
| | | | | | | | | | | | Since we switched the using memory addresses for asm const indexes and stopping trying to modify the code we can no loner de-duplicate the asm const strings here. If we want to de-duplicate in the strings in emscripten we could do that but it seems like a marginal benefit. This fixes the test_html5_gamepad failures which is currently showing up on the emscripten waterfall.
* Use absolute memory addresses for emasm string indexes. (#2408)Sam Clegg2019-10-315-29/+40
| | | | | | | | | | Before we used 0-based indexes which meant that we needed to modify the code calling the emasm function to replace the first argument. Now we use the string address itself as the index/code for the emasm constant. This allows use code to go unmodifed as the emscripten side will accept the memory address as the index/code. See: https://github.com/emscripten-core/emscripten/issues/9013
* When renaming functions ensure the corresponding GOT.func entry is also ↵Sam Clegg2019-10-253-0/+373
| | | | | | renamed (#2382) Fixes https://github.com/WebAssembly/binaryen/issues/2180
* MAIN_THREAD_EM_ASM support (#2367)Jacob Gravelle2019-10-072-0/+466
| | | | | | | | | | | | * Support for sync and async main-thread EM_ASM * Fix up import names as well * update test * fix whitespace * clang-format
* Only create `_start` if it doesn't already exist (#2363)Sam Clegg2019-09-272-0/+103
|
* Add a --standalone-wasm flag to wasm-emscripten-finalize (#2333)Alon Zakai2019-09-186-0/+327
| | | The flag indicates that we want to run the wasm by itself, without JS support. In that case we don't emit JS dynCalls etc., and we also emit a wasi _start if there is a main, i.e., we try to use the current conventions in the wasm-only space.
* Remove code to handle EM_ASM and setjmp/longjmp (#2302)Guanzhong Chen2019-08-162-52/+23
| | | | | | | | | This reverts commit 12add6f17c377de7ac334e8fa7885b61b98f3db4 (#2283). This is done due to the complexity of supporting EM_ASM and setjmp/longjmp, especially with dynamic linking thrown into the mix. In https://reviews.llvm.org/D66356, using EM_ASM and setjmp/longjmp in the same function is now an error.
* Fix EM_ASM not working with setjmp/longjmp (#2283)Guanzhong Chen2019-08-092-23/+52
|
* Implement --check-stack-overflow flag for wasm-emscripten-finalize (#2278)Guanzhong Chen2019-08-022-0/+334
|
* Revert "Fix EM_ASM not working with setjmp/longjmp (#2271)" (#2277)Alon Zakai2019-08-012-52/+23
| | | | | This reverts commit 692f4666fd116fb7827b53348978f29bba253d47. See details in the reverted PR.
* Fix EM_ASM not working with setjmp/longjmp (#2271)Guanzhong Chen2019-07-312-23/+52
| | | | | This fix does not handle dynamic linking, which requires additional work. Refs https://github.com/emscripten-core/emscripten/issues/8894.
* wasm-emscripten-finalize: Add mainReadsParams metadata (#2247)Alon Zakai2019-07-2214-14/+28
| | | | | | | The new flag indicates whether main reads the argc/argv parameters. If it does not, we can avoid emitting code to generate those arguments in the JS, which is not trivial in small programs - it requires some string conversion code. Nicely the existing test inputs were enough for testing this (see outputs). This depends on an emscripten change to land first, as emscripten.py asserts on metadata fields it doesn't recognize.
* Handle passive segments in wasm-emscripten-finalize (#2217)Thomas Lively2019-07-112-0/+151
|
* Ignore --initial-stack-pointer arg to wasm-emscripten-finalize (#2201)Sam Clegg2019-07-1011-11/+11
| | | | | | | | | | | | | We were passing bad value in --initial-stack-pointer which did not include the STATIC_BUMP (since STATIC_BUMP is determinted by the output of finalize). If emscripten wants to set the stack pointer position it can do so by calling the stackRestore() function at startup. This argument will be removed completely once we stop passing it on the emscripten side. See https://github.com/emscripten-core/emscripten/issues/8905
* Refactor type and function parsing (#2143)Heejin Ahn2019-05-248-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Refactored & fixed typeuse parsing rules so now the rules more closely follow the spec. There have been multiple parsing rules that were different in subtle ways, which are supposed to be the same according to the spec. - Duplicate types, i.e., types with the same signature, in the type section are allowed as long as they don't have the same given name. If a name is given, we use it; if type name is not given, we generate one in the form of `$FUNCSIG$` + signature string. If the same generated name already exists in the type section, we append `_` at the end. This causes most of the changes in the autogenerated type names in test outputs. - A typeuse has to be in the order of (type) -> (param) -> (result), if more than one of them exist. In case of function definitions, (local) has to be after all of these. Fixed some test cases that violate this rule. - When only (param)/(result) are given, its type will be the type with the smallest existing type index whose parameter and result are the same. If there's no such type, a new type will be created and inserted. - Added a test case `duplicate_types.wast` to test type namings for duplicate types. - Refactored `parseFunction` function. - Add more overrides to helper functions: `getSig` and `ensureFunctionType`.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-2111-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* Remove f32 legalization from LegalizeJSInterface (#2052)Sam Clegg2019-04-251-24/+2
| | | | | As well as i64 splitting this pass was also converting f32 to f64 at the wasm boundry. However it appears this is not actually useful and makes somethings (such as dynamic linking) harder.
* wasm-emscripten-finalize: Handle relocatable code in AsmConstWalker (#2035)Sam Clegg2019-04-222-18/+7
| | | | | | | | | When replacing the first argument to an asm call, allow more complex expressions for expressing the address. This fixes the case where the first argument might be the result of adding a constant to __memory_base.
* Change default feature set to MVP (#1993)Thomas Lively2019-04-1613-91/+0
| | | | | In the absence of the target features section or command line flags. When there are command line flags, it is an error if they do not exactly match the target features section, except if --detect-features has been provided. Also adds a --print-features pass to print the command line flags for all enabled options and uses it to make the feature tests more rigorous.
* Make sure we always add signature to `fp$` functions (#1994)Sam Clegg2019-04-164-39/+80
| | | | | | | | Previously we were searching for the function by name but this doesn't work when the internal name for the function is different. In order to repro such a case the shared.c test was converted to C++ since then binaryen's internal name is different since it comes from the de-mangled name section.
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-1213-39/+39
| | | | | This allows us to emit a (potentially modified) target features section and conditionally emit other sections such as the DataCount section based on the presence of features.
* Handle relocatable code in AsmConstWalker (#1992)Sam Clegg2019-04-1011-28/+556
| | | | | | In relocatable code the constant offset might be relative to __memory_base.
* wasm-emscripten-finalize: rename function pointer getter functions (#1988)Sam Clegg2019-04-081-3/+3
| | | | | | | | Turns out there was already a precedent in emscripten for using `fp$` for these functions. Also, improve the heuristics for guessing the stack pointer global. There are cases where we don't use have an explicit stack pointer at all but *do* have both imported and exported globals.
* Add missing comma in metadata JSON (#1983)Thomas Lively2019-04-0512-12/+12
|
* Add feature options to emscripten metadata (#1982)Thomas Lively2019-04-0512-0/+108
| | | Emscripten runs wasm-emscripten-finalize before running wasm-opt, so the target features section is stripped out before optimizations are run. One option would have been to add another wasm-opt invocation at the very end to strip the target features section, but dumping the features as metadata avoids the extra tool invocation. In the long run, it would be nice to have only as single binaryen invocation to do all the work that needs doing.
* wasm-emscripten-finalize: add namedGlobals to output metadata (#1979)Sam Clegg2019-04-0412-30/+45
| | | | | | This key is used by emscripten when building with MAIN_MODULE in order to export global variables from the main module to the side modules.
* wasm-emscripten-finalize: Improve shared library support (#1961)Sam Clegg2019-04-0212-36/+152
| | | | | | | | | | | | | | | | | Convert PIC code generated by llvm to work with the current emscripten ABI for dynamic linking: - Convert mutable global imports from GOT.mem and GOT.func into internal globals. - Initialize these globals on started up in g$foo and f$foo imported functions to calculate addresses at runtime. Also: - Add a test case for linking and finalizing a shared library - Allow __stack_pointer global to be non-existent as can be case for a shared library. - Allow __stack_pointer global to be an import, as can be the case for a shared library.
* Update lld test expectations (#1960)Sam Clegg2019-03-2112-250/+722
|
* wasm-emscripten-finalize: Remove JSCall thunk generation (#1938)Sam Clegg2019-03-121-359/+0
| | | | We now implement addFunction by creating a wasm module to wrap that JS function and simply adding it to the table.
* wasm-emscripten-finalize: separateDataSegments() fix (#1897)Alon Zakai2019-02-062-0/+0
| | | | | We should emit a file with only the data segments, starting from the global base, and not starting from zero (the data before is unneeded, and the emscripten loading code assumes it isn't there). Also fix the auto updater to work properly on .mem test updating.
* Fix EM_ASM+pthreads (#1891)Alon Zakai2019-02-042-0/+117
| | | To calculate the metadata, we must look at the segments. If we split them out earlier (which we do for threads), they aren't there.
* wasm-emscripten-finalize: Emit illegal dynCalls, and legalize them (#1890)Alon Zakai2019-01-292-35/+50
| | | Before this, we just did not emit illegal dynCalls. This was wrong as we do need them (e.g. if a function with a setjmp call calls a function with an i64 param - we'll have an invoke with that signature there). We just need to legalize them. This fixes that by first emitting them, and second by running legalization late, after dynCalls have been generated, so it legalizes them too.
* Handle EM_ASM/EM_JS in LLVM wasm backend O0 output (#1888)Alon Zakai2019-01-284-0/+270
| | | | | | | See emscripten-core/emscripten#7928 - we have been optimizing all wasms until now, and noticed this when the wasm object file path did not do so. When not optimizing, our methods of handling EM_ASM and EM_JS fail since the patterns are different. Specifically, for EM_ASM we hunt for emscripten_asm_const(X, where X is a constant, but without opts it may be a get of a local. For EM_JS, the function body may not just contain a const, but a block with a set of the const and a return of a get later. This adds logic to track gets and sets in basic blocks, which is sufficient to handle this.
* Emscripten stack simplification (#1870)Alon Zakai2019-01-169-18/+9
| | | | | | This takes advantage of the recent memory simplification in emscripten, where JS static allocation is done at compile time. That means we know the stack's initial location at compile time, and can apply it. This is the binaryen side of that: * asm2wasm support for asm.js globals with an initial value var X = Y; where Y is not 0 (which is what the stack now is). * wasm-emscripten-finalize support for a flag --initial-stack-pointer=X, and remove the old code to import the stack's initial location.
* Massive renaming (#1855)Thomas Lively2019-01-0716-253/+253
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* 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.
* wasm-emscripten-finalize: import env.STACKTOP, like asm2wasm doesAlon Zakai2018-12-119-9/+18
|
* 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.
* remove unnecessary constraint on remove-unused-br optimization of if-br-* ↵Alon Zakai2018-12-041-0/+0
| | | | into br_if,* - we can handle a concretely typed if as well, which can happen at the end of a block (#1799)
* 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.
* 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.
* 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
* Emit imports before defined things in text format (#1715)Alon Zakai2018-11-017-16/+16
| | | | | That is the correct order in the text format, wabt errors otherwise. See AssemblyScript/assemblyscript#310
* Expand asmConsts metadata to fit the shape of proxying async EM_ASMs (no ↵Jacob Gravelle2018-10-251-1/+1
| | | | actual support) (#1711)