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