This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Preserve ordering of global symbols
ClosedPublic

Authored by sbc100 on Dec 8 2017, 3:21 PM.

Details

Summary

This change restores the behaviour that global indexes
are assigned in object file order. This was accidentally
changed in https://reviews.llvm.org/D40859.

Diff Detail

Repository
rL LLVM

Event Timeline

sbc100 created this revision.Dec 8 2017, 3:21 PM
ncw accepted this revision.Dec 10 2017, 11:10 PM

Looks good. Is the ordering mainly for the stability of the test output, or is it expected to have a tiny improvement to code locality at runtime?

There might be a couple of other places where we could do the same change. For example calculateImports has exactly the same iteration pattern, where the imports are ordered according to the first-importing file, rather than ordered by the file that actually uses the import. Harder to see how to fix that one though. I wouldn't have thought it's worth trying.

This revision is now accepted and ready to land.Dec 10 2017, 11:10 PM
ruiu accepted this revision.Dec 11 2017, 8:53 AM

LGTM

wasm/Writer.cpp
617–618 ↗(On Diff #126224)

Could you invert the boolean expression so that we can still do early continue (to keep the indentation shallower)?

In D41038#950727, @ncw wrote:

Looks good. Is the ordering mainly for the stability of the test output, or is it expected to have a tiny improvement to code locality at runtime?

There might be a couple of other places where we could do the same change. For example calculateImports has exactly the same iteration pattern, where the imports are ordered according to the first-importing file, rather than ordered by the file that actually uses the import. Harder to see how to fix that one though. I wouldn't have thought it's worth trying.

I think an aesthetic things. It makes sense for function and global definitions to appear in declaration order.

For import, I think it makes sense for them to appear in the order of the first object the contains the import. I can't imagine a object that imports something but doesn't use it.. at least clang shouldn't produce such a thing.

wasm/Writer.cpp
617–618 ↗(On Diff #126224)

I personally found it more readable this way around. But sure, will change it back

sbc100 updated this revision to Diff 126440.Dec 11 2017, 1:51 PM
  • feedback
This revision was automatically updated to reflect the committed changes.