llvm.org GIT mirror llvm / bddc1ca
When analyzing functions known to only access argument pointees, only check arguments with pointer types. Update the documentation of IntrReadArgMem reflect this. While here, add support for TBAA tags on intrinsic calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130317 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
4 changed file(s) with 79 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
2929 def IntrNoMem : IntrinsicProperty;
3030
3131 // IntrReadArgMem - This intrinsic reads only from memory that one of its
32 // arguments points to, but may read an unspecified amount.
32 // pointer-typed arguments points to, but may read an unspecified amount.
3333 def IntrReadArgMem : IntrinsicProperty;
3434
3535 // IntrReadMem - This intrinsic reads from unspecified memory, so it cannot be
8585
8686 if (onlyAccessesArgPointees(MRB)) {
8787 bool doesAlias = false;
88 if (doesAccessArgPointees(MRB))
88 if (doesAccessArgPointees(MRB)) {
89 MDNode *CSTag = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa);
8990 for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
90 AI != AE; ++AI)
91 if (!isNoAlias(Location(*AI), Loc)) {
91 AI != AE; ++AI) {
92 const Value *Arg = *AI;
93 if (!Arg->getType()->isPointerTy())
94 continue;
95 Location CSLoc(Arg, UnknownSize, CSTag);
96 if (!isNoAlias(CSLoc, Loc)) {
9297 doesAlias = true;
9398 break;
9499 }
95
100 }
101 }
96102 if (!doesAlias)
97103 return NoModRef;
98104 }
137143 // CS2's arguments.
138144 if (onlyAccessesArgPointees(CS2B)) {
139145 AliasAnalysis::ModRefResult R = NoModRef;
140 if (doesAccessArgPointees(CS2B))
146 if (doesAccessArgPointees(CS2B)) {
147 MDNode *CS2Tag = CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa);
141148 for (ImmutableCallSite::arg_iterator
142149 I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
143 R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask);
150 const Value *Arg = *I;
151 if (!Arg->getType()->isPointerTy())
152 continue;
153 Location CS2Loc(Arg, UnknownSize, CS2Tag);
154 R = ModRefResult((R | getModRefInfo(CS1, CS2Loc)) & Mask);
144155 if (R == Mask)
145156 break;
146157 }
158 }
147159 return R;
148160 }
149161
151163 // any of the memory referenced by CS1's arguments. If not, return NoModRef.
152164 if (onlyAccessesArgPointees(CS1B)) {
153165 AliasAnalysis::ModRefResult R = NoModRef;
154 if (doesAccessArgPointees(CS1B))
166 if (doesAccessArgPointees(CS1B)) {
167 MDNode *CS1Tag = CS1.getInstruction()->getMetadata(LLVMContext::MD_tbaa);
155168 for (ImmutableCallSite::arg_iterator
156 I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)
157 if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) {
169 I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) {
170 const Value *Arg = *I;
171 if (!Arg->getType()->isPointerTy())
172 continue;
173 Location CS1Loc(Arg, UnknownSize, CS1Tag);
174 if (getModRefInfo(CS2, CS1Loc) != NoModRef) {
158175 R = Mask;
159176 break;
160177 }
178 }
179 }
161180 if (R == NoModRef)
162181 return R;
163182 }
0 ; RUN: opt -basicaa -gvn -S < %s | FileCheck %s
1
2 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
3
4 ; BasicAA should prove that these calls don't interfere, since they are
5 ; IntrArgReadMem and have noalias pointers.
6
7 ; CHECK: define <8 x i16> @test0(i8* noalias %p, i8* noalias %q, <8 x i16> %y) {
8 ; CHECK-NEXT: entry:
9 ; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind
10 ; CHECK-NEXT: call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16)
11 ; CHECK-NEXT: %c = add <8 x i16> %a, %a
12 define <8 x i16> @test0(i8* noalias %p, i8* noalias %q, <8 x i16> %y) {
13 entry:
14 %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind
15 call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16)
16 %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind
17 %c = add <8 x i16> %a, %b
18 ret <8 x i16> %c
19 }
20
21 declare <8 x i16> @llvm.arm.neon.vld1.v8i16(i8*, i32) nounwind readonly
22 declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind
0 ; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s
1
2 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
3
4 ; TBAA should prove that these calls don't interfere, since they are
5 ; IntrArgReadMem and have TBAA metadata.
6
7 ; CHECK: define <8 x i16> @test0(i8* %p, i8* %q, <8 x i16> %y) {
8 ; CHECK-NEXT: entry:
9 ; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind
10 ; CHECK-NEXT: call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16)
11 ; CHECK-NEXT: %c = add <8 x i16> %a, %a
12 define <8 x i16> @test0(i8* %p, i8* %q, <8 x i16> %y) {
13 entry:
14 %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind, !tbaa !2
15 call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16), !tbaa !1
16 %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind, !tbaa !2
17 %c = add <8 x i16> %a, %b
18 ret <8 x i16> %c
19 }
20
21 declare <8 x i16> @llvm.arm.neon.vld1.v8i16(i8*, i32) nounwind readonly
22 declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind
23
24 !0 = metadata !{metadata !"tbaa root", null}
25 !1 = metadata !{metadata !"A", metadata !0}
26 !2 = metadata !{metadata !"B", metadata !0}