Skip to content

Commit 552ca63

Browse files
philnik777mahesh-attarde
authored andcommitted
[libc++] Remove alignment attributes from _LIBCPP_COMPRESSED_PAIR (llvm#158595)
These attributes aren't required anymore, since the potential overalignemnt of the objects is handled by the surrounding anonymous struct.
1 parent 78bd0ed commit 552ca63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libcxx/include/__memory/compressed_pair.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
// understand how it works). //
2929
// ================================================================================================================== //
3030

31-
// The first member is aligned to the alignment of the second member to force padding in front of the compressed pair
32-
// in case there are members before it.
31+
// On GCC, the first member is aligned to the alignment of the second member to force padding in front of the compressed
32+
// pair in case there are members before it.
3333
//
3434
// For example:
3535
// (assuming x86-64 linux)
@@ -53,6 +53,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5353
// Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must
5454
// handle reference types specially since alignof(T&) == alignof(T).
5555
// See https://llvm.org/PR118559.
56+
//
57+
// On Clang, this is unnecessary, since we use anonymous structs instead, which automatically handle the alignment
58+
// correctly.
5659

5760
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
5861

@@ -104,18 +107,15 @@ class __compressed_pair_padding<_ToPad, true> {};
104107
# else
105108
# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
106109
struct { \
107-
_LIBCPP_NO_UNIQUE_ADDRESS \
108-
__attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \
110+
_LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \
109111
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
110112
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
111113
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
112114
}
113115

114116
# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
115117
struct { \
116-
_LIBCPP_NO_UNIQUE_ADDRESS \
117-
__attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \
118-
__aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
118+
_LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \
119119
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
120120
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
121121
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \

0 commit comments

Comments
 (0)