Commit Graph

41 Commits

Author SHA1 Message Date
Sam Clegg fd1c894a4a [lld][WebAssembly] Convert some lld tests to assembly
When we originally wrote these tests we didn't have a stable and
fleshed out assembly format.  Now we do so we should prefer that
over llvm ir for lld tests to avoid including more part of llvm
than necessary in order to run the test.

This change converts just 30 out of about 130 test files. More to
come when I have some more time.

Differential Revision: https://reviews.llvm.org/D80361
2020-05-28 16:52:01 -07:00
Thomas Lively 393d0f799f [WebAssembly] Allow multivalue signatures in object files
Summary:
Also changes the wasm YAML format to reflect the possibility of having
multiple return types and to put the returns after the params for
consistency with the binary encoding.

Reviewers: aheejin, sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, arphaman, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69156

llvm-svn: 375283
2019-10-18 20:27:30 +00:00
Sam Clegg 7d4ec5af6c [WebAssembly] Don't export __data_end and __heap_base by default.
These can still be exported via --export if needed.

Differential Revision: https://reviews.llvm.org/D62744

llvm-svn: 362276
2019-05-31 22:51:59 +00:00
Sam Clegg 0e6b42f5eb [WebAssebmly] Allow __wasm_call_ctors to be GC'ed
Differential Revision: https://reviews.llvm.org/D58806

llvm-svn: 355240
2019-03-01 22:35:47 +00:00
Thomas Lively 2e1504091e [WebAssembly] Update MC for bulk memory
Summary:
Rename MemoryIndex to InitFlags and implement logic for determining
data segment layout in ObjectYAML and MC. Also adds a "passive" flag
for the .section assembler directive although this cannot be assembled
yet because the assembler does not support data sections.

Reviewers: sbc100, aardappel, aheejin, dschuff

Subscribers: jgravelle-google, hiraditya, sunfish, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57938

llvm-svn: 354397
2019-02-19 22:56:19 +00:00
Thomas Lively 25ff893712 [WebAssembly] Instruction renaming
Summary: Associated with D56338.

Reviewers: aheejin, aardappel

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D56339

llvm-svn: 350610
2019-01-08 06:25:55 +00:00
Sam Clegg 305b0343ce [WebAssembly] Add --[no]-export-dynamic to replace --export-default
In a very recent change I introduced a --no-export-default flag
but after conferring with others it seems that this feature already
exists in gnu GNU ld and lld in the form the --export-dynamic flag
which is off by default.

This change replaces export-default with export-dynamic and also
changes the default to match the traditional linker behaviour.

Now, by default, only the entry point is exported.  If other symbols
are required by the embedder then --export-dynamic or --export can
be used to export all visibility hidden symbols or individual
symbols respectively.

This change touches a lot of tests that were relying on symbols
being exported by default.  I imagine it will also effect many
users but do think the change is worth it match of the traditional
behaviour and flag names.

Differential Revision: https://reviews.llvm.org/D52587

llvm-svn: 343265
2018-09-27 21:06:25 +00:00
Richard Smith 5a778aa79f Revert r339490 to match revert of llvm r339474 in r339630.
llvm-svn: 339635
2018-08-14 01:23:54 +00:00
Richard Trieu f1342bb8b8 Fix WebAssembly tests after r339474
Add flags to llc RUN lines to keep tests passing.

llvm-svn: 339490
2018-08-10 23:58:11 +00:00
Sam Clegg 47e2b6b29e [WebAssembly] Don't error when --undefined symbols are not found
This matches the behavior of the ELF linker where -u/--undefined
means symbols will get pulled in from archives but won't result
in link error if they are missing.

Also, don't actually great symbol table entries for the undefined
symbols, again matching more closely the ELF linker.

This also results in simplification of the code.

Differential Revision: https://reviews.llvm.org/D50279

llvm-svn: 338938
2018-08-04 00:04:06 +00:00
Sam Clegg 262e09018b [WebAssembly] Remove final -wasm component of target triple. NFC.
This has been the default for a while now.

llvm-svn: 332009
2018-05-10 17:59:41 +00:00
Sam Clegg 752494bfe3 [WebAssembly] Check function signatures by default
But only produce a warning (for now) unless --fatal-warnings
is passed.

