[PATCH] D64238: [WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 00:31:42 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365296: [WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96) (authored by MaskRay, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64238/new/

https://reviews.llvm.org/D64238

Files:
  lld/trunk/wasm/Symbols.h


Index: lld/trunk/wasm/Symbols.h
===================================================================
--- lld/trunk/wasm/Symbols.h
+++ lld/trunk/wasm/Symbols.h
@@ -131,26 +131,26 @@
   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 @@
   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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64238.208326.patch
Type: text/x-patch
Size: 1743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190708/e1f7afcb/attachment.bin>


More information about the llvm-commits mailing list