summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/MemCpyOpt
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-05-23 00:03:39 +0000
committerChris Lattner <sabre@nondot.org>2011-05-23 00:03:39 +0000
commit83791ced7ba2a2d43d37bb1350f28ddf83c029f9 (patch)
tree0367ad4b2449d64911deb97fb658aa0253dc4aba /llvm/test/Transforms/MemCpyOpt
parent4d37d9979857744d6bf306e8d90abb07209fea49 (diff)
downloadbcm5719-llvm-83791ced7ba2a2d43d37bb1350f28ddf83c029f9.tar.gz
bcm5719-llvm-83791ced7ba2a2d43d37bb1350f28ddf83c029f9.zip
Teach valuetracking that byval arguments with a specified alignment are
aligned. Teach memcpyopt to not give up all hope when confonted with an underaligned memcpy feeding an overaligned byval. If the *source* of the memcpy can be determined to be adequeately aligned, or if it can be forced to be, we can eliminate the memcpy. This addresses PR9794. We now compile the example into: define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp { entry: %call = call i32 @g(%struct.p* byval align 8 %q) nounwind ret i32 %call } in both x86-64 and x86-32 mode. We still don't get a tailcall though, because tailcalls apparently can't handle byval. llvm-svn: 131884
Diffstat (limited to 'llvm/test/Transforms/MemCpyOpt')
-rw-r--r--llvm/test/Transforms/MemCpyOpt/memcpy.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy.ll b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
index b387d32a7d5..5c6a94ce5c9 100644
--- a/llvm/test/Transforms/MemCpyOpt/memcpy.ll
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
@@ -109,3 +109,23 @@ define void @test6(i8 *%P) {
; CHECK-NEXT: ret void
}
+
+; PR9794 - Should forward memcpy into byval argument even though the memcpy
+; isn't itself 8 byte aligned.
+%struct.p = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
+
+define i32 @test7(%struct.p* nocapture byval align 8 %q) nounwind ssp {
+entry:
+ %agg.tmp = alloca %struct.p, align 4
+ %tmp = bitcast %struct.p* %agg.tmp to i8*
+ %tmp1 = bitcast %struct.p* %q to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* %tmp1, i64 48, i32 4, i1 false)
+ %call = call i32 @g(%struct.p* byval align 8 %agg.tmp) nounwind
+ ret i32 %call
+; CHECK: @test7
+; CHECK: call i32 @g(%struct.p* byval align 8 %q) nounwind
+}
+
+declare i32 @g(%struct.p* byval align 8)
+
+
OpenPOWER on IntegriCloud