This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Allow references to __tls_base without shared memory
ClosedPublic

Authored by sbc100 on Nov 9 2020, 8:04 PM.

Details

Summary

Previously we limited the use of atomics and TLS to programs
linked with --shared-memory.

However, as of https://reviews.llvm.org/D79530 we now allow
programs that use atomic to be linked without --shared-memory.
For this to be useful we also want to all TLS usage in such
programs. In this case, since we know we are single threaded
we simply include the TLS data as a regular active segment
and create an immutable __tls_base global that point to the
start of this segment.

Fixes: https://github.com/emscripten-core/emscripten/issues/12489

Diff Detail

Event Timeline

sbc100 created this revision.Nov 9 2020, 8:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2020, 8:04 PM
sbc100 requested review of this revision.Nov 9 2020, 8:04 PM
sbc100 updated this revision to Diff 304032.Nov 9 2020, 8:06 PM

cleanup

tlively added inline comments.Nov 10 2020, 11:39 AM
lld/wasm/Driver.cpp
657

It might be useful to say why we don't also need to define __tls_size and __tls_align in this case and also why __tls_base can be optional in this case but not in the shared case.

659–660

Not sure about the line wrapping here.

662

Is 0 the start of the static data region?

sbc100 updated this revision to Diff 304307.Nov 10 2020, 12:38 PM
sbc100 marked 3 inline comments as done.

feedback

lld/wasm/Driver.cpp
662

No, these globals are all set later on Writer.cpp .. this was just a zero-init. It was a little confusing though so I removed this final argument for all callers (since none of them have non-zero init that are useful).

tlively accepted this revision.Nov 10 2020, 1:47 PM
tlively added inline comments.
lld/wasm/SymbolTable.cpp
244–246
lld/wasm/SymbolTable.h
86
This revision is now accepted and ready to land.Nov 10 2020, 1:47 PM
This revision was landed with ongoing or failed builds.Nov 10 2020, 6:07 PM
This revision was automatically updated to reflect the committed changes.