llvm.org GIT mirror llvm / 0cacb9e
[AliasAnalysis] Take into account readonly attribute for the function arguments In getArgModRefInfo we consider all arguments as having MRI_ModRef. However for arguments marked with readonly attribute we can return more precise answer - MRI_Ref. Differential Revision: http://reviews.llvm.org/D13992 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251525 91177308-0d34-0410-b5e6-96231b3b80d8 Igor Laevsky 4 years ago
2 changed file(s) with 29 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
615615 }
616616 // FIXME: Handle memset_pattern4 and memset_pattern8 also.
617617
618 if (CS.paramHasAttr(ArgIdx + 1, Attribute::ReadOnly))
619 return MRI_Ref;
620
618621 return AAResultBase::getArgModRefInfo(CS, ArgIdx);
619622 }
620623
189189 ; CHECK: ret i32 %Diff
190190 }
191191
192 ; CHECK-LABEL: @test11(
193 define i32 @test11(i32* %P, i32* %P2) {
194 %V1 = load i32, i32* %P
195 call i32 @func_argmemonly(i32* readonly %P2)
196 %V2 = load i32, i32* %P
197 %Diff = sub i32 %V1, %V2
198 ret i32 %Diff
199 ; CHECK-NOT: load
200 ; CHECK: ret i32 0
201 }
202
203 declare i32 @func_argmemonly_two_args(i32* %P, i32* %P2) argmemonly
204
205 ; CHECK-LABEL: @test12(
206 define i32 @test12(i32* %P, i32* %P2, i32* %P3) {
207 %V1 = load i32, i32* %P
208 call i32 @func_argmemonly_two_args(i32* readonly %P2, i32* %P3)
209 %V2 = load i32, i32* %P
210 %Diff = sub i32 %V1, %V2
211 ret i32 %Diff
212 ; CHECK: load
213 ; CHECK: load
214 ; CHECK: sub
215 ; CHECK: ret i32 %Diff
216 }
217
192218 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
193219 declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind
194220 declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i32, i1) nounwind