Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/MemoryLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ MemoryLocation MemoryLocation::getForArgument(const CallBase *Call,
case Intrinsic::experimental_memset_pattern:
assert((ArgIdx == 0 || ArgIdx == 1) &&
"Invalid argument index for memory intrinsic");
if (ArgIdx == 1) {
assert(Arg->getType()->isPointerTy());
return MemoryLocation(Arg, LocationSize::precise(0), AATags);
}
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getArgOperand(2)))
return MemoryLocation(
Arg,
Expand Down
7 changes: 2 additions & 5 deletions llvm/test/Transforms/GVN/memset-pattern.ll
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ define i32 @load_forward_over_memset_pattern(ptr %P, ptr noalias %Q) {

define i32 @load_forward_over_memset_pattern2(ptr %P, ptr noalias %Q) nounwind ssp {
; CHECK-LABEL: @load_forward_over_memset_pattern2(
; CHECK-NEXT: [[V1:%.*]] = load i32, ptr [[Q:%.*]], align 4
; CHECK-NEXT: tail call void @llvm.experimental.memset.pattern.p0.p0.i64(ptr [[P:%.*]], ptr [[Q]], i64 8, i1 false)
; CHECK-NEXT: [[V2:%.*]] = load i32, ptr [[Q]], align 4
; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[V1]], [[V2]]
; CHECK-NEXT: ret i32 [[SUB]]
; CHECK-NEXT: tail call void @llvm.experimental.memset.pattern.p0.p0.i64(ptr [[P:%.*]], ptr [[Q:%.*]], i64 8, i1 false)
; CHECK-NEXT: ret i32 0
;
%v1 = load i32, ptr %Q
tail call void @llvm.experimental.memset.pattern(ptr %P, ptr %Q, i64 8, i1 false)
Expand Down