summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-07-08 07:30:07 +0000
committerFangrui Song <maskray@google.com>2019-07-08 07:30:07 +0000
commit34958d12c9cae91f41f5ef5369a21746218b4519 (patch)
treebde7afed33d1005c82026a9c95a98e779a0c403c
parent23d10f7a4edde835a7cd26679ffb46ba3759df73 (diff)
downloadbcm5719-llvm-34958d12c9cae91f41f5ef5369a21746218b4519.tar.gz
bcm5719-llvm-34958d12c9cae91f41f5ef5369a21746218b4519.zip
[WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96)
On Windows, the bitfield layout rule places `ussigned Referenced : 1` at byte offset 40, instead of byte offset 37 on *NIX. The consequence is that sizeof(SymbolUnion) == 104 on Windows while 96 on *NIX. To eliminate this difference, change these unsigned bitfields to bool. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64238 llvm-svn: 365296
-rw-r--r--lld/wasm/Symbols.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h
index cb3c73e103a..128ea9348a8 100644
--- a/lld/wasm/Symbols.h
+++ b/lld/wasm/Symbols.h
@@ -131,26 +131,26 @@ protected:
uint32_t OutputSymbolIndex = INVALID_INDEX;
uint32_t GOTIndex = INVALID_INDEX;
Kind SymbolKind;
- unsigned Referenced : 1;
+ bool Referenced : 1;
public:
// True if the symbol was used for linking and thus need to be added to the
// output file's symbol table. This is true for all symbols except for
// unreferenced DSO symbols, lazy (archive) symbols, and bitcode symbols that
// are unreferenced except by other bitcode objects.
- unsigned IsUsedInRegularObj : 1;
+ bool IsUsedInRegularObj : 1;
// True if ths symbol is explicity marked for export (i.e. via the -e/--export
// command line flag)
- unsigned ForceExport : 1;
+ bool ForceExport : 1;
// False if LTO shouldn't inline whatever this symbol points to. If a symbol
// is overwritten after LTO, LTO shouldn't inline the symbol because it
// doesn't know the final contents of the symbol.
- unsigned CanInline : 1;
+ bool CanInline : 1;
// True if this symbol is specified by --trace-symbol option.
- unsigned Traced : 1;
+ bool Traced : 1;
};
class FunctionSymbol : public Symbol {
@@ -475,6 +475,11 @@ union SymbolUnion {
alignas(SectionSymbol) char I[sizeof(SectionSymbol)];
};
+// It is important to keep the size of SymbolUnion small for performance and
+// memory usage reasons. 96 bytes is a soft limit based on the size of
+// UndefinedFunction on a 64-bit system.
+static_assert(sizeof(SymbolUnion) <= 96, "SymbolUnion too large");
+
void printTraceSymbol(Symbol *Sym);
void printTraceSymbolUndefined(StringRef Name, const InputFile* File);
OpenPOWER on IntegriCloud