summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-06-20 20:07:20 +0000
committerReid Kleckner <rnk@google.com>2019-06-20 20:07:20 +0000
commit3fd3de147b998c4cfca8c1945165d7346dfdf260 (patch)
treedb674b6e6324b0712fe9047f6ce8678a2f349ba7 /clang/test
parent07ed9cfc3e8db2d6acf2412bc138d61e88ccc5f5 (diff)
downloadbcm5719-llvm-3fd3de147b998c4cfca8c1945165d7346dfdf260.tar.gz
bcm5719-llvm-3fd3de147b998c4cfca8c1945165d7346dfdf260.zip
Fix passing structs and AVX vectors through sysv_abi
Do this the same way we did it for ms_abi in r324594. Fixes PR36806. llvm-svn: 363973
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/sysv_abi.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/clang/test/CodeGen/sysv_abi.c b/clang/test/CodeGen/sysv_abi.c
new file mode 100644
index 00000000000..62b0062579c
--- /dev/null
+++ b/clang/test/CodeGen/sysv_abi.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
+
+#define SYSV_CC __attribute__((sysv_abi))
+
+// Make sure we coerce structs according to the SysV rules instead of passing
+// them indirectly as we would for Win64.
+struct StringRef {
+ char *Str;
+ __SIZE_TYPE__ Size;
+};
+extern volatile char gc;
+void SYSV_CC take_stringref(struct StringRef s);
+void callit() {
+ struct StringRef s = {"asdf", 4};
+ take_stringref(s);
+}
+// CHECK: define {{(dso_local )?}}void @callit()
+// CHECK: call {{(x86_64_sysvcc )?}}void @take_stringref(i8* {{[^,]*}}, i64 {{[^,]*}})
+// CHECK: declare {{(dso_local )?}}{{(x86_64_sysvcc )?}}void @take_stringref(i8*, i64)
+
+// Check that we pass vectors directly if the target feature is enabled, and
+// not otherwise.
+typedef __attribute__((vector_size(32))) float my_m256;
+typedef __attribute__((vector_size(64))) float my_m512;
+
+my_m256 SYSV_CC get_m256(void);
+void SYSV_CC take_m256(my_m256);
+my_m512 SYSV_CC get_m512(void);
+void SYSV_CC take_m512(my_m512);
+
+void use_vectors() {
+ my_m256 v1 = get_m256();
+ take_m256(v1);
+ my_m512 v2 = get_m512();
+ take_m512(v2);
+}
+
+// CHECK: define {{(dso_local )?}}void @use_vectors()
+// AVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
+// AVX: call {{(x86_64_sysvcc )?}}void @take_m256(<8 x float> %{{.*}})
+// AVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
+// AVX: call {{(x86_64_sysvcc )?}}void @take_m512(<16 x float> %{{.*}})
+// NOAVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
+// NOAVX: call {{(x86_64_sysvcc )?}}void @take_m256(<8 x float>* byval(<8 x float>) align 32 %{{.*}})
+// NOAVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
+// NOAVX: call {{(x86_64_sysvcc )?}}void @take_m512(<16 x float>* byval(<16 x float>) align 64 %{{.*}})
OpenPOWER on IntegriCloud