Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

@llvmbot
Copy link
Member

llvmbot commented Jun 3, 2025

@llvm/pr-subscribers-lldb

Author: A. Jiang (frederick-vs-ja)

Changes

This PR mirrors changes of __compressed_pair_padding in libc++ into lldb test suite.

Related PR for libc++:

  • #108956
  • #109028
  • #142125

Full diff: https://github.com/llvm/llvm-project/pull/142516.diff

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h (+16-6)
diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index 6dc53a4e88ffd..3f305bdcb4d54 100644
--- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -72,14 +72,24 @@ inline const size_t __datasizeof_v =
 template <class _Tp>
 struct __lldb_is_final : public integral_constant<bool, __is_final(_Tp)> {};
 
-template <class _ToPad> class __compressed_pair_padding {
-  char __padding_[((is_empty<_ToPad>::value &&
-                    !__lldb_is_final<_ToPad>::value) ||
-                   is_reference<_ToPad>::value)
-                      ? 0
-                      : sizeof(_ToPad) - __datasizeof_v<_ToPad>];
+template <class _ToPad>
+inline const bool __is_reference_or_unpadded_object =
+    (std::is_empty<_ToPad>::value && !__lldb_is_final<_ToPad>::value) ||
+    sizeof(_ToPad) == __datasizeof_v<_ToPad>;
+
+template <class _Tp>
+inline const bool __is_reference_or_unpadded_object<_Tp &> = true;
+
+template <class _Tp>
+inline const bool __is_reference_or_unpadded_object<_Tp &&> = true;
+
+template <class _ToPad, bool _Empty = __is_reference_or_unpadded_object<_ToPad>>
+class __compressed_pair_padding {
+  char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
 };
 
+template <class _ToPad> class __compressed_pair_padding<_ToPad, true> {};
+
 #define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2)              \
   [[__gnu__::__aligned__(                                                      \
       alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1;                  \

};

template <class _ToPad> class __compressed_pair_padding<_ToPad, true> {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this in sync! What we would usually do with these simulators is to add the new implementation behind a ifdef COMPRESSED_PAIR_REV == <new version>. To make sure we don't regress users still on the older layout. Do you mind doing that? If it's too finicky I'm happy to give it a shot

Copy link
Contributor Author

@frederick-vs-ja frederick-vs-ja Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late replying. I'll do this soon I've done this, although this seems unnecessary as there doesn't seem any case where the layout will change.

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adjusting! I know it's quite gnarly with all these ifdefs

@frederick-vs-ja frederick-vs-ja merged commit 119705e into llvm:main Jul 3, 2025
7 checks passed
@frederick-vs-ja frederick-vs-ja deleted the lldb-test-sync-compressed-pair branch July 3, 2025 05:57
Michael137 pushed a commit to swiftlang/llvm-project that referenced this pull request Aug 26, 2025
…m#142516)

This PR mirrors changes of `__compressed_pair_padding` in libc++ into
lldb test suite.

Related PR for libc++:
- llvm#108956
- llvm#109028
- llvm#142125

(cherry picked from commit 119705e)
Michael137 pushed a commit to swiftlang/llvm-project that referenced this pull request Aug 26, 2025
…m#142516)

This PR mirrors changes of `__compressed_pair_padding` in libc++ into
lldb test suite.

Related PR for libc++:
- llvm#108956
- llvm#109028
- llvm#142125

(cherry picked from commit 119705e)
(cherry picked from commit 205591b)
Michael137 pushed a commit to swiftlang/llvm-project that referenced this pull request Aug 26, 2025
…m#142516)

This PR mirrors changes of `__compressed_pair_padding` in libc++ into
lldb test suite.

Related PR for libc++:
- llvm#108956
- llvm#109028
- llvm#142125

(cherry picked from commit 119705e)
(cherry picked from commit 205591b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants