summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-07-17 05:49:13 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-07-17 05:49:13 +0000
commitf8d14dbcfcd8e73903bc778f09b9796f10f45ec8 (patch)
tree8d9d97c20794c027f8ede1510c097566ae0317d3
parent64fc0727ffe36ee582af1e70913db49fdf67a3dc (diff)
downloadbcm5719-llvm-f8d14dbcfcd8e73903bc778f09b9796f10f45ec8.tar.gz
bcm5719-llvm-f8d14dbcfcd8e73903bc778f09b9796f10f45ec8.zip
[CodeGen, X86] Classify vectors <= 32 bits as INTEGER
We shouldn't crash despite the AMD64 ABI not giving clear guidance as to how to pass around vector types <= 32 bits. Instead, classify such vectors as INTEGER to be compatible with GCC. This fixes PR24162. llvm-svn: 242508
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp14
-rw-r--r--clang/test/CodeGenCXX/x86_64-arguments.cpp9
2 files changed, 17 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 6226d213b62..f95b945af4e 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1907,16 +1907,18 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase,
if (const VectorType *VT = Ty->getAs<VectorType>()) {
uint64_t Size = getContext().getTypeSize(VT);
- if (Size == 32) {
- // gcc passes all <4 x char>, <2 x short>, <1 x int>, <1 x
- // float> as integer.
+ if (Size == 1 || Size == 8 || Size == 16 || Size == 32) {
+ // gcc passes the following as integer:
+ // 4 bytes - <4 x char>, <2 x short>, <1 x int>, <1 x float>
+ // 2 bytes - <2 x char>, <1 x short>
+ // 1 byte - <1 x char>
Current = Integer;
// If this type crosses an eightbyte boundary, it should be
// split.
- uint64_t EB_Real = (OffsetBase) / 64;
- uint64_t EB_Imag = (OffsetBase + Size - 1) / 64;
- if (EB_Real != EB_Imag)
+ uint64_t EB_Lo = (OffsetBase) / 64;
+ uint64_t EB_Hi = (OffsetBase + Size - 1) / 64;
+ if (EB_Lo != EB_Hi)
Hi = Lo;
} else if (Size == 64) {
// gcc passes <1 x double> in memory. :(
diff --git a/clang/test/CodeGenCXX/x86_64-arguments.cpp b/clang/test/CodeGenCXX/x86_64-arguments.cpp
index 64202b4d02c..c7eca2386af 100644
--- a/clang/test/CodeGenCXX/x86_64-arguments.cpp
+++ b/clang/test/CodeGenCXX/x86_64-arguments.cpp
@@ -212,3 +212,12 @@ int FuncForDerivedPacked(DerivedPacked d) {
return d.three;
}
}
+
+namespace test11 {
+union U {
+ float f1;
+ char __attribute__((__vector_size__(1))) f2;
+};
+int f(union U u) { return u.f2[1]; }
+// CHECK-LABEL: define i32 @_ZN6test111fENS_1UE(i32
+}
OpenPOWER on IntegriCloud