Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o %t -O3
      2 // RUN: grep "ret i32" %t | count 4
      3 // RUN: grep "ret i32 1" %t | count 4
      4 
      5 static int f0(int n) {
      6   struct s0 {
      7     int a : 30;
      8     int b : 2;
      9     long long c : 31;
     10   } x = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef };
     11 
     12   x.a += n;
     13   x.b += n;
     14   x.c += n;
     15 
     16   return x.a + x.b + x.c;
     17 }
     18 
     19 int g0(void) {
     20   return f0(-1) + 44335655;
     21 }
     22 
     23 static int f1(void) {
     24   struct s1 {
     25     int a:13;
     26     char b;
     27     unsigned short c:7;
     28   } x;
     29 
     30   x.a = -40;
     31   x.b = 10;
     32   x.c = 15;
     33 
     34   return x.a + x.b + x.c;
     35 }
     36 
     37 int g1(void) {
     38   return f1() + 16;
     39 }
     40 
     41 static int f2(void) {
     42   struct s2 {
     43     short a[3];
     44     int b : 15;
     45   } x;
     46 
     47   x.a[0] = x.a[1] = x.a[2] = -40;
     48   x.b = 10;
     49 
     50   return x.b;
     51 }
     52 
     53 int g2(void) {
     54   return f2() - 9;
     55 }
     56 
     57 static int f3(int n) {
     58   struct s3 {
     59     unsigned a:16;
     60     unsigned b:28 __attribute__ ((packed));
     61   } x = { 0xdeadbeef, 0xdeadbeef };
     62   struct s4 {
     63     signed a:16;
     64     signed b:28 __attribute__ ((packed));
     65   } y;
     66   y.a = -0x56789abcL;
     67   y.b = -0x56789abcL;
     68   return ((y.a += x.a += n) +
     69           (y.b += x.b += n));
     70 }
     71 
     72 int g3(void) {
     73   return f3(20) + 130725747;
     74 }
     75