[llvm] DynamicAPInt: optimize size of structure (PR #97831)
Arjun P via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 6 03:24:43 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);
+ }
+
----------------
Superty wrote:
Nice, glad to see this could be made a `static_assert`.
Keeping this in the class body clutters it and is unnecessary; moreover, there is no need to compile this every time the header is included. I suggest moving it to the `.cpp` file.
https://github.com/llvm/llvm-project/pull/97831
More information about the llvm-commits
mailing list