Dan Gohman | 2ea7e73 | 2010-12-13 23:51:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s |
| 2 | // RUN: FileCheck < %t %s |
| 3 | |
| 4 | // Types with the may_alias attribute should be considered equivalent |
| 5 | // to char for aliasing. |
| 6 | |
| 7 | typedef int __attribute__((may_alias)) aliasing_int; |
| 8 | |
| 9 | void test0(aliasing_int *ai, int *i) |
| 10 | { |
John McCall | bc7fbf0 | 2011-02-26 08:07:02 +0000 | [diff] [blame] | 11 | // CHECK: store i32 0, i32* %{{.*}}, !tbaa !1 |
Dan Gohman | 2ea7e73 | 2010-12-13 23:51:08 +0000 | [diff] [blame] | 12 | *ai = 0; |
John McCall | bc7fbf0 | 2011-02-26 08:07:02 +0000 | [diff] [blame] | 13 | // CHECK: store i32 1, i32* %{{.*}}, !tbaa !3 |
Dan Gohman | 2ea7e73 | 2010-12-13 23:51:08 +0000 | [diff] [blame] | 14 | *i = 1; |
| 15 | } |
| 16 | |
John McCall | bc7fbf0 | 2011-02-26 08:07:02 +0000 | [diff] [blame] | 17 | // PR9307 |
| 18 | struct Test1 { int x; }; |
| 19 | struct Test1MA { int x; } __attribute__((may_alias)); |
| 20 | void test1(struct Test1MA *p1, struct Test1 *p2) { |
| 21 | // CHECK: store i32 2, i32* {{%.*}}, !tbaa !1 |
| 22 | p1->x = 2; |
| 23 | // CHECK: store i32 3, i32* {{%.*}}, !tbaa !3 |
| 24 | p2->x = 3; |
| 25 | } |
Dan Gohman | 2ea7e73 | 2010-12-13 23:51:08 +0000 | [diff] [blame] | 26 | |
| 27 | // CHECK: !0 = metadata !{metadata !"any pointer", metadata !1} |
| 28 | // CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} |
| 29 | // CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null} |
| 30 | // CHECK: !3 = metadata !{metadata !"int", metadata !1} |