blob: c624d0045d33010a81a2bfd1a6b5f1105f6c2fcd [file] [log] [blame]
Manman Renf5d9d342013-10-11 20:48:38 +00001// 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
Lauro Ramos Venancio2ddcb25a32008-01-22 20:17:04 +00003
Daniel Dunbar8d816832008-08-06 16:07:39 +00004static 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;
Lauro Ramos Venancio2ddcb25a32008-01-22 20:17:04 +000014
Daniel Dunbar8d816832008-08-06 16:07:39 +000015 return x.a + x.b + x.c;
Lauro Ramos Venancio2ddcb25a32008-01-22 20:17:04 +000016}
Lauro Ramos Venancio09af71c2008-01-22 22:36:45 +000017
Daniel Dunbar8d816832008-08-06 16:07:39 +000018int g0(void) {
Manman Ren3380ee52013-08-21 20:53:05 +000019// CHECK-LABEL: @g0()
20// CHECK: ret i32 1
Manman Ren879ce882013-08-21 20:58:45 +000021// PATH-LABEL: @g0()
22// PATH: ret i32 1
Daniel Dunbar8d816832008-08-06 16:07:39 +000023 return f0(-1) + 44335655;
Lauro Ramos Venancio09af71c2008-01-22 22:36:45 +000024}
Lauro Ramos Venancio9eff02d2008-02-07 19:29:53 +000025
Daniel Dunbar8d816832008-08-06 16:07:39 +000026static 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;
Lauro Ramos Venancio9eff02d2008-02-07 19:29:53 +000038}
39
Daniel Dunbar8d816832008-08-06 16:07:39 +000040int g1(void) {
Manman Ren3380ee52013-08-21 20:53:05 +000041// CHECK-LABEL: @g1()
42// CHECK: ret i32 1
Manman Ren879ce882013-08-21 20:58:45 +000043// PATH-LABEL: @g1()
44// PATH: ret i32 1
Daniel Dunbar8d816832008-08-06 16:07:39 +000045 return f1() + 16;
46}
47
48static 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
60int g2(void) {
Manman Ren3380ee52013-08-21 20:53:05 +000061// CHECK-LABEL: @g2()
62// CHECK: ret i32 1
Manman Ren879ce882013-08-21 20:58:45 +000063// PATH-LABEL: @g2()
64// PATH: ret i32 1
Daniel Dunbar8d816832008-08-06 16:07:39 +000065 return f2() - 9;
66}
67
68static 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
83int g3(void) {
Manman Ren3380ee52013-08-21 20:53:05 +000084// CHECK-LABEL: @g3()
85// CHECK: ret i32 1
Manman Ren879ce882013-08-21 20:58:45 +000086// PATH-LABEL: @g3()
87// PATH: ret i32 1
Daniel Dunbar8d816832008-08-06 16:07:39 +000088 return f3(20) + 130725747;
Lauro Ramos Venancio9eff02d2008-02-07 19:29:53 +000089}