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

>From 844fb5283d654d7d9cb68c5712b338f0a70b384e Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.w...@intel.com>
Date: Sat, 11 May 2024 16:07:00 +0800
Subject: [PATCH 1/2] [X86][vectorcall] Pass built types byval when xmm0~6
 exhausted

This is how MSVC handles it. https://godbolt.org/z/fG386bjnf
---
 clang/lib/CodeGen/Targets/X86.cpp |  2 +-
 clang/test/CodeGen/vectorcall.c   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 717a27fc9c574..5c09339bd7137 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -792,7 +792,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState &State,
         return ABIArgInfo::getDirect();
       return ABIArgInfo::getExpand();
     }
-    return getIndirectResult(Ty, /*ByVal=*/false, State);
+    return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
diff --git a/clang/test/CodeGen/vectorcall.c b/clang/test/CodeGen/vectorcall.c
index cb53ecc70351d..97a532a9e3a25 100644
--- a/clang/test/CodeGen/vectorcall.c
+++ b/clang/test/CodeGen/vectorcall.c
@@ -140,4 +140,20 @@ void __vectorcall vectorcall_indirect_vec(
 // X86-SAME: ptr inreg noundef %0,
 // X86-SAME: i32 inreg noundef %edx,
 // X86-SAME: ptr noundef %1)
+
+void __vectorcall vectorcall_indirect_fp(
+    double xmm0, double xmm1, double xmm2, double xmm3, double xmm4,
+    v4f32 xmm5, v4f32 ecx, int edx, double mem) {
+}
+
+// X86: define dso_local x86_vectorcallcc void 
@"\01vectorcall_indirect_fp@@{{[0-9]+}}"
+// X86-SAME: (double inreg noundef %xmm0,
+// X86-SAME: double inreg noundef %xmm1,
+// X86-SAME: double inreg noundef %xmm2,
+// X86-SAME: double inreg noundef %xmm3,
+// X86-SAME: double inreg noundef %xmm4,
+// X86-SAME: <4 x float> inreg noundef %xmm5,
+// X86-SAME: ptr inreg noundef %0,
+// X86-SAME: i32 inreg noundef %edx,
+// X86-SAME: ptr noundef byval(double) align 4 %1)
 #endif

>From ec8be6b7ae2c85a1cab580de24883794eaef8027 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.w...@intel.com>
Date: Sun, 12 May 2024 13:57:39 +0800
Subject: [PATCH 2/2] Address review comment

---
 clang/lib/CodeGen/Targets/X86.cpp | 4 +++-
 clang/test/CodeGen/vectorcall.c   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 5c09339bd7137..29d98aad8fcb4 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -792,7 +792,9 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState &State,
         return ABIArgInfo::getDirect();
       return ABIArgInfo::getExpand();
     }
-    return getIndirectResult(Ty, IsVectorCall && Ty->isBuiltinType(), State);
+    if (IsVectorCall && Ty->isBuiltinType())
+      return ABIArgInfo::getDirect();
+    return getIndirectResult(Ty, /*ByVal=*/false, State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
diff --git a/clang/test/CodeGen/vectorcall.c b/clang/test/CodeGen/vectorcall.c
index 97a532a9e3a25..71dc3b0b9585a 100644
--- a/clang/test/CodeGen/vectorcall.c
+++ b/clang/test/CodeGen/vectorcall.c
@@ -155,5 +155,5 @@ void __vectorcall vectorcall_indirect_fp(
 // X86-SAME: <4 x float> inreg noundef %xmm5,
 // X86-SAME: ptr inreg noundef %0,
 // X86-SAME: i32 inreg noundef %edx,
-// X86-SAME: ptr noundef byval(double) align 4 %1)
+// X86-SAME: double noundef %mem)
 #endif

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to