[libcxx-commits] [PATCH] D102359: [libc++] [test] Fix a few tests for 32-bit x86

Harald van Dijk via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 12 12:51:01 PDT 2021


hvdijk created this revision.
hvdijk added a reviewer: mclow.lists.
hvdijk added a project: libc++.
Herald added a subscriber: pengfei.
hvdijk requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

- libcxx/gdb/gdb_pretty_printer_test.sh.cpp tests that vectors pretty-print correctly, but the exact output depends on the target: vector<bool> stores its bits in an array of __storage_type, which may be 32 bits.
- The unique_ptr_ret and weak_ptr_ret tests are not expected to pass on x86. These tests check that unique_ptr and weak_ptr are returned by value, but on x86, all structs are always returned by reference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102359

Files:
  libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
  libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
  libcxx/test/libcxx/memory/trivial_abi/weak_ptr_ret.pass.cpp


Index: libcxx/test/libcxx/memory/trivial_abi/weak_ptr_ret.pass.cpp
===================================================================
--- libcxx/test/libcxx/memory/trivial_abi/weak_ptr_ret.pass.cpp
+++ libcxx/test/libcxx/memory/trivial_abi/weak_ptr_ret.pass.cpp
@@ -51,9 +51,10 @@
   //
   // With trivial_abi, local_addr is the address of a local variable in
   // make_val, and hence different from &ret.
-#ifndef __arm__
+#if !defined(__i386__) && !defined(__arm__)
+  // On X86, structs are never returned in registers.
   // On ARM32, structs larger than 4 bytes cannot be returned in registers.
-  // Thus, weak_ptr will be passed indrectly even if it is trivial.
+  // Thus, weak_ptr will be passed indirectly even if it is trivial.
   assert((void*)&ret != local_addr);
 #endif
   return 0;
Index: libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
===================================================================
--- libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
+++ libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
@@ -48,7 +48,11 @@
   //
   // With trivial_abi, local_addr is the address of a local variable in
   // make_val, and hence different from &ret.
+#if !defined(__i386__)
+  // On X86, structs are never returned in registers.
+  // Thus, unique_ptr will be passed indirectly even if it is trivial.
   assert((void*)&ret != local_addr);
+#endif
 
   return 0;
 }
Index: libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
===================================================================
--- libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
+++ libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
@@ -427,9 +427,9 @@
 
 void vector_test() {
   std::vector<bool> test0 = {true, false};
-  ComparePrettyPrintToChars(test0,
+  ComparePrettyPrintToRegex(test0,
                             "std::vector<bool> of "
-                            "length 2, capacity 64 = {1, 0}");
+                            "length 2, capacity (32|64) = {1, 0}");
   for (int i = 0; i < 31; ++i) {
     test0.push_back(true);
     test0.push_back(false);
@@ -444,9 +444,9 @@
   ComparePrettyPrintToRegex(
       test0,
       "std::vector<bool> of length 65, "
-      "capacity 128 = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, "
-      "1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, "
-      "1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}");
+      "capacity (96|128) = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, "
+      "0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, "
+      "0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}");
 
   std::vector<int> test1;
   ComparePrettyPrintToChars(test1, "std::vector of length 0, capacity 0");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102359.344914.patch
Type: text/x-patch
Size: 2811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210512/108eed1e/attachment-0001.bin>


More information about the libcxx-commits mailing list