Differential Revision: https://reviews.llvm.org/D46484

llvm-svn: 331574
2018-05-05 01:23:07 +00:00
Nicholas Wilson 5639da89a9 [WebAssembly] Reorder synthetic functions to come first
This matches the existing ordering that's been there for globals
for a while (__stack_pointer coming first).

Differential Revision: https://reviews.llvm.org/D44333

llvm-svn: 327286
2018-03-12 15:44:07 +00:00
Nicholas Wilson f2f6d5e03b [WebAssembly] Export non-hidden defined data symbols via wasm globals
This fixes a TODO introduced in rLLD325861.

Differential Revision: https://reviews.llvm.org/D43930

llvm-svn: 326581
2018-03-02 14:51:36 +00:00
Nicholas Wilson 4cdf5b8fa0 [WebAssembly] Reorder exports to match symbol table order
This fixes a TODO introduced in rLLD325861.

Differential Revision: https://reviews.llvm.org/D43877

llvm-svn: 326424
2018-03-01 09:38:02 +00:00
Sam Clegg 45f984e625 [WebAssembly] Remove unneeded --no-gc-sections flag from tests. NFC.
Differential Revision: https://reviews.llvm.org/D43889

llvm-svn: 326356
2018-02-28 19:40:03 +00:00
Sam Clegg 99eb42c0c5 [WebAssembly] Remove DataSize from linking metadata
This means we don't need to write the linking metadata section
at all for executable (non-relocatable) output.

Differential Revision: https://reviews.llvm.org/D42869

llvm-svn: 326268
2018-02-27 23:58:03 +00:00
Rui Ueyama f05124e60c Use wasm-ld instead of "lld -flavor wasm".
Invoking lld as ld.lld, ld.ld64, lld-link or wasm-ld is preferred
than invoking lld as lld and pass an -flavor option. We have "lld"
file mostly for historical reasons.

Differential Revision: https://reviews.llvm.org/D43407

