[PATCH] D138613: [MemoryLocation] Support memcpy_chk in getForArgument.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 24 11:18:12 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae852750b34a: [MemoryLocation] Support memcpy_chk in getForArgument. (authored by fhahn).
Changed prior to commit:
https://reviews.llvm.org/D138613?vs=477609&id=477825#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138613/new/
https://reviews.llvm.org/D138613
Files:
llvm/lib/Analysis/MemoryLocation.cpp
llvm/test/Analysis/BasicAA/libfuncs.ll
Index: llvm/test/Analysis/BasicAA/libfuncs.ll
===================================================================
--- llvm/test/Analysis/BasicAA/libfuncs.ll
+++ llvm/test/Analysis/BasicAA/libfuncs.ll
@@ -323,9 +323,9 @@
; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
-; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
+; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
-; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
+; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @__memcpy_chk(i8* %a, i8* %b, i64 4, i64 %n)
;
entry:
load i8, i8* %a
Index: llvm/lib/Analysis/MemoryLocation.cpp
===================================================================
--- llvm/lib/Analysis/MemoryLocation.cpp
+++ llvm/lib/Analysis/MemoryLocation.cpp
@@ -253,12 +253,17 @@
assert((ArgIdx == 0 || ArgIdx == 1) && "Invalid argument index for str function");
return MemoryLocation::getAfter(Arg, AATags);
- case LibFunc_memset_chk: {
+ case LibFunc_memset_chk:
assert(ArgIdx == 0 && "Invalid argument index for memset_chk");
+ LLVM_FALLTHROUGH;
+ case LibFunc_memcpy_chk: {
+ assert((ArgIdx == 0 || ArgIdx == 1) &&
+ "Invalid argument index for memcpy_chk");
LocationSize Size = LocationSize::afterPointer();
if (const auto *Len = dyn_cast<ConstantInt>(Call->getArgOperand(2))) {
- // memset_chk writes at most Len bytes. It may write less, if Len
- // exceeds the specified max size and aborts.
+ // memset_chk writes at most Len bytes, memcpy_chk reads/writes at most
+ // Len bytes. They may read/write less, if Len exceeds the specified max
+ // size and aborts.
Size = LocationSize::upperBound(Len->getZExtValue());
}
return MemoryLocation(Arg, Size, AATags);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138613.477825.patch
Type: text/x-patch
Size: 2399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221124/d5777485/attachment.bin>
More information about the llvm-commits
mailing list