This is an archive of the discontinued LLVM Phabricator instance.

Add visibility flag to Wasm symbol flags
ClosedPublic

Authored by ncw on Nov 24 2017, 7:24 AM.

Details

Summary

The LLVM "hidden" flag needs to be passed through the Wasm intermediate objects in order for the linker to apply it to the final Wasm object.

The corresponding change in LLD is here: https://github.com/WebAssembly/lld/pull/14

Diff Detail

Repository
rL LLVM

Event Timeline

ncw created this revision.Nov 24 2017, 7:24 AM
ncw edited the summary of this revision. (Show Details)Nov 24 2017, 7:26 AM
sbc100 edited edge metadata.Nov 27 2017, 11:10 AM

lgtm with comments.

And can you add a test in test/MC/WebAssembly?

include/llvm/BinaryFormat/Wasm.h
201 ↗(On Diff #124208)

Why not make this 0 and 1?

lib/MC/MCWasmStreamer.cpp
103 ↗(On Diff #124208)

Wont all the above cases fall through to this too?

ncw updated this revision to Diff 124563.Nov 28 2017, 6:14 AM
  • Added missing "return" to switch
  • Added test to tests/MC/WebAssembly
ncw added inline comments.Nov 28 2017, 6:14 AM
include/llvm/BinaryFormat/Wasm.h
201 ↗(On Diff #124208)

(Thanks for the review.)

It's 0x4 because the flags are ORed together when writing out into the "linking" custom section. That's similar to ELF, where all the different per-symbol flags are ORed together. (I would have split these into a separate enum if they were independent of the other values.)

lib/MC/MCWasmStreamer.cpp
103 ↗(On Diff #124208)

D'oh, truly terrible typo, sorry - I added the blank line but not the break.

sbc100 accepted this revision.Nov 28 2017, 9:43 AM

lgtm, with a minor change

lib/MC/MCWasmStreamer.cpp
103 ↗(On Diff #124208)

Can you move this down so that all the "return false" cases are still in a single block?

This revision is now accepted and ready to land.Nov 28 2017, 9:43 AM

Please also document the wasm binary encoding for visibilities in Linking.md.

ncw updated this revision to Diff 124601.Nov 28 2017, 10:13 AM

Updated with Sam's requested re-ordering of the switch labels.

still lgtm.

Do you have llvm commit access to land this yourself?

ncw added a comment.Nov 30 2017, 12:59 AM

No, I don't - I've never been that involved!

This revision was automatically updated to reflect the committed changes.