llvm-svn: 325405
2018-02-16 22:58:02 +00:00
Sam Clegg 37a4a8a4b1 [WebAssembly] Add __data_end link-sythentic symbol.
This is similar to _end (See https://linux.die.net/man/3/edata for more)
but using our own unique name since our use cases will most likely be
different and we want to keep our options open WRT to memory layout.

This change will allow is to remove the DataSize from the linking
metadata section which is currently being used by emscripten to derive
the end of the data.

Differential Revision: https://reviews.llvm.org/D42867

llvm-svn: 324443
2018-02-07 03:04:53 +00:00
Sam Clegg 279c850cf2 [WebAssembly] Fix signature mismatches in test code
Pass --check-signatures to test executions of lld and
fix resulting errors.

Differential Revision: https://reviews.llvm.org/D42661

llvm-svn: 324042
2018-02-02 00:30:03 +00:00
Sam Clegg 8f6d2def2b [WebAssembly] Write minimal types section
Don't include type signatures that are not referenced by
some relocation.

We don't include this in the -gc-sections settings since
we are always building the type section from scratch,
just like we do the table elements.

In the future we might want to unify the relocation
processing which is currently done once for gc-sections
and then again for building the sympathetic type and
table sections.

Differential Revision: https://reviews.llvm.org/D42747

llvm-svn: 323931
2018-01-31 23:48:14 +00:00
Sam Clegg 0362633fd2 [WebAssembly] Add support for --gc-sections
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
2018-01-31 01:45:47 +00:00
Sam Clegg 70683b2f75 [WebAssembly] Use inline target tripple in test cases
This is somewhat preferable since (in many cases) it allows llc
to be run directly on the .ll files without having to pass the
`-mtriple` argument.

Differential Revision: https://reviews.llvm.org/D42438

llvm-svn: 323299
2018-01-24 03:29:47 +00:00
Rui Ueyama b9b1a522ea Remove trailing whitespace.
llvm-svn: 323287
2018-01-24 00:22:53 +00:00
Sam Clegg ab604a9882 [WebAssembly] Update to match llvm changes to TABLE relocations
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
2018-01-23 01:25:56 +00:00
Sam Clegg 0f0a428738 [WebAssembly] Remove special handling of entry point export.
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
2018-01-20 01:44:45 +00:00
Sam Clegg d3052d5522 [WebAssembly] Add missing function exports and SYM_INFO to --relocatable output
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
2018-01-18 23:40:49 +00:00
Sam Clegg 51bcdc2d49 [WebAssembly] Define __heap_base global
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
2018-01-17 01:34:31 +00:00
Sam Clegg 5068685678 [WebAssembly] Create synthetic __wasm_call_ctors function
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
2018-01-12 18:35:13 +00:00
Sam Clegg f50534b127 [WebAssembly] Update YAML in tests to match LLVM change
Differential Revision: https://reviews.llvm.org/D41878

llvm-svn: 322122
2018-01-09 21:47:36 +00:00
Sam Clegg 7075d3fc1c [WebAssembly] Add test of indirect call to an otherwise unused type
In this case we are calling a function pointer which
a type that doesn't otherwise exist in the code.
Clearly this code can't would trap if it was ever
called (because there is not such function that
the pointer can resolve to).

But it should valid and compile and link and validation
time.

llvm-svn: 321134
2017-12-20 01:17:45 +00:00
Sam Clegg bd0416d0c0 [WebAssemlby] Fix typo in target triple used in tests
llvm-svn: 321044
2017-12-19 00:18:16 +00:00
Sam Clegg 30b013bac8 [WebAssembly] Update YAML expected output after llvm change
See: https://reviews.llvm.org/D41202

Differential Revision: https://reviews.llvm.org/D41210

llvm-svn: 320662
2017-12-14 00:34:25 +00:00
Rui Ueyama 1ce416c635 Remove trailing whitespace.
llvm-svn: 320520
2017-12-12 20:00:30 +00:00
Sam Clegg f2356b3c05 [WebAssembly] Check more details in call-indirect test. NFC.
Also make function bodies unique so they can be distinguished
in the output.  This is helpful for adding support for --gc-sections.

Differential Revision: https://reviews.llvm.org/D41093

llvm-svn: 320441
2017-12-12 00:22:21 +00:00
Sam Clegg fc1a912b9b [WebAssembly] De-dup indirect function table.
Create the indirect function table based on symbols rather
than just duplicating the input entries.  This has the
effect of de-duplicating the table.

This is a followup to the equivalent change made for globals:
  https://reviews.llvm.org/D40859

Partially based on a patch by Nicholas Wilson:
  https://reviews.llvm.org/D40845

Differential Revision: https://reviews.llvm.org/D40989

llvm-svn: 320428
2017-12-11 22:00:56 +00:00
Sam Clegg 2e25e896fb [WebAssembly] Improve wasm test cases
Add test for weakly defined symbols with the same name

Improve test for call-indirect to include the same call in two
different objects. This lays the ground work to improve the
output via de-duplicating the indirect call table:
   https://reviews.llvm.org/D40989

Also make all tests consistently pass -mtriple rather than
declaring in the sources.

Differential Revision: https://reviews.llvm.org/D41024

llvm-svn: 320172
2017-12-08 18:37:44 +00:00
Sam Clegg 4b27c0554c Reland "[WebAssembly] Add support for visibility flag""
Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish

Differential Revision: https://reviews.llvm.org/D40773

llvm-svn: 319627
2017-12-03 02:38:04 +00:00
Heejin Ahn 675147b54d [WebAssembly] Revert r319592 "Add support for visibility flag"
r319488 reportedly broke one of LLVM bots (ubuntu-gcc7.1-werror), and this patch
depends on that patch.
See http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/3369 for
details.

llvm-svn: 319603
2017-12-02 02:05:50 +00:00
Sam Clegg e7487e4c92 [WebAssembly] Add support for visibility flag
Patch by Nicholas Wilson

Differential Revision: https://reviews.llvm.org/D40690

llvm-svn: 319592
2017-12-01 22:37:25 +00:00
Sam Clegg c94d393ad5 [WebAssembly] Initial wasm linker implementation
This linker backend is still a work in progress but is
enough to link simple programs including linking against
library archives.

Differential Revision: https://reviews.llvm.org/D34851

llvm-svn: 318539
2017-11-17 18:14:09 +00:00