• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
2; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6; rdar://7282591
7
8@X = common global i32 0
9@Y = common global i32 0
10@Z = common global i32 0
11
12; CHECK-LABEL: foo
13; CHECK:  NoAlias: i32* %P, i32* @Z
14
15define void @foo(i32 %cond) nounwind {
16entry:
17  %"alloca point" = bitcast i32 0 to i32
18  %tmp = icmp ne i32 %cond, 0
19  br i1 %tmp, label %bb, label %bb1
20
21bb:
22  br label %bb2
23
24bb1:
25  br label %bb2
26
27bb2:
28  %P = phi i32* [ @X, %bb ], [ @Y, %bb1 ]
29  %tmp1 = load i32, i32* @Z, align 4
30  store i32 123, i32* %P, align 4
31  %tmp2 = load i32, i32* @Z, align 4
32  br label %return
33
34return:
35  ret void
36}
37
38; Pointers can vary in between iterations of loops.
39; PR18068
40
41; CHECK-LABEL: pr18068
42; CHECK: MayAlias: i32* %0, i32* %arrayidx5
43; CHECK: NoAlias: i32* %arrayidx13, i32* %arrayidx5
44
45define i32 @pr18068(i32* %jj7, i32* %j) {
46entry:
47  %oa5 = alloca [100 x i32], align 16
48  br label %codeRepl
49
50codeRepl:
51  %0 = phi i32* [ %arrayidx13, %for.body ], [ %j, %entry ]
52  %targetBlock = call i1 @cond(i32* %jj7)
53  br i1 %targetBlock, label %for.body, label %bye
54
55for.body:
56  %1 = load i32, i32* %jj7, align 4
57  %idxprom4 = zext i32 %1 to i64
58  %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom4
59  %2 = load i32, i32* %arrayidx5, align 4
60  %sub6 = sub i32 %2, 6
61  store i32 %sub6, i32* %arrayidx5, align 4
62  ; %0 and %arrayidx5 can alias! It is not safe to DSE the above store.
63  %3 = load i32, i32* %0, align 4
64  store i32 %3, i32* %arrayidx5, align 4
65  %sub11 = add i32 %1, -1
66  %idxprom12 = zext i32 %sub11 to i64
67  %arrayidx13 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom12
68  call void @inc(i32* %jj7)
69  br label %codeRepl
70
71bye:
72  %.reload = load i32, i32* %jj7, align 4
73  ret i32 %.reload
74}
75
76declare i1 @cond(i32*)
77
78declare void @inc(i32*)
79
80
81