blob: 242239010881efb701ed9446ecbd23f8dfc43470 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +00002// RUN: FileCheck < %t %s
Daniel Dunbar644f4c32009-02-14 02:09:24 +00003
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +00004// CHECK: %0 = type { i64, double }
5
6// CHECK: define signext i8 @f0()
Daniel Dunbar644f4c32009-02-14 02:09:24 +00007char f0(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +00008 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +00009}
10
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000011// CHECK: define signext i16 @f1()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000012short f1(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000013 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000014}
15
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000016// CHECK: define i32 @f2()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000017int f2(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000018 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000019}
20
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000021// CHECK: define float @f3()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000022float f3(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000023 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000024}
25
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000026// CHECK: define double @f4()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000027double f4(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000028 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000029}
30
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000031// CHECK: define x86_fp80 @f5()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000032long double f5(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000033 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000034}
35
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000036// CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4)
Daniel Dunbar644f4c32009-02-14 02:09:24 +000037void f6(char a0, short a1, int a2, long long a3, void *a4) {
38}
Anders Carlsson730f9092009-02-26 17:38:19 +000039
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000040// CHECK: define void @f7(i32 %a0)
41typedef enum { A, B, C } e7;
42void f7(e7 a0) {
Mike Stump4b871422009-02-26 19:00:14 +000043}
Daniel Dunbar100f4022009-03-06 17:50:25 +000044
45// Test merging/passing of upper eightbyte with X87 class.
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000046//
47// CHECK: define %0 @f8_1()
48// CHECK: define void @f8_2(%0)
Daniel Dunbar100f4022009-03-06 17:50:25 +000049union u8 {
50 long double a;
51 int b;
52};
Mike Stumpc36541e2009-07-21 20:52:43 +000053union u8 f8_1() { while (1) {} }
Daniel Dunbar100f4022009-03-06 17:50:25 +000054void f8_2(union u8 a0) {}
Daniel Dunbar8236bf12009-05-08 22:26:44 +000055
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000056// CHECK: define i64 @f9()
Mike Stumpc36541e2009-07-21 20:52:43 +000057struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
Daniel Dunbar8236bf12009-05-08 22:26:44 +000058
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000059// CHECK: define void @f10(i64)
Daniel Dunbar8236bf12009-05-08 22:26:44 +000060struct s10 { int a; int b; int : 0; };
61void f10(struct s10 a0) {}
62
Daniel Dunbar46c54fb2010-04-21 19:49:55 +000063// CHECK: define void @f11(%struct.s19* sret %agg.result)
Mike Stumpc36541e2009-07-21 20:52:43 +000064union { long double a; float b; } f11() { while (1) {} }
Daniel Dunbar20e95c52009-05-12 15:22:40 +000065
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000066// CHECK: define i64 @f12_0()
67// CHECK: define void @f12_1(i64)
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000068struct s12 { int a __attribute__((aligned(16))); };
Mike Stumpc36541e2009-07-21 20:52:43 +000069struct s12 f12_0(void) { while (1) {} }
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000070void f12_1(struct s12 a0) {}
71
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000072// Check that sret parameter is accounted for when checking available integer
73// registers.
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000074// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, %struct.s13_1* byval %e, i32 %f)
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000075
76struct s13_0 { long long f0[3]; };
Daniel Dunbar55a759b2009-08-23 19:28:59 +000077struct s13_1 { long long f0[2]; };
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000078struct s13_0 f13(int a, int b, int c, int d,
Daniel Dunbar55a759b2009-08-23 19:28:59 +000079 struct s13_1 e, int f) { while (1) {} }
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000080
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000081// CHECK: define void @f14({{.*}}, i8 signext %X)
82void f14(int a, int b, int c, int d, int e, int f, char X) {}
83
84// CHECK: define void @f15({{.*}}, i8* %X)
85void f15(int a, int b, int c, int d, int e, int f, void *X) {}
86
87// CHECK: define void @f16({{.*}}, float %X)
Daniel Dunbar86e13ee2009-05-26 16:37:37 +000088void f16(float a, float b, float c, float d, float e, float f, float g, float h,
89 float X) {}
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000090
91// CHECK: define void @f17({{.*}}, x86_fp80 %X)
Daniel Dunbar86e13ee2009-05-26 16:37:37 +000092void f17(float a, float b, float c, float d, float e, float f, float g, float h,
93 long double X) {}
94
Chris Lattnerfaf23b72010-06-28 19:56:59 +000095// Check for valid coercion. The struct should be passed/returned as i32, not
96// as i64 for better code quality.
97// rdar://8135035
98// CHECK: define void @f18(i32 %a, i32)
Daniel Dunbar55a759b2009-08-23 19:28:59 +000099struct f18_s0 { int f0; };
100void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
Daniel Dunbarfdf49862009-06-05 07:58:54 +0000101
Daniel Dunbar46c54fb2010-04-21 19:49:55 +0000102// Check byval alignment.
103
104// CHECK: define void @f19(%struct.s19* byval align 16 %x)
105struct s19 {
106 long double a;
107};
108void f19(struct s19 x) {}
109
110// CHECK: define void @f20(%struct.s20* byval align 32 %x)
111struct __attribute__((aligned(32))) s20 {
112 int x;
113 int y;
114};
115void f20(struct s20 x) {}