This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Reorder Symbol fields to make it smaller
ClosedPublic

Authored by MaskRay on Jul 4 2019, 7:52 AM.

Event Timeline

MaskRay created this revision.Jul 4 2019, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2019, 7:52 AM
sbc100 accepted this revision.Jul 4 2019, 10:45 AM

Nice! I wonder if its worth adding some kind of static assert or unittest to avoid accidental increases in future? Either way lgtm.

This revision is now accepted and ready to land.Jul 4 2019, 10:45 AM
MaskRay updated this revision to Diff 208103.Jul 4 2019, 6:24 PM

Add a size assert

This revision was automatically updated to reflect the committed changes.
MaskRay added a comment.EditedJul 4 2019, 7:16 PM

static_assert(sizeof(SymbolUnion) <= 96, "SymbolUnion too large");

c:\b\slave\sanitizer-windows\build\llvm.src\tools\lld\wasm\Symbols.h(481): error C2338: SymbolUnion too large

*NIX systems place bitfields at the next available unit where the entire bitfield would fit in an aligned storage unit of the declared type;

UndefinedFunction  ;;;; sizeof(UndefinedFunction) = 96
└⏷56 llvm::StringRef ImportName
└⏷72 llvm::StringRef ImportModule
├╸88 bool IsCalledDirectly
├╸48 uint32_t TableIndex
├╸52 uint32_t FunctionIndex
└⏷ 0 llvm::StringRef Name
└⏷16 lld::wasm::InputFile *File
├╸24 uint32_t Flags
├╸28 uint32_t OutputSymbolIndex
├╸32 uint32_t GOTIndex
├╸36 lld::wasm::Symbol::Kind SymbolKind
├╸37 unsigned int Referenced                    ;;;;;;;; on Windows, 40
├╸37.1 unsigned int IsUsedInRegularObj
├╸37.2 unsigned int ForceExport
├╸37.3 unsigned int CanInline
└╸37.4 unsigned int Traced

On Windows, bit fields are placed differently, sizeof(UndefinedFunction) = 104.