[llvm] DynamicAPInt: optimize size of structure (PR #97831)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 6 03:31:24 PDT 2024


================
@@ -203,6 +211,14 @@ class DynamicAPInt {
 
   friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
 
+  void static_assert_layout() { // NOLINT
+    constexpr size_t ValLargeOff =
+        offsetof(DynamicAPInt, ValLarge.Val.BitWidth);
+    constexpr size_t ValSmallOff = offsetof(DynamicAPInt, ValSmall);
+    constexpr size_t ValSmallSz = sizeof(ValSmall);
+    static_assert(ValLargeOff >= ValSmallOff + ValSmallSz);
+  }
+
----------------
artagnon wrote:

It can't, because we're accessing private members.

https://github.com/llvm/llvm-project/pull/97831


More information about the llvm-commits mailing list