summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-11-30 22:10:53 +0000
committerDan Gohman <dan433584@gmail.com>2017-11-30 22:10:53 +0000
commit59e4c0b9381e9402d4987a5e5e5dec8424fbc4c6 (patch)
tree43584c78a2af8282b29cf8d065c5a90a638b7350 /llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
parent9d939c8f19854b94c99c37365d6c567deb4acc95 (diff)
downloadbcm5719-llvm-59e4c0b9381e9402d4987a5e5e5dec8424fbc4c6.tar.gz
bcm5719-llvm-59e4c0b9381e9402d4987a5e5e5dec8424fbc4c6.zip
[memcpyopt] Teach memcpyopt to optimize across basic blocks
This teaches memcpyopt to make a non-local memdep query when a local query indicates that the dependency is non-local. This notably allows it to eliminate many more llvm.memcpy calls in common Rust code, often by 20-30%. Fixes PR28958. Differential Revision: https://reviews.llvm.org/D38374 llvm-svn: 319482
Diffstat (limited to 'llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll')
-rw-r--r--llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll b/llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
new file mode 100644
index 00000000000..e3d1f6dd2b1
--- /dev/null
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
@@ -0,0 +1,48 @@
+; RUN: opt < %s -memcpyopt -S | FileCheck %s
+; Test memcpy-memcpy dependencies across invoke edges.
+
+; Test that memcpyopt works across the non-unwind edge of an invoke.
+
+define hidden void @test_normal(i8* noalias %dst, i8* %src) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ %temp = alloca i8, i32 64
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %temp, i8* nonnull %src, i64 64, i32 8, i1 false)
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %temp, i8* nonnull %src, i64 64, i32 8, i1 false)
+ invoke void @invoke_me()
+ to label %try.cont unwind label %lpad
+
+lpad:
+ landingpad { i8*, i32 }
+ catch i8* null
+ ret void
+
+try.cont:
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %temp, i64 64, i32 8, i1 false)
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 64, i32 8, i1 false)
+ ret void
+}
+
+; Test that memcpyopt works across the unwind edge of an invoke.
+
+define hidden void @test_unwind(i8* noalias %dst, i8* %src) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ %temp = alloca i8, i32 64
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %temp, i8* nonnull %src, i64 64, i32 8, i1 false)
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %temp, i8* nonnull %src, i64 64, i32 8, i1 false)
+ invoke void @invoke_me()
+ to label %try.cont unwind label %lpad
+
+lpad:
+ landingpad { i8*, i32 }
+ catch i8* null
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %temp, i64 64, i32 8, i1 false)
+; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 64, i32 8, i1 false)
+ ret void
+
+try.cont:
+ ret void
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1)
+declare i32 @__gxx_personality_v0(...)
+declare void @invoke_me() readnone
OpenPOWER on IntegriCloud