-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86_64] fix SSE type error in vaarg. #86377
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
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-x86 Author: Longsheng Mou (CoTinker) Changestweak 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:
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);
+}
|
@llvm/pr-subscribers-clang-codegen Author: Longsheng Mou (CoTinker) Changestweak 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:
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);
+}
|
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
@@ -21,3 +21,18 @@ empty empty_record_test(int z, ...) { | |||
__builtin_va_start(list, z); | |||
return __builtin_va_arg(list, empty); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please regenerate the CHECK lines with update_cc_test_checks.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tweak the position of the ++neededSSE when Lo is NoClass and Hi is SSE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
typedef struct { | ||
struct{} a; | ||
double b; | ||
} s1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is really worth testing... at least, it's not testing anything relevant to this patch. (sizeof(s1)==8.) Up to you, I guess.
Thanks. |
/cherry-pick 9c8dd5e |
Error: Command failed due to missing milestone. |
tweak the position of the ++neededSSE when Lo is NoClass and Hi is SSE. Fix llvm#86371. (cherry picked from commit 9c8dd5e)
tweak the position of the ++neededSSE when Lo is NoClass and Hi is SSE. Fix llvm#86371. (cherry picked from commit 9c8dd5e)
tweak the position of the ++neededSSE when Lo is NoClass and Hi is SSE. Fix #86371.