[llvm] DynamicAPInt: optimize size of structure (PR #97831)
Arjun P via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 10:51:37 PDT 2024
================
@@ -35,21 +35,20 @@ namespace llvm {
/// We always_inline all operations; removing these results in a 1.5x
/// performance slowdown.
///
-/// When HoldsLarge is true, a SlowMPInt is held in the union. If it is false,
-/// the int64_t is held. Using std::variant instead would lead to significantly
-/// worse performance.
+/// When isLarge returns true, a SlowMPInt is held in the union. If isSmall
+/// returns true, the int64_t is held. Using std::variant instead would lead to
+/// significantly worse performance.
----------------
Superty wrote:
This is a reasonably "clever" thing so can you please add a line of documentation noting that we are "stealing" the memory from the ValLarge when it is not in use because we know that the memory layout of APInt is such that it doesn't overlap with our date in ValSmall? Also, can you add some test to assert that this continues to be the case so that the reason for failure is obvious in case of changes (you can use `offsetof`, if it's constexpr you can maybe even make it a static_assert)
https://github.com/llvm/llvm-project/pull/97831
More information about the llvm-commits
mailing list