1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -passes=inline -enable-noalias-to-md-conversion -S < %s | FileCheck %s
3 ; RUN: opt -aa-pipeline=basic-aa -passes=inline -enable-noalias-to-md-conversion -S < %s | FileCheck %s
5 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 declare void @llvm.experimental.noalias.scope.decl(metadata) #0
10 define void @caller_equals_callee(ptr noalias %p0, ptr noalias %p1, i32 %cnt) {
11 ; CHECK-LABEL: define {{[^@]+}}@caller_equals_callee
12 ; CHECK-SAME: (ptr noalias [[P0:%.*]], ptr noalias [[P1:%.*]], i32 [[CNT:%.*]]) {
14 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[P0]], i64 2
15 ; CHECK-NEXT: [[ADD_PTR1:%.*]] = getelementptr inbounds i32, ptr [[P1]], i64 2
16 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata !0)
17 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata !3)
18 ; CHECK-NEXT: store i32 10, ptr [[ADD_PTR]], align 4, !alias.scope !0, !noalias !3
19 ; CHECK-NEXT: store i32 20, ptr [[ADD_PTR1]], align 4, !alias.scope !3, !noalias !0
20 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CNT]], 0
21 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
23 ; CHECK-NEXT: store i32 11, ptr [[P0]], align 4
24 ; CHECK-NEXT: br label [[IF_END:%.*]]
26 ; CHECK-NEXT: [[ADD_PTR2:%.*]] = getelementptr inbounds i32, ptr [[P1]], i64 1
27 ; CHECK-NEXT: [[ADD_PTR3:%.*]] = getelementptr inbounds i32, ptr [[P0]], i64 1
28 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !5)
29 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !8)
30 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR2]], i64 2
31 ; CHECK-NEXT: [[ADD_PTR1_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR3]], i64 2
32 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata !10)
33 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata !13)
34 ; CHECK-NEXT: store i32 10, ptr [[ADD_PTR_I]], align 4, !alias.scope !15, !noalias !16
35 ; CHECK-NEXT: store i32 20, ptr [[ADD_PTR1_I]], align 4, !alias.scope !16, !noalias !15
36 ; CHECK-NEXT: store i32 11, ptr [[ADD_PTR2]], align 4, !alias.scope !5, !noalias !8
37 ; CHECK-NEXT: store i32 12, ptr [[P1]], align 4
38 ; CHECK-NEXT: br label [[IF_END]]
40 ; CHECK-NEXT: ret void
43 %add.ptr = getelementptr inbounds i32, ptr %p0, i64 2
44 %add.ptr1 = getelementptr inbounds i32, ptr %p1, i64 2
45 tail call void @llvm.experimental.noalias.scope.decl(metadata !0)
46 tail call void @llvm.experimental.noalias.scope.decl(metadata !3)
47 store i32 10, ptr %add.ptr, align 4, !alias.scope !0, !noalias !3
48 store i32 20, ptr %add.ptr1, align 4, !alias.scope !3, !noalias !0
49 %cmp = icmp eq i32 %cnt, 0
50 br i1 %cmp, label %if.then, label %if.else
52 if.then: ; preds = %entry
53 store i32 11, ptr %p0, align 4
56 if.else: ; preds = %entry
57 %add.ptr2 = getelementptr inbounds i32, ptr %p1, i64 1
58 %add.ptr3 = getelementptr inbounds i32, ptr %p0, i64 1
59 tail call void @caller_equals_callee(ptr nonnull %add.ptr2, ptr nonnull %add.ptr3, i32 0)
60 store i32 12, ptr %p1, align 4
63 if.end: ; preds = %if.else, %if.then
67 define void @test01(ptr noalias %p0, ptr noalias %p1, i32 %cnt) {
68 ; CHECK-LABEL: define {{[^@]+}}@test01
69 ; CHECK-SAME: (ptr noalias [[P0:%.*]], ptr noalias [[P1:%.*]], i32 [[CNT:%.*]]) {
71 ; CHECK-NEXT: store i32 13, ptr [[P0]], align 4
72 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[P0]], i64 1
73 ; CHECK-NEXT: [[ADD_PTR1:%.*]] = getelementptr inbounds i32, ptr [[P1]], i64 1
74 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !17)
75 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !20)
76 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR]], i64 2
77 ; CHECK-NEXT: [[ADD_PTR1_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR1]], i64 2
78 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !22)
79 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !25)
80 ; CHECK-NEXT: store i32 10, ptr [[ADD_PTR_I]], align 4, !alias.scope !27, !noalias !28
81 ; CHECK-NEXT: store i32 20, ptr [[ADD_PTR1_I]], align 4, !alias.scope !28, !noalias !27
82 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[CNT]], 0
83 ; CHECK-NEXT: br i1 [[CMP_I]], label [[IF_THEN_I:%.*]], label [[IF_ELSE_I:%.*]]
85 ; CHECK-NEXT: store i32 11, ptr [[ADD_PTR]], align 4, !alias.scope !17, !noalias !20
86 ; CHECK-NEXT: br label [[CALLER_EQUALS_CALLEE_EXIT:%.*]]
88 ; CHECK-NEXT: [[ADD_PTR2_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR1]], i64 1
89 ; CHECK-NEXT: [[ADD_PTR3_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR]], i64 1
90 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !29)
91 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !32)
92 ; CHECK-NEXT: [[ADD_PTR_I_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR2_I]], i64 2
93 ; CHECK-NEXT: [[ADD_PTR1_I_I:%.*]] = getelementptr inbounds i32, ptr [[ADD_PTR3_I]], i64 2
94 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !34)
95 ; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata !37)
96 ; CHECK-NEXT: store i32 10, ptr [[ADD_PTR_I_I]], align 4, !alias.scope !39, !noalias !40
97 ; CHECK-NEXT: store i32 20, ptr [[ADD_PTR1_I_I]], align 4, !alias.scope !40, !noalias !39
98 ; CHECK-NEXT: store i32 11, ptr [[ADD_PTR2_I]], align 4, !alias.scope !41, !noalias !42
99 ; CHECK-NEXT: store i32 12, ptr [[ADD_PTR1]], align 4, !alias.scope !20, !noalias !17
100 ; CHECK-NEXT: br label [[CALLER_EQUALS_CALLEE_EXIT]]
101 ; CHECK: caller_equals_callee.exit:
102 ; CHECK-NEXT: ret void
105 store i32 13, ptr %p0, align 4
106 %add.ptr = getelementptr inbounds i32, ptr %p0, i64 1
107 %add.ptr1 = getelementptr inbounds i32, ptr %p1, i64 1
108 call void @caller_equals_callee(ptr nonnull %add.ptr, ptr nonnull %add.ptr1, i32 %cnt)
112 attributes #0 = { inaccessiblememonly nofree nosync nounwind willreturn }
115 !1 = distinct !{!1, !2, !"do_store: %p0"}
116 !2 = distinct !{!2, !"do_store"}
118 !4 = distinct !{!4, !2, !"do_store: %p1"}
121 ; CHECK: !1 = distinct !{!1, !2, !"do_store: %p0"}
122 ; CHECK: !2 = distinct !{!2, !"do_store"}
124 ; CHECK: !4 = distinct !{!4, !2, !"do_store: %p1"}
126 ; CHECK: !6 = distinct !{!6, !7, !"caller_equals_callee: %p0"}
127 ; CHECK: !7 = distinct !{!7, !"caller_equals_callee"}
129 ; CHECK: !9 = distinct !{!9, !7, !"caller_equals_callee: %p1"}
130 ; CHECK: !10 = !{!11}
131 ; CHECK: !11 = distinct !{!11, !12, !"do_store: %p0"}
132 ; CHECK: !12 = distinct !{!12, !"do_store"}
133 ; CHECK: !13 = !{!14}
134 ; CHECK: !14 = distinct !{!14, !12, !"do_store: %p1"}
135 ; CHECK: !15 = !{!11, !6}
136 ; CHECK: !16 = !{!14, !9}
137 ; CHECK: !17 = !{!18}
138 ; CHECK: !18 = distinct !{!18, !19, !"caller_equals_callee: %p0"}
139 ; CHECK: !19 = distinct !{!19, !"caller_equals_callee"}
140 ; CHECK: !20 = !{!21}
141 ; CHECK: !21 = distinct !{!21, !19, !"caller_equals_callee: %p1"}
142 ; CHECK: !22 = !{!23}
143 ; CHECK: !23 = distinct !{!23, !24, !"do_store: %p0"}
144 ; CHECK: !24 = distinct !{!24, !"do_store"}
145 ; CHECK: !25 = !{!26}
146 ; CHECK: !26 = distinct !{!26, !24, !"do_store: %p1"}
147 ; CHECK: !27 = !{!23, !18}
148 ; CHECK: !28 = !{!26, !21}
149 ; CHECK: !29 = !{!30}
150 ; CHECK: !30 = distinct !{!30, !31, !"caller_equals_callee: %p0"}
151 ; CHECK: !31 = distinct !{!31, !"caller_equals_callee"}
152 ; CHECK: !32 = !{!33}
153 ; CHECK: !33 = distinct !{!33, !31, !"caller_equals_callee: %p1"}
154 ; CHECK: !34 = !{!35}
155 ; CHECK: !35 = distinct !{!35, !36, !"do_store: %p0"}
156 ; CHECK: !36 = distinct !{!36, !"do_store"}
157 ; CHECK: !37 = !{!38}
158 ; CHECK: !38 = distinct !{!38, !36, !"do_store: %p1"}
159 ; CHECK: !39 = !{!35, !30, !21}
160 ; CHECK: !40 = !{!38, !33, !18}
161 ; CHECK: !41 = !{!30, !21}
162 ; CHECK: !42 = !{!33, !18}