diff --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp --- a/llvm/lib/Analysis/MemoryLocation.cpp +++ b/llvm/lib/Analysis/MemoryLocation.cpp @@ -271,10 +271,18 @@ 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(Call->getArgOperand(2))) return MemoryLocation(Arg, LocationSize::precise(LenCI->getZExtValue()), @@ -309,7 +317,6 @@ 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 --- a/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll +++ b/llvm/test/Analysis/BasicAA/libfuncs-darwin.ll @@ -9,9 +9,9 @@ ; 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 @@ ; 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)