Manman Ren | f5d9d34 | 2013-10-11 20:48:38 +0000 | [diff] [blame] | 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 |
Lauro Ramos Venancio | 2ddcb25a3 | 2008-01-22 20:17:04 +0000 | [diff] [blame] | 3 | |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 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; |
Lauro Ramos Venancio | 2ddcb25a3 | 2008-01-22 20:17:04 +0000 | [diff] [blame] | 14 | |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 15 | return x.a + x.b + x.c; |
Lauro Ramos Venancio | 2ddcb25a3 | 2008-01-22 20:17:04 +0000 | [diff] [blame] | 16 | } |
Lauro Ramos Venancio | 09af71c | 2008-01-22 22:36:45 +0000 | [diff] [blame] | 17 | |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 18 | int g0(void) { |
Manman Ren | 3380ee5 | 2013-08-21 20:53:05 +0000 | [diff] [blame] | 19 | // CHECK-LABEL: @g0() |
| 20 | // CHECK: ret i32 1 |
Manman Ren | 879ce88 | 2013-08-21 20:58:45 +0000 | [diff] [blame] | 21 | // PATH-LABEL: @g0() |
| 22 | // PATH: ret i32 1 |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 23 | return f0(-1) + 44335655; |
Lauro Ramos Venancio | 09af71c | 2008-01-22 22:36:45 +0000 | [diff] [blame] | 24 | } |
Lauro Ramos Venancio | 9eff02d | 2008-02-07 19:29:53 +0000 | [diff] [blame] | 25 | |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 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; |
Lauro Ramos Venancio | 9eff02d | 2008-02-07 19:29:53 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 40 | int g1(void) { |
Manman Ren | 3380ee5 | 2013-08-21 20:53:05 +0000 | [diff] [blame] | 41 | // CHECK-LABEL: @g1() |
| 42 | // CHECK: ret i32 1 |
Manman Ren | 879ce88 | 2013-08-21 20:58:45 +0000 | [diff] [blame] | 43 | // PATH-LABEL: @g1() |
| 44 | // PATH: ret i32 1 |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 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) { |
Manman Ren | 3380ee5 | 2013-08-21 20:53:05 +0000 | [diff] [blame] | 61 | // CHECK-LABEL: @g2() |
| 62 | // CHECK: ret i32 1 |
Manman Ren | 879ce88 | 2013-08-21 20:58:45 +0000 | [diff] [blame] | 63 | // PATH-LABEL: @g2() |
| 64 | // PATH: ret i32 1 |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 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) { |
Manman Ren | 3380ee5 | 2013-08-21 20:53:05 +0000 | [diff] [blame] | 84 | // CHECK-LABEL: @g3() |
| 85 | // CHECK: ret i32 1 |
Manman Ren | 879ce88 | 2013-08-21 20:58:45 +0000 | [diff] [blame] | 86 | // PATH-LABEL: @g3() |
| 87 | // PATH: ret i32 1 |
Daniel Dunbar | 8d81683 | 2008-08-06 16:07:39 +0000 | [diff] [blame] | 88 | return f3(20) + 130725747; |
Lauro Ramos Venancio | 9eff02d | 2008-02-07 19:29:53 +0000 | [diff] [blame] | 89 | } |