mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 19:49:36 +00:00
[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 llvm-svn: 251525
This commit is contained in:
parent
5d381bc775
commit
36e84c0fc7
@ -616,6 +616,9 @@ ModRefInfo BasicAAResult::getArgModRefInfo(ImmutableCallSite CS,
|
||||
}
|
||||
// FIXME: Handle memset_pattern4 and memset_pattern8 also.
|
||||
|
||||
if (CS.paramHasAttr(ArgIdx + 1, Attribute::ReadOnly))
|
||||
return MRI_Ref;
|
||||
|
||||
return AAResultBase::getArgModRefInfo(CS, ArgIdx);
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,32 @@ define i32 @test10(i32* %P, i32* %P2) {
|
||||
; CHECK: ret i32 %Diff
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test11(
|
||||
define i32 @test11(i32* %P, i32* %P2) {
|
||||
%V1 = load i32, i32* %P
|
||||
call i32 @func_argmemonly(i32* readonly %P2)
|
||||
%V2 = load i32, i32* %P
|
||||
%Diff = sub i32 %V1, %V2
|
||||
ret i32 %Diff
|
||||
; CHECK-NOT: load
|
||||
; CHECK: ret i32 0
|
||||
}
|
||||
|
||||
declare i32 @func_argmemonly_two_args(i32* %P, i32* %P2) argmemonly
|
||||
|
||||
; CHECK-LABEL: @test12(
|
||||
define i32 @test12(i32* %P, i32* %P2, i32* %P3) {
|
||||
%V1 = load i32, i32* %P
|
||||
call i32 @func_argmemonly_two_args(i32* readonly %P2, i32* %P3)
|
||||
%V2 = load i32, i32* %P
|
||||
%Diff = sub i32 %V1, %V2
|
||||
ret i32 %Diff
|
||||
; CHECK: load
|
||||
; CHECK: load
|
||||
; CHECK: sub
|
||||
; CHECK: ret i32 %Diff
|
||||
}
|
||||
|
||||
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
|
||||
declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i32, i1) nounwind
|
||||
|
Loading…
Reference in New Issue
Block a user