[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / X86 / x86_64-arguments-nacl.c
blob4d820aef8fd2df924afa05ac302afc971ace5393
1 // RUN: %clang_cc1 -triple x86_64-unknown-nacl -emit-llvm -o - %s| FileCheck %s
2 #include <stdarg.h>
3 // Test for x86-64 structure representation (instead of pnacl representation),
4 // in particular for unions. Also crib a few tests from x86 Linux.
6 union PP_VarValue {
7 int as_int;
8 double as_double;
9 long long as_i64;
12 struct PP_Var {
13 int type;
14 int padding;
15 union PP_VarValue value;
18 // CHECK: define{{.*}} { i64, i64 } @f0()
19 struct PP_Var f0(void) {
20 struct PP_Var result = { 0, 0, 0 };
21 return result;
24 // CHECK-LABEL: define{{.*}} void @f1(i64 %p1.coerce0, i64 %p1.coerce1)
25 void f1(struct PP_Var p1) { while(1) {} }
27 // long doubles are 64 bits on NaCl
28 // CHECK-LABEL: define{{.*}} double @f5()
29 long double f5(void) {
30 return 0;
33 // CHECK-LABEL: define{{.*}} void @f6(i8 noundef signext %a0, i16 noundef signext %a1, i32 noundef %a2, i64 noundef %a3, ptr noundef %a4)
34 void f6(char a0, short a1, int a2, long long a3, void *a4) {
37 // CHECK-LABEL: define{{.*}} i64 @f8_1()
38 // CHECK-LABEL: define{{.*}} void @f8_2(i64 %a0.coerce)
39 union u8 {
40 long double a;
41 int b;
43 union u8 f8_1(void) { while (1) {} }
44 void f8_2(union u8 a0) {}
46 // CHECK-LABEL: define{{.*}} i64 @f9()
47 struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
49 // CHECK-LABEL: define{{.*}} void @f10(i64 %a0.coerce)
50 struct s10 { int a; int b; int : 0; };
51 void f10(struct s10 a0) {}
53 // CHECK-LABEL: define{{.*}} double @f11()
54 union { long double a; float b; } f11(void) { while (1) {} }
56 // CHECK-LABEL: define{{.*}} i32 @f12_0()
57 // CHECK-LABEL: define{{.*}} void @f12_1(i32 %a0.coerce)
58 struct s12 { int a __attribute__((aligned(16))); };
59 struct s12 f12_0(void) { while (1) {} }
60 void f12_1(struct s12 a0) {}
62 // Check that sret parameter is accounted for when checking available integer
63 // registers.
64 // CHECK: define{{.*}} void @f13(ptr dead_on_unwind noalias writable sret(%struct.s13_0) align 8 %agg.result, i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d, ptr noundef byval({{.*}}) align 8 %e, i32 noundef %f)
66 struct s13_0 { long long f0[3]; };
67 struct s13_1 { long long f0[2]; };
68 struct s13_0 f13(int a, int b, int c, int d,
69 struct s13_1 e, int f) { while (1) {} }
71 // CHECK-LABEL: define{{.*}} void @f20(ptr noundef byval(%struct.s20) align 32 %x)
72 struct __attribute__((aligned(32))) s20 {
73 int x;
74 int y;
76 void f20(struct s20 x) {}
79 // CHECK: declare void @func(i64)
80 typedef struct _str {
81 union {
82 long double a;
83 long c;
85 } str;
87 void func(str s);
88 str ss;
89 void f9122143(void)
91 func(ss);