mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-17 11:39:11 +00:00
MemCpyOptimizer: don't create new addrspace casts
This isn't safe on all targets, and since we don't have a way to know it's safe, avoid doing it for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297788 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dfb7eaee7b
commit
54dc1ed088
@ -932,6 +932,17 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpy, Value *cpyDest,
|
||||
if (MR != MRI_NoModRef)
|
||||
return false;
|
||||
|
||||
// We can't create address space casts here because we don't know if they're
|
||||
// safe for the target.
|
||||
if (cpySrc->getType()->getPointerAddressSpace() !=
|
||||
cpyDest->getType()->getPointerAddressSpace())
|
||||
return false;
|
||||
for (unsigned i = 0; i < CS.arg_size(); ++i)
|
||||
if (CS.getArgument(i)->stripPointerCasts() == cpySrc &&
|
||||
cpySrc->getType()->getPointerAddressSpace() !=
|
||||
CS.getArgument(i)->getType()->getPointerAddressSpace())
|
||||
return false;
|
||||
|
||||
// All the checks have passed, so do the transformation.
|
||||
bool changedArgument = false;
|
||||
for (unsigned i = 0; i < CS.arg_size(); ++i)
|
||||
|
@ -202,6 +202,21 @@ define void @test10(%opaque* noalias nocapture sret %x, i32 %y) {
|
||||
ret void
|
||||
}
|
||||
|
||||
; don't create new addressspacecasts when we don't know they're safe for the target
|
||||
define void @test11([20 x i32] addrspace(1)* nocapture dereferenceable(80) %P) {
|
||||
%A = alloca [20 x i32], align 4
|
||||
%a = bitcast [20 x i32]* %A to i8*
|
||||
%b = bitcast [20 x i32] addrspace(1)* %P to i8 addrspace(1)*
|
||||
call void @llvm.memset.p0i8.i64(i8* %a, i8 0, i64 80, i32 4, i1 false)
|
||||
call void @llvm.memcpy.p1i8.p0i8.i64(i8 addrspace(1)* %b, i8* %a, i64 80, i32 4, i1 false)
|
||||
ret void
|
||||
; CHECK-LABEL: @test11(
|
||||
; CHECK-NOT: addrspacecast
|
||||
}
|
||||
|
||||
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
|
||||
declare void @llvm.memcpy.p1i8.p0i8.i64(i8 addrspace(1)* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
||||
|
||||
declare void @f1(%struct.big* nocapture sret)
|
||||
declare void @f2(%struct.big*)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user