pengfei created this revision. pengfei added a reviewer: rnk. Herald added a project: All. pengfei requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The passing format of floating-point types are different from vector when SSE registers exhausted. They are passed indirectly by value rather than address. https://godbolt.org/z/Kbs89f36P Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D134797 Files: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/vectorcall.c Index: clang/test/CodeGen/vectorcall.c =================================================================== --- clang/test/CodeGen/vectorcall.c +++ clang/test/CodeGen/vectorcall.c @@ -140,4 +140,19 @@ // X86-SAME: <4 x float>* inreg noundef %0, // X86-SAME: i32 inreg noundef %edx, // X86-SAME: <4 x float>* noundef %1) + +// The passing format of floating-point types are different from vector when SSE registers exhausted. +// They are passed indirectly by value rather than address. +void __vectorcall vectorcall_indirect_fp( + double xmm0, double xmm1, double xmm2, double xmm3, double xmm4, + v4f32 xmm5, double stack) { +} +// 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: double* noundef byval(double) align 4 %0) #endif Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -1855,7 +1855,8 @@ return ABIArgInfo::getDirect(); return ABIArgInfo::getExpand(); } - return getIndirectResult(Ty, /*ByVal=*/false, State); + bool ByVal = IsVectorCall && Ty->isFloatingType(); + return getIndirectResult(Ty, ByVal, State); } if (isAggregateTypeForABI(Ty)) {
Index: clang/test/CodeGen/vectorcall.c =================================================================== --- clang/test/CodeGen/vectorcall.c +++ clang/test/CodeGen/vectorcall.c @@ -140,4 +140,19 @@ // X86-SAME: <4 x float>* inreg noundef %0, // X86-SAME: i32 inreg noundef %edx, // X86-SAME: <4 x float>* noundef %1) + +// The passing format of floating-point types are different from vector when SSE registers exhausted. +// They are passed indirectly by value rather than address. +void __vectorcall vectorcall_indirect_fp( + double xmm0, double xmm1, double xmm2, double xmm3, double xmm4, + v4f32 xmm5, double stack) { +} +// 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: double* noundef byval(double) align 4 %0) #endif Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -1855,7 +1855,8 @@ return ABIArgInfo::getDirect(); return ABIArgInfo::getExpand(); } - return getIndirectResult(Ty, /*ByVal=*/false, State); + bool ByVal = IsVectorCall && Ty->isFloatingType(); + return getIndirectResult(Ty, ByVal, State); } if (isAggregateTypeForABI(Ty)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits