[clang] [X86_64] fix SSE type error in vaarg. (PR #86377)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 22 21:31:20 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Longsheng Mou (CoTinker)
<details>
<summary>Changes</summary>
tweak the position of the ++neededSSE when Lo is NoClass and Hi is SSE. Fix #<!-- -->86371.
---
Full diff: https://github.com/llvm/llvm-project/pull/86377.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/Targets/X86.cpp (+1-2)
- (modified) clang/test/CodeGenCXX/x86_64-vaarg.cpp (+15)
``````````diff
diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp
index 1ec0f159ebcb8a..6931768147a9b2 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -2788,12 +2788,11 @@ X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned freeIntRegs,
// memory), except in situations involving unions.
case X87Up:
case SSE:
+ ++neededSSE;
HighPart = GetSSETypeAtOffset(CGT.ConvertType(Ty), 8, Ty, 8);
if (Lo == NoClass) // Pass HighPart at offset 8 in memory.
return ABIArgInfo::getDirect(HighPart, 8);
-
- ++neededSSE;
break;
// AMD64-ABI 3.2.3p3: Rule 4. If the class is SSEUP, the
diff --git a/clang/test/CodeGenCXX/x86_64-vaarg.cpp b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
index f0177906a09a81..82c32329502816 100644
--- a/clang/test/CodeGenCXX/x86_64-vaarg.cpp
+++ b/clang/test/CodeGenCXX/x86_64-vaarg.cpp
@@ -21,3 +21,18 @@ empty empty_record_test(int z, ...) {
__builtin_va_start(list, z);
return __builtin_va_arg(list, empty);
}
+
+typedef struct {
+ struct{} a;
+ double b;
+} s1;
+
+// CHECK-LABEL: define{{.*}} double @{{.*}}f
+// CHECK: vaarg.in_reg:
+// CHECK: vaarg.in_mem:
+// CHECK: vaarg.end:
+s1 f(int z, ...) {
+ __builtin_va_list list;
+ __builtin_va_start(list, z);
+ return __builtin_va_arg(list, s1);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/86377
More information about the cfe-commits
mailing list