Skip to content

Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" #111123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Michael137
Copy link
Member

Relands #108375 which had to be reverted because it was failing on the Windows buildbot. Trying to reland this with msvc::no_unique_address on Windows.

@Michael137 Michael137 force-pushed the bugfix/lldb-reland-string-simulator-padding branch from c7278dd to 453d331 Compare October 4, 2024 11:09
@Michael137 Michael137 requested a review from labath October 4, 2024 11:09
@Michael137
Copy link
Member Author

Didn't manage to build LLDB on my Windows machine (and AFAICT we don't have Windows PR testing). So hoping this will fix it.

@Michael137 Michael137 marked this pull request as ready for review October 4, 2024 11:10
@Michael137 Michael137 changed the title [WIP] Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" Oct 4, 2024
@llvmbot llvmbot added the lldb label Oct 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 4, 2024

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

Relands #108375 which had to be reverted because it was failing on the Windows buildbot. Trying to reland this with msvc::no_unique_address on Windows.


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

3 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h (+23-16)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py (+1-1)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp (+28-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 89eafcec0ea962..6dc53a4e88ffdd 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
@@ -7,6 +7,12 @@
 namespace std {
 namespace __lldb {
 
+#if __has_cpp_attribute(msvc::no_unique_address)
+#define _LLDB_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#elif __has_cpp_attribute(no_unique_address)
+#define _LLDB_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
+#endif
+
 #if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout
 struct __value_init_tag {};
 struct __default_init_tag {};
@@ -55,7 +61,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
 #elif COMPRESSED_PAIR_REV == 1
 // From libc++ datasizeof.h
 template <class _Tp> struct _FirstPaddingByte {
-  [[no_unique_address]] _Tp __v_;
+  _LLDB_NO_UNIQUE_ADDRESS _Tp __v_;
   char __first_padding_byte_;
 };
 
@@ -75,29 +81,30 @@ template <class _ToPad> class __compressed_pair_padding {
 };
 
 #define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2)              \
-  [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \
-  [[no_unique_address]] __compressed_pair_padding<T1> __padding1_;             \
-  [[no_unique_address]] T2 Initializer2;                                       \
-  [[no_unique_address]] __compressed_pair_padding<T2> __padding2_;
+  [[__gnu__::__aligned__(                                                      \
+      alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1;                  \
+  _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_;           \
+  _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2;                                     \
+  _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_;
 
 #define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3,        \
                                 Initializer3)                                  \
   [[using __gnu__: __aligned__(alignof(T2)),                                   \
-    __aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1;          \
-  [[no_unique_address]] __compressed_pair_padding<T1> __padding1_;             \
-  [[no_unique_address]] T2 Initializer2;                                       \
-  [[no_unique_address]] __compressed_pair_padding<T2> __padding2_;             \
-  [[no_unique_address]] T3 Initializer3;                                       \
-  [[no_unique_address]] __compressed_pair_padding<T3> __padding3_;
+    __aligned__(alignof(T3))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1;        \
+  _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_;           \
+  _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2;                                     \
+  _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_;           \
+  _LLDB_NO_UNIQUE_ADDRESS T3 Initializer3;                                     \
+  _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T3> __padding3_;
 #elif COMPRESSED_PAIR_REV == 2
 #define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2)                            \
-  [[no_unique_address]] T1 Name1;                                              \
-  [[no_unique_address]] T2 Name2
+  _LLDB_NO_UNIQUE_ADDRESS T1 Name1;                                            \
+  _LLDB_NO_UNIQUE_ADDRESS T2 Name2
 
 #define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3)               \
-  [[no_unique_address]] T1 Name1;                                              \
-  [[no_unique_address]] T2 Name2;                                              \
-  [[no_unique_address]] T3 Name3
+  _LLDB_NO_UNIQUE_ADDRESS T1 Name1;                                            \
+  _LLDB_NO_UNIQUE_ADDRESS T2 Name2;                                            \
+  _LLDB_NO_UNIQUE_ADDRESS T3 Name3
 #endif
 } // namespace __lldb
 } // namespace std
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
index afe6374e55a355..fff181440b6d7c 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
@@ -27,7 +27,7 @@ def _run_test(self, defines):
 
 
 for v in [None, "ALTERNATE_LAYOUT"]:
-    for r in range(5):
+    for r in range(6):
         for c in range(3):
             name = "test_r%d_c%d" % (r, c)
             defines = ["REVISION=%d" % r, "COMPRESSED_PAIR_REV=%d" % c]
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
index f8fc13c10c4372..fdf8d53a341384 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/main.cpp
@@ -20,7 +20,11 @@
 // Pre-D128285 layout.
 #define PACKED_ANON_STRUCT
 #endif
-// REVISION == 4: current layout
+#if REVISION <= 4
+// Pre-2a1ef74 layout.
+#define NON_STANDARD_PADDING
+#endif
+// REVISION == 5: current layout
 
 #ifdef PACKED_ANON_STRUCT
 #define BEGIN_PACKED_ANON_STRUCT struct __attribute__((packed)) {
@@ -34,6 +38,7 @@
 namespace std {
 namespace __lldb {
 
+#ifdef NON_STANDARD_PADDING
 #if defined(ALTERNATE_LAYOUT) && defined(SUBCLASS_PADDING)
 template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
   unsigned char __xx[sizeof(_CharT) - 1];
@@ -41,6 +46,13 @@ template <class _CharT, size_t = sizeof(_CharT)> struct __padding {
 
 template <class _CharT> struct __padding<_CharT, 1> {};
 #endif
+#else // !NON_STANDARD_PADDING
+template <size_t _PaddingSize> struct __padding {
+  char __padding_[_PaddingSize];
+};
+
+template <> struct __padding<0> {};
+#endif
 
 template <class _CharT, class _Traits, class _Allocator> class basic_string {
 public:
@@ -77,7 +89,12 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
     };
 #else // !SUBCLASS_PADDING
 
+#ifdef NON_STANDARD_PADDING
     unsigned char __padding[sizeof(value_type) - 1];
+#else
+    _LLDB_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
+#endif
+
 #ifdef BITMASKS
     unsigned char __size_;
 #else // !BITMASKS
@@ -129,21 +146,26 @@ template <class _CharT, class _Traits, class _Allocator> class basic_string {
     union {
 #ifdef BITMASKS
       unsigned char __size_;
-#else
+#else  // !BITMASKS
       struct {
         unsigned char __is_long_ : 1;
         unsigned char __size_ : 7;
       };
-#endif
+#endif // BITMASKS
       value_type __lx;
     };
-#else
+#else  // !SHORT_UNION
     BEGIN_PACKED_ANON_STRUCT
     unsigned char __is_long_ : 1;
     unsigned char __size_ : 7;
     END_PACKED_ANON_STRUCT
-    char __padding_[sizeof(value_type) - 1];
-#endif
+#ifdef NON_STANDARD_PADDING
+    unsigned char __padding[sizeof(value_type) - 1];
+#else  // !NON_STANDARD_PADDING
+    _LLDB_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
+#endif // NON_STANDARD_PADDING
+
+#endif // SHORT_UNION
     value_type __data_[__min_cap];
   };
 

@Michael137 Michael137 merged commit d148548 into llvm:main Oct 7, 2024
11 checks passed
@Michael137 Michael137 deleted the bugfix/lldb-reland-string-simulator-padding branch October 7, 2024 09:59
Kyvangka1610 added a commit to Kyvangka1610/llvm-project that referenced this pull request Oct 7, 2024
* commit 'FETCH_HEAD':
  [X86] getIntImmCostInst - pull out repeated Imm.getBitWidth() calls. NFC.
  [X86] Add test coverage for llvm#111323
  [Driver] Use empty multilib file in another test (llvm#111352)
  [clang][OpenMP][test] Use x86_64-linux-gnu triple for test referencing avx512f feature (llvm#111337)
  [doc] Fix Kaleidoscope tutorial chapter 3 code snippet and full listing discrepancies (llvm#111289)
  [Flang][OpenMP] Improve entry block argument creation and binding (llvm#110267)
  [x86] combineMul - handle 0/-1 KnownBits cases before MUL_IMM logic (REAPPLIED)
  [llvm-dis] Fix non-deterministic disassembly across multiple inputs (llvm#110988)
  [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: change order of ifdefs
  [lldb][test] Add libcxx-simulators test for std::optional (llvm#111133)
  [x86] combineMul - use computeKnownBits directly to find MUL_IMM constant splat. (REAPPLIED)
  Reland "[lldb][test] TestDataFormatterLibcxxStringSimulator.py: add new padding layout" (llvm#111123)
  Revert "[x86] combineMul - use computeKnownBits directly to find MUL_IMM constant splat."
  update_test_checks: fix a simple regression  (llvm#111347)
  [LegalizeVectorTypes] Always widen fabs (llvm#111298)
  [lsan] Make ReportUnsuspendedThreads return bool also for Fuchsia
  [mlir][vector] Add more tests for ConvertVectorToLLVM (6/n) (llvm#111121)
  [bazel] port 9144fed
  [SystemZ] Remove inlining threshold multiplier. (llvm#106058)
  [LegalizeVectorTypes] When widening don't check for libcalls if promoted (llvm#111297)
  [clang][Driver] Improve multilib custom error reporting (llvm#110804)
  [clang][Driver] Rename "FatalError" key to "Error" in multilib.yaml (llvm#110804)
  [LLVM][Maintainers] Update release managers (llvm#111164)
  [Clang][Driver] Add option to provide path for multilib's YAML config file (llvm#109640)
  [LoopVectorize] Remove redundant code in emitSCEVChecks (llvm#111132)
  [AMDGPU] Only emit SCOPE_SYS global_wb (llvm#110636)
  [ELF] Change Ctx::target to unique_ptr (llvm#111260)
  [ELF] Pass Ctx & to some free functions
  [RISCV] Only disassemble fcvtmod.w.d if the rounding mode is rtz. (llvm#111308)
  [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d76 (llvm#111277)
  [ELF] Pass Ctx & to InputFile
  [clang-format] Add AlignFunctionDeclarations to AlignConsecutiveDeclarations (llvm#108241)
  [AMDGPU] Support preloading hidden kernel arguments (llvm#98861)
  [ELF] Move static nextGroupId isInGroup to LinkerDriver
  [clangd] Add ArgumentLists config option under Completion (llvm#111322)
  [ELF] Pass Ctx & to SyntheticSections
  [ELF] Pass Ctx & to Symbols
  [ELF] Pass Ctx & to Symbols
  [ELF] getRelocTargetVA: pass Ctx and Relocation. NFC
  [clang-tidy] Avoid capturing a local variable in a static lambda in UseRangesCheck (llvm#111282)
  [VPlan] Use pointer to member 0 as VPInterleaveRecipe's pointer arg. (llvm#106431)
  [clangd] Simplify ternary expressions with std::optional::value_or (NFC) (llvm#111309)
  [libc++][format][2/3] Optimizes c-string arguments. (llvm#101805)
  [RISCV] Combine RVBUnary and RVKUnary into classes that are more similar to ALU(W)_r(r/i). NFC (llvm#111279)
  [ELF] Pass Ctx & to InputFiles
  [libc] GPU RPC interface: add return value to `rpc_host_call` (llvm#111288)

Signed-off-by: kyvangka1610 <[email protected]>
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request Apr 17, 2025
…ew padding layout" (llvm#111123)

Relands llvm#108375 which had to be
reverted because it was failing on the Windows buildbot. Trying to
reland this with `msvc::no_unique_address` on Windows.

(cherry picked from commit d148548)
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request Apr 17, 2025
…ew padding layout" (llvm#111123)

Relands llvm#108375 which had to be
reverted because it was failing on the Windows buildbot. Trying to
reland this with `msvc::no_unique_address` on Windows.

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

Successfully merging this pull request may close these issues.

3 participants