1 ; RUN: opt -basicaa -print-alias-sets -S -o - < %s 2>&1 | FileCheck %s
3 @s = global i8 1, align 1
4 @d = global i8 2, align 1
6 ; CHECK: Alias sets for function 'test_alloca_argmemonly':
7 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 3 pointer values.
8 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, LocationSize::precise(1))
9 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown), (i8* %s, unknown)
10 define void @test_alloca_argmemonly(i8* %s, i8* %d) {
12 %a = alloca i8, align 1
13 store i8 1, i8* %a, align 1
14 call void @my_memcpy(i8* %d, i8* %s, i64 1)
18 ; CHECK: Alias sets for function 'test_readonly_arg'
19 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values.
20 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown)
21 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %s, unknown)
22 define i8 @test_readonly_arg(i8* noalias %s, i8* noalias %d) {
24 call void @my_memcpy(i8* %d, i8* %s, i64 1)
25 %ret = load i8, i8* %s
29 ; CHECK: Alias sets for function 'test_noalias_argmemonly':
30 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 3 pointer values.
31 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, LocationSize::precise(1))
32 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown), (i8* %s, unknown)
33 define void @test_noalias_argmemonly(i8* noalias %a, i8* %s, i8* %d) {
35 store i8 1, i8* %a, align 1
36 call void @my_memmove(i8* %d, i8* %s, i64 1)
40 ; CHECK: Alias sets for function 'test5':
41 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values.
42 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown)
43 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown)
44 define void @test5(i8* noalias %a, i8* noalias %b) {
46 store i8 1, i8* %a, align 1
47 call void @my_memcpy(i8* %b, i8* %a, i64 1)
48 store i8 1, i8* %b, align 1
52 ; CHECK: Alias sets for function 'test_argcollapse':
53 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values.
54 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown)
55 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown)
56 define void @test_argcollapse(i8* noalias %a, i8* noalias %b) {
58 store i8 1, i8* %a, align 1
59 call void @my_memmove(i8* %b, i8* %a, i64 1)
60 store i8 1, i8* %b, align 1
64 ; CHECK: Alias sets for function 'test_memcpy1':
65 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values.
66 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown)
67 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown)
68 define void @test_memcpy1(i8* noalias %a, i8* noalias %b) {
70 call void @my_memcpy(i8* %b, i8* %a, i64 1)
71 call void @my_memcpy(i8* %a, i8* %b, i64 1)
75 ; CHECK: Alias sets for function 'test_memset1':
76 ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 1 pointer values.
77 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown)
78 define void @test_memset1() {
80 %a = alloca i8, align 1
81 call void @my_memset(i8* %a, i8 0, i64 1)
85 ; CHECK: Alias sets for function 'test_memset2':
86 ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 1 pointer values.
87 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown)
88 define void @test_memset2(i8* %a) {
90 call void @my_memset(i8* %a, i8 0, i64 1)
94 ; CHECK: Alias sets for function 'test_memset3':
95 ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 2 pointer values.
96 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod Pointers: (i8* %a, unknown), (i8* %b, unknown)
97 define void @test_memset3(i8* %a, i8* %b) {
99 call void @my_memset(i8* %a, i8 0, i64 1)
100 call void @my_memset(i8* %b, i8 0, i64 1)
106 ; CHECK: Alias sets for function 'test_memset4':
107 ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values.
108 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown)
109 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown)
110 define void @test_memset4(i8* noalias %a, i8* noalias %b) {
112 call void @my_memset(i8* %a, i8 0, i64 1)
113 call void @my_memset(i8* %b, i8 0, i64 1)
117 declare void @my_memset(i8* nocapture writeonly, i8, i64) argmemonly
118 declare void @my_memcpy(i8* nocapture writeonly, i8* nocapture readonly, i64) argmemonly
119 declare void @my_memmove(i8* nocapture, i8* nocapture readonly, i64) argmemonly
122 ; CHECK: Alias sets for function 'test_attribute_intersect':
123 ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 1 pointer values.
124 ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %a, LocationSize::precise(1))
125 define i8 @test_attribute_intersect(i8* noalias %a) {
127 ;; This call is effectively readnone since the argument is readonly
128 ;; and the function is declared writeonly.
129 call void @attribute_intersect(i8* %a)
130 %val = load i8, i8* %a
134 declare void @attribute_intersect(i8* readonly) argmemonly writeonly