[lld] r365443 - [ELF] Assert sizeof(SymbolUnion) <= 80

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 00:12:58 PDT 2019


Author: maskray
Date: Tue Jul  9 00:12:58 2019
New Revision: 365443

URL: http://llvm.org/viewvc/llvm-project?rev=365443&view=rev
Log:
[ELF] Assert sizeof(SymbolUnion) <= 80

Reviewed By: ruiu

Differential Revision: https://reviews.llvm.org/D64077

Modified:
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=365443&r1=365442&r2=365443&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Jul  9 00:12:58 2019
@@ -460,6 +460,11 @@ union SymbolUnion {
   alignas(LazyObject) char F[sizeof(LazyObject)];
 };
 
+// It is important to keep the size of SymbolUnion small for performance and
+// memory usage reasons. 80 bytes is a soft limit based on the size of Defined
+// on a 64-bit system.
+static_assert(sizeof(SymbolUnion) <= 80, "SymbolUnion too large");
+
 template <typename T> struct AssertSymbol {
   static_assert(std::is_trivially_destructible<T>(),
                 "Symbol types must be trivially destructible");




More information about the llvm-commits mailing list