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