summaryrefslogtreecommitdiffstats
path: root/lld/wasm
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Add support for --gc-sectionsSam Clegg2018-01-3110-13/+180
| | | | | | | | | | | | | | | In this initial version we only GC symbols with `hidden` visibility since other symbols we export to the embedder. We could potentially modify this the future and only use symbols explicitly passed via `--export` as GC roots. This version of the code only does GC of data and code. GC for the types section is coming soon. Differential Revision: https://reviews.llvm.org/D42511 llvm-svn: 323842
* [WebAssembly] Sort options in `Options.td`. NFC.Sam Clegg2018-01-281-33/+41
| | | | | | Differential Revision: https://reviews.llvm.org/D42627 llvm-svn: 323624
* [WebAssembly] Add getName and getFileName methods to InputChunk base class. NFC.Sam Clegg2018-01-282-4/+6
| | | | | | | | | | Summary: These are useful to upcoming addition of --gc-sections support. Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D42626 llvm-svn: 323623
* clang formatSam Clegg2018-01-286-21/+21
| | | | llvm-svn: 323622
* [WebAssemly] Associate symbol with InputChunk in which they are defined. NFC.Sam Clegg2018-01-288-48/+58
| | | | | | | | | | | | | | | | Summary: Rather than explicit Function or InputSegment points store a pointer to the base class (InputChunk) and use llvm dynamic casts when we need a subtype. This change is useful for add the upcoming gc-section support wants to deal with all input chunks. Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D42625 llvm-svn: 323621
* [WebAssembly] Remove unneeded include. NFC.Sam Clegg2018-01-281-4/+2
| | | | llvm-svn: 323620
* [WebAssembly] Don't duplicate functions in table outputSam Clegg2018-01-244-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | Previously, we were ensuring that the "output index" for InputFunctions was unique across all symbols that referenced a function body, but allowing the same function body to have multiple table indexes. Now, we use the same mechanism for table indexes as we already do for output indexes, ensuring that each InputFunction is only placed in the table once. This makes the LLD output table denser and smaller, but should not change the behaviour. Note that we still need the `Symbol::TableIndex` member, to store the table index for function Symbols that don't have an InputFunction, i.e. for address-taken imports. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42476 llvm-svn: 323379
* [WebAssembly] Always start table index at 1, even for relocatable outputSam Clegg2018-01-241-8/+5
| | | | | | | | | | | | Previously llvm was using 0 as the first table index for wasm object files but now that has switched to 1 we can have the output of lld do the same and simplify the code. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42096 llvm-svn: 323378
* [WebAssembly] Remove excess debugging. NFC.Sam Clegg2018-01-241-2/+0
| | | | llvm-svn: 323286
* [WebAssembly] Update to match llvm changes to TABLE relocationsSam Clegg2018-01-235-54/+57
| | | | | | | | | | | | | TABLE relocations now store the function that is being refered to indirectly. See rL323165. Also extend the call-indirect.ll a little. Based on a patch by Nicholas Wilson! llvm-svn: 323168
* [WebAssembly] Remove --emit-relocsSam Clegg2018-01-225-16/+8
| | | | | | | | | | This was added to mimic ELF, but maintaining it has cost and we currently don't have any use for it outside of the test code. Differential Revision: https://reviews.llvm.org/D42324 llvm-svn: 323154
* [WebAssembly] Remove special handling of entry point export.Sam Clegg2018-01-204-12/+16
| | | | | | | | | | | | Its much easier to export it via setHidden(false), now that that is a thing. As a side effect the start function is not longer always exports first (becuase its being exported just like all the other function). Differential Revision: https://reviews.llvm.org/D42321 llvm-svn: 323025
* [WebAssembly] Remove redundant function: addSyntheticUndefinedFunction. NFC.Sam Clegg2018-01-202-10/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D42327 llvm-svn: 323024
* [WebAssembly] Remove custom handling for undefined entrySam Clegg2018-01-201-2/+0
| | | | | | | | | | | This code was needed back when we were not able to write out the synthetic symbol for main. Add tests to make sure we can handle this now. Differential Revision: https://reviews.llvm.org/D42322 llvm-svn: 323020
* [WebAssembly] Include SYMBOL_INFO for imports as well as exportsSam Clegg2018-01-191-6/+13
| | | | | | | | | | Only effects --emit-relocs/--relocatable Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42306 llvm-svn: 322994
* [WebAssembly] Include weak imports when linking with --relocatableSam Clegg2018-01-191-1/+1
| | | | | | | | | | We need these import since relocations are generated against them. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42305 llvm-svn: 322990
* [WebAssembly] Allow non-zero table offset in input objectSam Clegg2018-01-192-4/+4
| | | | | | | | | | Summary: This change enables D42284 to land without breaking lld Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D42285 llvm-svn: 322976
* [WebAssembly] Fix variable whose name is also a type nameSam Clegg2018-01-191-7/+7
| | | | | | Some compilers don't like this and generate a warning. llvm-svn: 322921
* [WebAssembly] Export the stack pointer when using --emit-relocsSam Clegg2018-01-181-3/+6
| | | | | | | | | | | | This solves the problem that --emit-relocs needs the stack-pointer to be exported, in order to write out any relocations that reference the __stack_pointer symbol by its symbol index. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42237 llvm-svn: 322911
* [WebAssembly] Add missing function exports and SYM_INFO to --relocatable outputSam Clegg2018-01-181-33/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When writing relocatable files we were exporting for all globals (including file-local syms), but not for functions. Oops. To be consistent with non-relocatable output, all symbols (file-local and global) should be exported. Any symbol targetted by further relocations needs to be exported. The lack of local function exports was just an omission, I think. Second bug: Local symbol names can collide, causing an illegal Wasm file to be generated! Oops again. This only previously affected producing relocatable output from two files, where each had a global with the same name. We need to "budge" the symbol names for locals that are exported on relocatable output. Third bug: LLD's relocatable output wasn't writing out any symbol flags! Thus the local globals weren't being marked as local, and the hidden flag was also stripped... Added tests to exercise colliding local names with/without relocatable flag Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42105 llvm-svn: 322908
* [WebAssembly] Simplify generation of "names" sectionSam Clegg2018-01-173-56/+30
| | | | | | | | | | | | | | | | Simplify generation of "names" section by simply iterating over the DefinedFunctions array. This even fixes some bugs, judging by the test changes required. Some tests are asserting that functions are named multiple times, other tests are asserting that the "names" section contains the function's alias rather than its original name Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42076 llvm-svn: 322751
* [WebAssembly] Remove DEBUG_FUNCTION_NAME after llvm changeSam Clegg2018-01-171-3/+0
| | | | | | | | Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42193 llvm-svn: 322745
* [WebAssembly] Remove non-existent method declaration. NFC.Sam Clegg2018-01-171-1/+0
| | | | | | Patch by Nicholas Wilson! llvm-svn: 322732
* [WebAssembly] Remove unused member variable. NFC.Sam Clegg2018-01-171-2/+1
| | | | | | Patch by Nicholas Wilson! llvm-svn: 322731
* [WebAssembly] Fix typo in commentSam Clegg2018-01-171-1/+1
| | | | | | Patch by Nicholas Wilson! llvm-svn: 322727
* [WebAssembly] Refactor InputChunk.getSize(). NFCSam Clegg2018-01-171-8/+5
| | | | | | | | Also, remove trailing semicolons. Patch by Nicholas Wilson! llvm-svn: 322726
* [WebAssembly] Define __heap_base globalSam Clegg2018-01-173-0/+12
| | | | | | | | | This is an immutable exported global representing the start of the heap area. It is a page aligned. Differential Revision: https://reviews.llvm.org/D42030 llvm-svn: 322609
* [WebAssembly] Create synthetic __dso_handle symbolSam Clegg2018-01-171-0/+9
| | | | | | | | | | | | | This is used by __cxa_ataxit to determine the currently executing DLL. Once we fully support DLLs this will need to be set to some address within the DLL. The ELF linker added support for this symbol here: https://reviews.llvm.org/D33856 Differential Revision: https://reviews.llvm.org/D42024 llvm-svn: 322606
* [WebAssembly] Fix build failures due to warningSam Clegg2018-01-131-0/+2
| | | | | | | | Oops, the waterfall tests with `-Werror -Wunused-variable`. Differential Revision: https://reviews.llvm.org/D42028 llvm-svn: 322442
* Revert "[WebAssembly] Move checking of InputSegment comdat group earlier"Sam Clegg2018-01-132-8/+6
| | | | | | This reverts commit 7421eab7ccf2e14518f4526a084a5afc76ac9c6a. llvm-svn: 322441
* [WebAssembly] Move checking of InputSegment comdat group earlierSam Clegg2018-01-132-6/+8
| | | | | | | This should also fixe an unused varaible warning in the realeae build. llvm-svn: 322440
* Remove extraneous semicolon.Eric Christopher2018-01-131-1/+1
| | | | llvm-svn: 322426
* [WebAssembly] Use ArrayRef over raw pointersSam Clegg2018-01-133-15/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D42013 llvm-svn: 322423
* [WebAssembly] Add COMDAT supportSam Clegg2018-01-126-12/+106
| | | | | | | | | | | | | | | | | | See https://bugs.llvm.org/show_bug.cgi?id=35533, and D40844 Things covered: * Removing duplicate data segments (as determined by COMDATs emitted by the frontend) * Removing duplicate globals and functions in COMDATs * Checking that each time a COMDAT is seen it has the same symbols as at other times (ie it's a stronger check than simply giving all the symbols in the COMDAT weak linkage) Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D40845 llvm-svn: 322415
* [WebAssembly] Fix typo in file headerSam Clegg2018-01-121-1/+1
| | | | llvm-svn: 322412
* [WebAssembly] Add --export flag to force a symbol to be exportedSam Clegg2018-01-124-4/+25
| | | | | | | | | | This is useful for emscripten or other tools that want to selectively exports symbols without necessarily changing the source code. Differential Revision: https://reviews.llvm.org/D42003 llvm-svn: 322408
* [WebAssembly] Create synthetic __wasm_call_ctors functionSam Clegg2018-01-128-49/+157
| | | | | | | | | | | This change create a new synthetic function in the final output binary which calls the static constructors in sequence. See: https://github.com/WebAssembly/tool-conventions/issues/25 Differential Revision: https://reviews.llvm.org/D41893 llvm-svn: 322388
* [WebAssembly] Don't allow functions to be named more than onceSam Clegg2018-01-124-5/+16
| | | | | | | | | | Even though a function can have multiple names in the linking standards (i.e. due to aliases), there can only be one name for a given function in the NAME section. Differential Revision: https://reviews.llvm.org/D41975 llvm-svn: 322383
* [WebAssembly] Reduce output of --verboseSam Clegg2018-01-122-4/+5
| | | | llvm-svn: 322337
* [WebAssembly] When loading libraries look for companion `.imports` fileSam Clegg2018-01-111-6/+24
| | | | | | | | | | | | | | | | | | This allows libraries to supply a list of symbols which are allowed to be undefined at link time (i.e. result in imports). This method replaces the existing mechanism (-allow-undefined-file) used by the clang driver to allow undefined symbols in libc. For more on motivation for this see: https://github.com/WebAssembly/tool-conventions/issues/35 In the long run we hope to remove this features and instead include this information in the object format itself. Differential Revision: https://reviews.llvm.org/D41922 llvm-svn: 322320
* [WebAssembly] Optimize Writer::lookupTypeSam Clegg2018-01-101-2/+5
| | | | | | Followup on https://reviews.llvm.org/D41894 llvm-svn: 322219
* [WebAssembly] Move relocation handling InputChunks.cppSam Clegg2018-01-105-152/+157
| | | | | | | | | Teach each input chunk how to write itself and apply its own relocations. Differential Revision: https://reviews.llvm.org/D41891 llvm-svn: 322212
* [WebAssembly] Add seperate Writer::lookupType and Writer::registerType. NFCSam Clegg2018-01-101-9/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D41894 llvm-svn: 322211
* [WebAssembly] Add InputChunk as common base class for InputSegment and ↵Sam Clegg2018-01-1013-183/+165
| | | | | | | | InputFunction. NFC. Differential Revision: https://reviews.llvm.org/D41419 llvm-svn: 322148
* [WebAssembly] Refactor symbol and symbol table to remove WasmSymbol referencesSam Clegg2018-01-106-93/+91
| | | | | | | | | | | | | | | This WasmSymbol types comes directly from the input objects but we want to be able to represent synthetic symbols too. This is more in line with how the ELF linker represents symbols. This change also removes the logic from Symbol::getVirtualAddress for finding the global address and instead has the InputFile provide this. Differential Revision: https://reviews.llvm.org/D41426 llvm-svn: 322145
* [WebAssembly] Output functions individuallySam Clegg2018-01-0911-214/+266
| | | | | | | | | | | | | The code section is now written out one function at a time rather than all the functions in a given objects being serialized at once. This change lays the groundwork for supporting --gc-sections. Differential Revision: https://reviews.llvm.org/D41315 llvm-svn: 322138
* [WebAssembly] Write out undefined symbol addresses as zeroSam Clegg2018-01-085-23/+20
| | | | | | | | | | | | | The addresses of undefined symbols that make it into the final executable (i.e. weak references to non-existent symbols) should resolve to zero. Also, make sure to not include function in the indirect function table if they are not included in the output. Differential Revision: https://reviews.llvm.org/D41839 llvm-svn: 322045
* [WebAssmebly] Fix references to weak aliasesSam Clegg2017-12-212-9/+10
| | | | | | | | Corresponding LLVM change: https://reviews.llvm.org/D41472 Differential Revision: https://reviews.llvm.org/D41473 llvm-svn: 321244
* [WebAssembly] Improve toString(OutputSection). NFC.Sam Clegg2017-12-203-22/+17
| | | | llvm-svn: 321146
* [WebAssembly] Apply data relocations in parallel. NFC.Sam Clegg2017-12-194-13/+23
| | | | | | | | | | Store data relocations with their respective segment. This allows relocations to be applied as each segment is written (and therefore in parallel). Differential Revision: https://reviews.llvm.org/D41410 llvm-svn: 321105
OpenPOWER on IntegriCloud