[llvm] 3c55acc - [MemoryLocation] Support memset_pattern{4,8} in getForArgument.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 8 11:40:03 PST 2021
Author: Florian Hahn
Date: 2021-12-08T19:39:45Z
New Revision: 3c55acc4a6205481b1546bea768de52953cd3ad7
URL: https://github.com/llvm/llvm-project/commit/3c55acc4a6205481b1546bea768de52953cd3ad7
DIFF: https://github.com/llvm/llvm-project/commit/3c55acc4a6205481b1546bea768de52953cd3ad7.diff
LOG: [MemoryLocation] Support memset_pattern{4,8} in getForArgument.
memset_pattern{4,8} behave as memset_pattern16, with the only difference
being the size of the pattern location.
Reviewed By: ab
Differential Revision: https://reviews.llvm.org/D114905
Added:
Modified:
llvm/lib/Analysis/MemoryLocation.cpp
llvm/test/Analysis/BasicAA/libfuncs-darwin.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp
index 93b5f6e9871c4..c74b6258f780e 100644
--- a/llvm/lib/Analysis/MemoryLocation.cpp
+++ b/llvm/lib/Analysis/MemoryLocation.cpp
@@ -271,10 +271,18 @@ MemoryLocation MemoryLocation::getForArgument(const CallBase *Call,
return MemoryLocation(Arg, Size, AATags);
}
case LibFunc_memset_pattern16:
+ case LibFunc_memset_pattern4:
+ case LibFunc_memset_pattern8:
assert((ArgIdx == 0 || ArgIdx == 1) &&
"Invalid argument index for memset_pattern16");
- if (ArgIdx == 1)
- return MemoryLocation(Arg, LocationSize::precise(16), AATags);
+ if (ArgIdx == 1) {
+ unsigned Size = 16;
+ if (F == LibFunc_memset_pattern4)
+ Size = 4;
+ else if (F == LibFunc_memset_pattern8)
+ Size = 8;
+ return MemoryLocation(Arg, LocationSize::precise(Size), AATags);
+ }
if (const ConstantInt *LenCI =
dyn_cast<ConstantInt>(Call->getArgOperand(2)))
return MemoryLocation(Arg, LocationSize::precise(LenCI->getZExtValue()),
@@ -309,7 +317,6 @@ MemoryLocation MemoryLocation::getForArgument(const CallBase *Call,
break;
};
}
- // FIXME: Handle memset_pattern4 and memset_pattern8 also.
return MemoryLocation::getBeforeOrAfter(Call->getArgOperand(ArgIdx), AATags);
}
diff --git a/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll b/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll
index 0ae358eb2f508..e2f43eb9f6417 100644
--- a/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll
+++ b/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll
@@ -9,9 +9,9 @@ define void @test_memset_pattern4_const_size(i8* noalias %a, i8* noalias %patter
; CHECK: Just Mod: Ptr: i8* %a <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Ref: Ptr: i8* %pattern <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
-; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.17 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
+; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.17 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Ref: Ptr: i8* %pattern.gep.3 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
-; CHECK-NEXT: Just Ref: Ptr: i8* %pattern.gep.4 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
+; CHECK-NEXT: NoModRef: Ptr: i8* %pattern.gep.4 <-> call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
;
entry:
call void @memset_pattern4(i8* %a, i8* %pattern, i64 17)
@@ -48,9 +48,9 @@ define void @test_memset_pattern8_const_size(i8* noalias %a, i8* noalias %patter
; CHECK: Just Mod: Ptr: i8* %a <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Ref: Ptr: i8* %pattern <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
-; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.17 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
+; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.17 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
; CHECK-NEXT: Just Ref: Ptr: i8* %pattern.gep.7 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
-; CHECK-NEXT: Just Ref: Ptr: i8* %pattern.gep.8 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
+; CHECK-NEXT: NoModRef: Ptr: i8* %pattern.gep.8 <-> call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
;
entry:
call void @memset_pattern8(i8* %a, i8* %pattern, i64 17)
More information about the llvm-commits
mailing list