From 88a9f0476ccf82d705062eab6867b7d37e1e736c Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 22 Jan 2014 21:53:19 +0000 Subject: [PATCH] Handle an addrspacecast case in memcpyopt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199836 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/MemCpyOptimizer.cpp | 2 +- test/Transforms/MemCpyOpt/memcpy.ll | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 58f8dbd6e3f..ea9f57c9ff2 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -662,7 +662,7 @@ bool MemCpyOpt::performCallSlotOptzn(Instruction *cpy, while (!srcUseList.empty()) { User *UI = srcUseList.pop_back_val(); - if (isa(UI)) { + if (isa(UI) || isa(UI)) { for (User::use_iterator I = UI->use_begin(), E = UI->use_end(); I != E; ++I) srcUseList.push_back(*I); diff --git a/test/Transforms/MemCpyOpt/memcpy.ll b/test/Transforms/MemCpyOpt/memcpy.ll index 2417cd11f7f..492c453932c 100644 --- a/test/Transforms/MemCpyOpt/memcpy.ll +++ b/test/Transforms/MemCpyOpt/memcpy.ll @@ -78,6 +78,7 @@ define void @test4(i8 *%P) { declare void @test4a(i8* align 1 byval) declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind +declare void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* nocapture, i8 addrspace(1)* nocapture, i64, i32, i1) nounwind %struct.S = type { i128, [4 x i8]} @@ -152,6 +153,22 @@ declare noalias i8* @malloc(i32) ; rdar://11341081 %struct.big = type { [50 x i32] } +define void @test9_addrspacecast() nounwind ssp uwtable { +entry: +; CHECK-LABEL: @test9_addrspacecast( +; CHECK: f1 +; CHECK-NOT: memcpy +; CHECK: f2 + %b = alloca %struct.big, align 4 + %tmp = alloca %struct.big, align 4 + call void @f1(%struct.big* sret %tmp) + %0 = addrspacecast %struct.big* %b to i8 addrspace(1)* + %1 = addrspacecast %struct.big* %tmp to i8 addrspace(1)* + call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* %0, i8 addrspace(1)* %1, i64 200, i32 4, i1 false) + call void @f2(%struct.big* %b) + ret void +} + define void @test9() nounwind ssp uwtable { entry: ; CHECK: test9