xref: /llvm-project/llvm/test/Analysis/BasicAA/noalias-inttoptr.ll (revision 05ff7606c9d47135ecf5b69e25b1327634f6fa27)
1; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2target datalayout = "p:64:64"
3
4declare void @escape(ptr %ptr)
5
6; Verify that unescaped noalias parameter does not alias inttoptr
7define void @test1(ptr noalias %P, i64 %Q_as_int) {
8  ; CHECK-LABEL: Function: test1:
9  ; CHECK: NoAlias:	i8* %P, i8* %Q
10  %Q = inttoptr i64 %Q_as_int to ptr
11  store i8 0, ptr %P
12  store i8 1, ptr %Q
13  ret void
14}
15
16; Verify that unescaped alloca does not alias inttoptr
17define void @test2(i64 %Q_as_int) {
18  ; CHECK-LABEL: Function: test2:
19  ; CHECK: NoAlias:	i8* %P, i8* %Q
20  %P = alloca i8
21  %Q = inttoptr i64 %Q_as_int to ptr
22  store i8 0, ptr %P
23  store i8 1, ptr %Q
24  ret void
25}
26
27; Verify that escaped noalias parameter may alias inttoptr
28define void @test3(ptr noalias %P, i64 %Q_as_int) {
29  ; CHECK-LABEL: Function: test3:
30  ; CHECK: MayAlias:	i8* %P, i8* %Q
31  call void @escape(ptr %P)
32  %Q = inttoptr i64 %Q_as_int to ptr
33  store i8 0, ptr %P
34  store i8 1, ptr %Q
35  ret void
36}
37
38; Verify that escaped alloca may alias inttoptr
39define void @test4(i64 %Q_as_int) {
40  ; CHECK-LABEL: Function: test4:
41  ; CHECK: MayAlias:	i8* %P, i8* %Q
42  %P = alloca i8
43  call void @escape(ptr %P)
44  %Q = inttoptr i64 %Q_as_int to ptr
45  store i8 0, ptr %P
46  store i8 1, ptr %Q
47  ret void
48}
49
50
51; Verify that global may alias inttoptr
52@G = external global i8
53define void @test5(i64 %Q_as_int) {
54  ; CHECK-LABEL: Function: test5:
55  ; CHECK: MayAlias:	i8* %Q, i8* @G
56  %Q = inttoptr i64 %Q_as_int to ptr
57  store i8 0, ptr @G
58  store i8 1, ptr %Q
59  ret void
60}
61