xref: /llvm-project/llvm/test/Analysis/TypeBasedAliasAnalysis/argument-promotion.ll (revision 6402fc22e1bccd0984beadfe931511175bac688c)
1; RUN: opt < %s -passes=argpromotion,mem2reg -S | FileCheck %s
2
3target datalayout = "E-p:64:64:64"
4
5; CHECK: test
6; CHECK-NOT: alloca
7define internal i32 @test(ptr %X, ptr %Y, ptr %Q) {
8  store i32 77, ptr %Q, !tbaa !2
9  %A = load i32, ptr %X, !tbaa !1
10  %B = load i32, ptr %Y, !tbaa !1
11  %C = add i32 %A, %B
12  ret i32 %C
13}
14
15; CHECK: caller
16; CHECK-NOT: alloca
17define internal i32 @caller(ptr %B, ptr %Q) {
18  %A = alloca i32
19  store i32 78, ptr %Q, !tbaa !2
20  store i32 1, ptr %A, !tbaa !1
21  %C = call i32 @test(ptr %A, ptr %B, ptr %Q)
22  ret i32 %C
23}
24
25; CHECK: callercaller
26; CHECK-NOT: alloca
27define i32 @callercaller(ptr %Q) {
28  %B = alloca i32
29  store i32 2, ptr %B, !tbaa !1
30  store i32 79, ptr %Q, !tbaa !2
31  %X = call i32 @caller(ptr %B, ptr %Q)
32  ret i32 %X
33}
34
35!0 = !{!"test"}
36!1 = !{!3, !3, i64 0}
37!2 = !{!4, !4, i64 0}
38!3 = !{!"green", !0}
39!4 = !{!"blue", !0}
40