• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang -target wasm64-unknown-unknown -### %s -emit-llvm-only -c 2>&1 \
2 // RUN:   | FileCheck %s -check-prefix=ECHO
3 // RUN: %clang -target wasm64-unknown-unknown %s -emit-llvm -S -o - \
4 // RUN:   | FileCheck %s
5 // RUN: %clang -target wasm64-unknown-unknown %s -emit-llvm -S -pthread -o - \
6 // RUN:   | FileCheck %s -check-prefix=THREADS
7 
8 // ECHO: {{.*}} "-cc1" {{.*}}wasm64-unknown-unknown.c
9 
10 typedef __builtin_va_list va_list;
11 typedef __SIZE_TYPE__ size_t;
12 typedef __PTRDIFF_TYPE__ ptrdiff_t;
13 
14 extern "C" {
15 
16 // CHECK: @align_c = hidden global i32 1
17 int align_c = __alignof(char);
18 
19 // CHECK: @align_s = hidden global i32 2
20 int align_s = __alignof(short);
21 
22 // CHECK: @align_i = hidden global i32 4
23 int align_i = __alignof(int);
24 
25 // CHECK: @align_l = hidden global i32 8
26 int align_l = __alignof(long);
27 
28 // CHECK: @align_ll = hidden global i32 8
29 int align_ll = __alignof(long long);
30 
31 // CHECK: @align_p = hidden global i32 8
32 int align_p = __alignof(void*);
33 
34 // CHECK: @align_f = hidden global i32 4
35 int align_f = __alignof(float);
36 
37 // CHECK: @align_d = hidden global i32 8
38 int align_d = __alignof(double);
39 
40 // CHECK: @align_ld = hidden global i32 16
41 int align_ld = __alignof(long double);
42 
43 // CHECK: @align_vl = hidden global i32 8
44 int align_vl = __alignof(va_list);
45 
46 // CHECK: _GNU_SOURCEdefined
47 #ifdef _GNU_SOURCE
_GNU_SOURCEdefined()48 void _GNU_SOURCEdefined() {}
49 #endif
50 
51 // THREADS: _REENTRANTdefined
52 // CHECK: _REENTRANTundefined
53 #ifdef _REENTRANT
_REENTRANTdefined()54 void _REENTRANTdefined() {}
55 #else
_REENTRANTundefined()56 void _REENTRANTundefined() {}
57 #endif
58 
59 // Check types
60 
61 // CHECK: signext i8 @check_char()
check_char()62 char check_char() { return 0; }
63 
64 // CHECK: signext i16 @check_short()
check_short()65 short check_short() { return 0; }
66 
67 // CHECK: i32 @check_int()
check_int()68 int check_int() { return 0; }
69 
70 // CHECK: i64 @check_long()
check_long()71 long check_long() { return 0; }
72 
73 // CHECK: i64 @check_longlong()
check_longlong()74 long long check_longlong() { return 0; }
75 
76 // CHECK: zeroext i8 @check_uchar()
check_uchar()77 unsigned char check_uchar() { return 0; }
78 
79 // CHECK: zeroext i16 @check_ushort()
check_ushort()80 unsigned short check_ushort() { return 0; }
81 
82 // CHECK: i32 @check_uint()
check_uint()83 unsigned int check_uint() { return 0; }
84 
85 // CHECK: i64 @check_ulong()
check_ulong()86 unsigned long check_ulong() { return 0; }
87 
88 // CHECK: i64 @check_ulonglong()
check_ulonglong()89 unsigned long long check_ulonglong() { return 0; }
90 
91 // CHECK: i64 @check_size_t()
check_size_t()92 size_t check_size_t() { return 0; }
93 
94 // CHECK: float @check_float()
check_float()95 float check_float() { return 0; }
96 
97 // CHECK: double @check_double()
check_double()98 double check_double() { return 0; }
99 
100 // CHECK: fp128 @check_longdouble()
check_longdouble()101 long double check_longdouble() { return 0; }
102 
103 }
104 
105 template<int> void Switch();
106 template<> void Switch<4>();
107 template<> void Switch<8>();
108 template<> void Switch<16>();
109 
check_pointer_size()110 void check_pointer_size() {
111   // CHECK: SwitchILi8
112   Switch<sizeof(void*)>();
113 
114   // CHECK: SwitchILi8
115   Switch<sizeof(long long)>();
116 
117   // CHECK: SwitchILi8
118   Switch<sizeof(va_list)>();
119 }
120