llvm.org GIT mirror llvm / eba2561
Merging r299866: ------------------------------------------------------------------------ r299866 | arsenm | 2017-04-10 15:00:25 -0400 (Mon, 10 Apr 2017) | 3 lines [MemCpyOpt] Only replace memcpy with bitcast if address spaces match Patch by James Price ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@303657 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
2 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
13051305 CS.getInstruction(), &AC, &DT) < ByValAlign)
13061306 return false;
13071307
1308 // The address space of the memcpy source must match the byval argument
1309 if (MDep->getSource()->getType()->getPointerAddressSpace() !=
1310 ByValArg->getType()->getPointerAddressSpace())
1311 return false;
1312
13081313 // Verify that the copied-from memory doesn't change in between the memcpy and
13091314 // the byval call.
13101315 // memcpy(a <- b)
7575 ; CHECK-NEXT: call void @test4a(
7676 }
7777
78 ; Make sure we don't remove the memcpy if the source address space doesn't match the byval argument
79 define void @test4_addrspace(i8 addrspace(1)* %P) {
80 %A = alloca %1
81 %a = bitcast %1* %A to i8*
82 call void @llvm.memcpy.p0i8.p1i8.i64(i8* %a, i8 addrspace(1)* %P, i64 8, i32 4, i1 false)
83 call void @test4a(i8* align 1 byval %a)
84 ret void
85 ; CHECK-LABEL: @test4_addrspace(
86 ; CHECK: call void @llvm.memcpy.p0i8.p1i8.i64(
87 ; CHECK-NEXT: call void @test4a(
88 }
89
7890 declare void @test4a(i8* align 1 byval)
7991 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
92 declare void @llvm.memcpy.p0i8.p1i8.i64(i8* nocapture, i8 addrspace(1)* nocapture, i64, i32, i1) nounwind
8093 declare void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* nocapture, i8 addrspace(1)* nocapture, i64, i32, i1) nounwind
8194
8295 %struct.S = type { i128, [4 x i8]}