Disallow aliases to available_externally.
[oota-llvm.git] / test / Transforms / LICM / PR21582.ll
1 ; RUN: opt < %s -basicaa -licm -S | FileCheck %s
2 @b = external global i32, align 4
3 @fn3.i = external global i32, align 4
4
5 declare i32 @g() nounwind
6
7 define i32 @f() {
8 entry:
9   br label %for.cond
10
11 for.cond:                                         ; preds = %for.end, %entry
12 ; CHECK-LABEL: for.cond:
13 ; CHECK: store i32 0, i32* @b
14   store i32 0, i32* @b, align 4
15   br i1 true, label %for.body.preheader, label %for.end
16
17 for.body.preheader:                               ; preds = %for.cond
18   br label %for.body
19
20 for.body:                                         ; preds = %for.body, %for.body.preheader
21   %g.15 = phi i32 [ undef, %for.body ], [ 0, %for.body.preheader ]
22   %arrayidx2 = getelementptr inbounds i32, i32* @fn3.i, i64 0
23   %0 = load i32, i32* %arrayidx2, align 4
24   %call = call i32 @g()
25   br i1 false, label %for.body, label %for.end.loopexit
26
27 for.end.loopexit:                                 ; preds = %for.body
28   br label %for.end
29
30 for.end:                                          ; preds = %for.end.loopexit, %for.cond
31   %whatever = phi i32 [ %call, %for.end.loopexit ], [ undef, %for.cond ]
32   br i1 false, label %for.cond, label %if.then
33
34 if.then:                                          ; preds = %for.end
35 ; CHECK-LABEL: if.then:
36 ; CHECK: phi i32 [ {{.*}}, %for.end ]
37 ; CHECK-NOT: store i32 0, i32* @b
38 ; CHECK: ret i32
39   ret i32 %whatever
40 }