mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[MemCpyOpt] Support opaque pointers
This commit is contained in:
parent
e3cd3226a4
commit
d5928b4916
@ -62,7 +62,7 @@ Type *IRBuilderBase::getCurrentFunctionReturnType() const {
|
|||||||
|
|
||||||
Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
|
Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
|
||||||
auto *PT = cast<PointerType>(Ptr->getType());
|
auto *PT = cast<PointerType>(Ptr->getType());
|
||||||
if (PT->getElementType()->isIntegerTy(8))
|
if (PT->isOpaqueOrPointeeTypeMatches(getInt8Ty()))
|
||||||
return Ptr;
|
return Ptr;
|
||||||
|
|
||||||
// Otherwise, we need to insert a bitcast.
|
// Otherwise, we need to insert a bitcast.
|
||||||
|
@ -1215,8 +1215,7 @@ bool MemCpyOptPass::processMemSetMemCpyDependence(MemCpyInst *MemCpy,
|
|||||||
Value *MemsetLen = Builder.CreateSelect(
|
Value *MemsetLen = Builder.CreateSelect(
|
||||||
Ule, ConstantInt::getNullValue(DestSize->getType()), SizeDiff);
|
Ule, ConstantInt::getNullValue(DestSize->getType()), SizeDiff);
|
||||||
Instruction *NewMemSet = Builder.CreateMemSet(
|
Instruction *NewMemSet = Builder.CreateMemSet(
|
||||||
Builder.CreateGEP(Dest->getType()->getPointerElementType(), Dest,
|
Builder.CreateGEP(Builder.getInt8Ty(), Dest, SrcSize),
|
||||||
SrcSize),
|
|
||||||
MemSet->getOperand(1), MemsetLen, MaybeAlign(Align));
|
MemSet->getOperand(1), MemsetLen, MaybeAlign(Align));
|
||||||
|
|
||||||
if (MSSAU) {
|
if (MSSAU) {
|
||||||
|
@ -291,10 +291,27 @@ define void @test_must_alias_different_size(i8* noalias %src, i64 %src_size, i8*
|
|||||||
ret void
|
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.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.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.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.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.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.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()
|
declare void @call()
|
||||||
|
Loading…
Reference in New Issue
Block a user