[llvm] 81fcdae - [MemCpyOpt] Support opaque pointers
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 12:51:29 PDT 2021
Ah, I see there's been a fair few of these smaller changes without
pre-commit review. No worries - I'll keep an eye out for them for
post-commit review. Thanks!
On Mon, Jun 28, 2021 at 11:57 AM David Blaikie <dblaikie at gmail.com> wrote:
> If this came from a phab review - please make sure to include that in the
> commit message (& in cases where it's missed, could you follow-up with an
> email reply to the commit to link to the review).
>
> On Sun, Jun 27, 2021 at 6:53 AM Nikita Popov via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>>
>> Author: Nikita Popov
>> Date: 2021-06-27T15:52:38+02:00
>> New Revision: 81fcdae68c5ff656c30032fd26c6a21af4c51dbb
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/81fcdae68c5ff656c30032fd26c6a21af4c51dbb
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/81fcdae68c5ff656c30032fd26c6a21af4c51dbb.diff
>>
>> LOG: [MemCpyOpt] Support opaque pointers
>>
>> Added:
>>
>>
>> Modified:
>> llvm/lib/IR/IRBuilder.cpp
>> llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>> llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
>>
>> Removed:
>>
>>
>>
>>
>> ################################################################################
>> diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
>> index ca6577330c8ee..3c55b7395864a 100644
>> --- a/llvm/lib/IR/IRBuilder.cpp
>> +++ b/llvm/lib/IR/IRBuilder.cpp
>> @@ -62,7 +62,7 @@ Type *IRBuilderBase::getCurrentFunctionReturnType()
>> const {
>>
>> Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
>> auto *PT = cast<PointerType>(Ptr->getType());
>> - if (PT->getElementType()->isIntegerTy(8))
>> + if (PT->isOpaqueOrPointeeTypeMatches(getInt8Ty()))
>> return Ptr;
>>
>> // Otherwise, we need to insert a bitcast.
>>
>> diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>> b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>> index db8d40b2bafaf..6016779ef3cfa 100644
>> --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>> +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
>> @@ -1215,8 +1215,7 @@ bool
>> MemCpyOptPass::processMemSetMemCpyDependence(MemCpyInst *MemCpy,
>> Value *MemsetLen = Builder.CreateSelect(
>> Ule, ConstantInt::getNullValue(DestSize->getType()), SizeDiff);
>> Instruction *NewMemSet = Builder.CreateMemSet(
>> - Builder.CreateGEP(Dest->getType()->getPointerElementType(), Dest,
>> - SrcSize),
>> + Builder.CreateGEP(Builder.getInt8Ty(), Dest, SrcSize),
>> MemSet->getOperand(1), MemsetLen, MaybeAlign(Align));
>>
>> if (MSSAU) {
>>
>> diff --git
>> a/llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
>> b/llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
>> index 10ec8b46dbd27..987321607b3db 100644
>> --- a/llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
>> +++ b/llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
>> @@ -291,10 +291,27 @@ define void @test_must_alias_
>> diff erent_size(i8* noalias %src, i64 %src_size, i8*
>> ret void
>> }
>>
>> +define void @test_opaque_ptrs(ptr %src, i64 %src_size, ptr noalias %dst,
>> i64 %dst_size, i8 %c) {
>> +; CHECK-LABEL: @test_opaque_ptrs(
>> +; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i64 [[DST_SIZE:%.*]],
>> [[SRC_SIZE:%.*]]
>> +; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[DST_SIZE]], [[SRC_SIZE]]
>> +; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i64 0, i64 [[TMP2]]
>> +; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i8, ptr [[DST:%.*]], i64
>> [[SRC_SIZE]]
>> +; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[TMP4]], i8
>> [[C:%.*]], i64 [[TMP3]], i1 false)
>> +; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr
>> [[SRC:%.*]], i64 [[SRC_SIZE]], i1 false)
>> +; CHECK-NEXT: ret void
>> +;
>> + call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false)
>> + call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1
>> false)
>> + ret void
>> +}
>> +
>> declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1)
>> declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture
>> readonly, i64, i1)
>> declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1)
>> declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture
>> readonly, i32, i1)
>> declare void @llvm.memset.p0i8.i128(i8* nocapture, i8, i128, i1)
>> declare void @llvm.memcpy.p0i8.p0i8.i128(i8* nocapture, i8* nocapture
>> readonly, i128, i1)
>> +declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1)
>> +declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture
>> readonly, i64, i1)
>> declare void @call()
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/f3eca59e/attachment-0001.html>
More information about the llvm-commits
mailing list