https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/205040

>From afc371bbe15bf87b96ec434a6cb396262c746041 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <[email protected]>
Date: Sun, 21 Jun 2026 23:48:37 -0700
Subject: [PATCH 1/2] [clang] Exclude EmptyRecord calculating larger CXX
 records

Fixes: #203760

Assisted-by: Claude Sonnet 4.6
---
 clang/lib/CodeGen/Targets/X86.cpp         |  1 +
 clang/test/CodeGen/X86/avx-cxx-record.cpp | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index dbe4d656aabc5..abf903647336d 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -2085,6 +2085,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t 
OffsetBase, Class &Lo,
         Lo = merge(Lo, FieldLo);
         Hi = merge(Hi, FieldHi);
         if (returnCXXRecordGreaterThan128InMem() &&
+            !isEmptyRecord(getContext(), I.getType(), true) &&
             (Size > 128 && (Size != getContext().getTypeSize(I.getType()) ||
                             Size > getNativeVectorSizeForAVXABI(AVXLevel)))) {
           // The only case a 256(or 512)-bit wide vector could be used to 
return
diff --git a/clang/test/CodeGen/X86/avx-cxx-record.cpp 
b/clang/test/CodeGen/X86/avx-cxx-record.cpp
index b20bcdd616a43..e64cef32e78ec 100644
--- a/clang/test/CodeGen/X86/avx-cxx-record.cpp
+++ b/clang/test/CodeGen/X86/avx-cxx-record.cpp
@@ -46,3 +46,21 @@ YMM2 bar() {
   ((YMM1<1>*)&result)->x = UInt64x4{5, 6, 7, 8};
   return result;
 }
+
+// Test that empty base classes do not prevent structs with a single wide
+// vector member from being passed/returned in registers (issue #203760).
+struct EmptyBase {};
+
+struct YMMWithEmptyBase : EmptyBase {
+    UInt64x4 x;
+};
+
+// A struct with a single 256-bit vector and an empty base should use 
registers,
+// matching the behavior with no base class.
+// CHECK: define{{.*}} <4 x i64> @_Z18ymm_empty_base_retv()
+// CLANG-20: define{{.*}} <4 x i64> @_Z18ymm_empty_base_retv()
+YMMWithEmptyBase ymm_empty_base_ret() { return {}; }
+
+// CHECK: define{{.*}} i64 @_Z19ymm_empty_base_pass16YMMWithEmptyBase(<4 x i64>
+// CLANG-20: define{{.*}} i64 @_Z19ymm_empty_base_pass16YMMWithEmptyBase(<4 x 
i64>
+unsigned long long ymm_empty_base_pass(YMMWithEmptyBase x) { return x.x[0]; }

>From 414b822387911924397a1e1981f894a2cb278748 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <[email protected]>
Date: Mon, 22 Jun 2026 23:17:11 -0700
Subject: [PATCH 2/2] Add release note

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e7a0c76d4594..ea7d7908a5ff2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -113,6 +113,8 @@ ABI Changes in This Version
   compilers. On most targets this is not a breaking change because ``fastcc``
   and the platform C calling convention agree for ``void(ptr)``. It is an ABI
   break on i686, MIPS O32, PowerPC64 ELFv1, and Lanai.
+- Fixed incorrect struct return when single large vector (256/512-bit) used on
+  x86-64 targets. (#GH203760) The bug was introduced since Clang 21. 
(#GH120670)
 
 AST Dumping Potentially Breaking Changes
 ----------------------------------------

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to