• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple le32-unknown-nacl %s -emit-llvm -o - | FileCheck %s
2 
3 // Basic argument/attribute tests for le32/PNaCl
4 
5 // CHECK-LABEL: define void @f0(i32 %i, i32 %j, double %k)
f0(int i,long j,double k)6 void f0(int i, long j, double k) {}
7 
8 typedef struct {
9   int aa;
10   int bb;
11 } s1;
12 // Structs should be passed byval and not split up
13 // CHECK-LABEL: define void @f1(%struct.s1* byval align 4 %i)
f1(s1 i)14 void f1(s1 i) {}
15 
16 typedef struct {
17   int cc;
18 } s2;
19 // Structs should be returned sret and not simplified by the frontend
20 // CHECK-LABEL: define void @f2(%struct.s2* noalias sret %agg.result)
f2()21 s2 f2() {
22   s2 foo;
23   return foo;
24 }
25 
26 // CHECK-LABEL: define void @f3(i64 %i)
f3(long long i)27 void f3(long long i) {}
28 
29 // i8/i16 should be signext, i32 and higher should not
30 // CHECK-LABEL: define void @f4(i8 signext %a, i16 signext %b)
f4(char a,short b)31 void f4(char a, short b) {}
32 
33 // CHECK-LABEL: define void @f5(i8 zeroext %a, i16 zeroext %b)
f5(unsigned char a,unsigned short b)34 void f5(unsigned char a, unsigned short b) {}
35 
36 
37 enum my_enum {
38   ENUM1,
39   ENUM2,
40   ENUM3,
41 };
42 // Enums should be treated as the underlying i32
43 // CHECK-LABEL: define void @f6(i32 %a)
f6(enum my_enum a)44 void f6(enum my_enum a) {}
45 
46 union simple_union {
47   int a;
48   char b;
49 };
50 // Unions should be passed as byval structs
51 // CHECK-LABEL: define void @f7(%union.simple_union* byval align 4 %s)
f7(union simple_union s)52 void f7(union simple_union s) {}
53 
54 typedef struct {
55   int b4 : 4;
56   int b3 : 3;
57   int b8 : 8;
58 } bitfield1;
59 // Bitfields should be passed as byval structs
60 // CHECK-LABEL: define void @f8(%struct.bitfield1* byval align 4 %bf1)
f8(bitfield1 bf1)61 void f8(bitfield1 bf1) {}
62