This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Sort output data sections to place .bss last
ClosedPublic

Authored by tlively on Sep 18 2019, 3:29 PM.

Details

Summary

This was always the intended behavior, but had not been
implemented. This ordering is important for Emscripten when generating
.mem files while compiling to JS, since only zeros at the end of
initialized memory can be dropped.

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

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Sep 18 2019, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2019, 3:29 PM

Nice!

lld/wasm/Writer.cpp
690 ↗(On Diff #220761)

Its possible to have custom segment names. See Writer.cpp:getOutputDataSegmentName. Seems strange that no tests use this feature though .. maybe I'm misunderstanding something?

Perhaps just create a partial order that puts bss last?

695 ↗(On Diff #220761)

Drop the curlies for single line blocks

tlively updated this revision to Diff 220779.Sep 18 2019, 5:40 PM
  • Add test for custom section names and change sorting to handle them
sbc100 accepted this revision.Sep 18 2019, 5:58 PM
sbc100 added inline comments.
lld/wasm/Writer.cpp
690 ↗(On Diff #220761)

It it worth sorting things other than bss? Don't make much difference I suppose.

This revision is now accepted and ready to land.Sep 18 2019, 5:58 PM
tlively marked an inline comment as done.Sep 18 2019, 6:05 PM
tlively added inline comments.
lld/wasm/Writer.cpp
690 ↗(On Diff #220761)

Eh, probably not, but changing all the tests was a pain and I don't want to do it again :) Perhaps someone will find it useful to have similar sections together some day.

This revision was automatically updated to reflect the committed changes.