This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Test the size of basic_string
ClosedPublic

Authored by philnik on Jun 13 2022, 10:32 AM.

Diff Detail

Event Timeline

philnik created this revision.Jun 13 2022, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 10:32 AM
philnik requested review of this revision.Jun 13 2022, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 10:32 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jun 13 2022, 1:51 PM

LGTM but I'd like to add a test for alignment too, since that would be so easy.

libcxx/test/libcxx/strings/basic.string/string_abi.compile.pass.cpp
9 ↗(On Diff #436468)

While we're at it, I think it would be trivial to add a test for the alignment. WDYT?

18 ↗(On Diff #436468)

Space between > > here and below should help pass in C++03.

25 ↗(On Diff #436468)

You need a dummy , ""); message in your static_assert for C++11.

This revision is now accepted and ready to land.Jun 13 2022, 1:51 PM
philnik updated this revision to Diff 436657.Jun 13 2022, 10:48 PM
philnik marked 3 inline comments as done.
  • Address comments
libcxx/test/libcxx/strings/basic.string/string_abi.compile.pass.cpp
9 ↗(On Diff #436468)

Sounds like a good idea.

philnik updated this revision to Diff 436767.Jun 14 2022, 6:35 AM
  • Try to fix CI
philnik updated this revision to Diff 436797.Jun 14 2022, 8:21 AM
  • Next try
philnik updated this revision to Diff 436798.Jun 14 2022, 8:29 AM

Only update the .clang-format

philnik updated this revision to Diff 436800.Jun 14 2022, 8:30 AM

Upload the correct diff

philnik updated this revision to Diff 437318.Jun 15 2022, 1:28 PM
  • Another try
This revision was landed with ongoing or failed builds.Jun 16 2022, 1:43 AM
This revision was automatically updated to reflect the committed changes.
philnik reopened this revision.Jun 16 2022, 9:02 AM
This revision is now accepted and ready to land.Jun 16 2022, 9:02 AM
philnik updated this revision to Diff 437568.Jun 16 2022, 9:10 AM
  • Try to find out what the correct values are on AIX
hubert.reinterpretcast added inline comments.
libcxx/test/libcxx/strings/basic.string/sizeof.compile.pass.cpp
60

At least historically, the value is 12.

libcxx/test/libcxx/strings/basic.string/sizeof.compile.pass.cpp
58
libcxx/test/libcxx/strings/basic.string/alignof.compile.pass.cpp
100

This used to pass on AIX, but changes to use bitfields (without applying _LIBCPP_PACKED_BYTE_FOR_AIX) has broken this.

112

Same comment as above.

libcxx/test/libcxx/strings/basic.string/sizeof.compile.pass.cpp
110

This used to pass on AIX, but changes to use bitfields (without applying _LIBCPP_PACKED_BYTE_FOR_AIX) has broken this.

122

Same comment as above.

142

Same comment as above.

libcxx/test/libcxx/strings/basic.string/alignof.compile.pass.cpp
100

However, using the above also causes other members to be less aligned if padding is not explicitly added.

libcxx/test/libcxx/strings/basic.string/alignof.compile.pass.cpp
100

Or rather it causes the string type to be less aligned.

libcxx/test/libcxx/strings/basic.string/alignof.compile.pass.cpp
100
--- string_20220520     2022-05-20 11:48:54.326820970 -0400
+++ string      2022-06-16 19:30:22.238194020 -0400
@@ -724,3 +724,4 @@

-    struct __long
+_LIBCPP_PACKED_BYTE_FOR_AIX
+    struct __long_impl
     {
@@ -729,2 +730,6 @@
         size_type __size_;
+        char
+            __padding_[sizeof(pointer) *
+                           ((2 * sizeof(size_type) - 1) / sizeof(pointer) + 1) -
+                       2 * sizeof(size_type)];
         pointer   __data_;
@@ -731,2 +736,4 @@
     };
+_LIBCPP_PACKED_BYTE_FOR_AIX_END
+    struct alignas(size_type) alignas(pointer) __long : __long_impl {};

@@ -735,3 +742,4 @@

-    struct __short
+_LIBCPP_PACKED_BYTE_FOR_AIX
+    struct __short_impl
     {
@@ -742,2 +750,4 @@
     };
+_LIBCPP_PACKED_BYTE_FOR_AIX_END
+    struct alignas(value_type) __short : __short_impl {};
philnik updated this revision to Diff 439926.Jun 24 2022, 4:42 PM

Change back to the old diff. D128285 fixed the basic_string layout, so the test should pass now.

@hubert.reinterpretcast Do you know what the correct values for AIX are? If that's the case, could you tell me? Or how about I land this with XFAIL: AIX any you fix it in a follow-up patch?

@hubert.reinterpretcast Do you know what the correct values for AIX are? If that's the case, could you tell me? Or how about I land this with XFAIL: AIX any you fix it in a follow-up patch?

As far as I can tell, the values are correct. I will need to see if the failures show up when using the LIT harness.

As far as I can tell, the values are correct. I will need to see if the failures show up when using the LIT harness.

These pass for me with the LIT harness. Perhaps the precommit CI does make use of the "Parents" metadata?
The metadata shows that your patch is a commit on top of rGaf41955a49725c8ddc69d94b1874bbbbd608729e.
Xing's fix in rG60f7bdfd0317cb38eda54637cdab9baed8ae2f57 occurs after that.

My guess is that the CI will pass if you rebase.

As far as I can tell, the values are correct. I will need to see if the failures show up when using the LIT harness.

These pass for me with the LIT harness. Perhaps the precommit CI does make use of the "Parents" metadata?
The metadata shows that your patch is a commit on top of rGaf41955a49725c8ddc69d94b1874bbbbd608729e.
Xing's fix in rG60f7bdfd0317cb38eda54637cdab9baed8ae2f57 occurs after that.

My guess is that the CI will pass if you rebase.

Thanks! I thought I had already rebased, but apparently not.

This revision was automatically updated to reflect the committed changes.