summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-05-22 05:22:10 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-05-22 05:22:10 +0000
commit6d55f2269e20298a1d6a683be72d9552482156a9 (patch)
tree120cf5335e916d8079373f6d62d6b00cd71f2fbc /test/Transforms
parent9063b55f9b51850fa5f77abc699ab53ec639d9be (diff)
downloadllvm-6d55f2269e20298a1d6a683be72d9552482156a9.tar.gz
llvm-6d55f2269e20298a1d6a683be72d9552482156a9.tar.bz2
llvm-6d55f2269e20298a1d6a683be72d9552482156a9.tar.xz
Teach the inliner to emit llvm.lifetime.start/end, to scope the local variables
of the inlinee to the code representing the original function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/Inline/lifetime.ll78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/Transforms/Inline/lifetime.ll b/test/Transforms/Inline/lifetime.ll
new file mode 100644
index 0000000000..a95c836b77
--- /dev/null
+++ b/test/Transforms/Inline/lifetime.ll
@@ -0,0 +1,78 @@
+; RUN: opt -inline %s -S -o - | FileCheck %s
+
+declare void @llvm.lifetime.start(i64, i8*)
+declare void @llvm.lifetime.end(i64, i8*)
+
+define void @helper_both_markers() {
+ %a = alloca i8
+ call void @llvm.lifetime.start(i64 1, i8* %a)
+ call void @llvm.lifetime.end(i64 1, i8* %a)
+ ret void
+}
+
+define void @test_both_markers() {
+; CHECK: @test_both_markers
+; CHECK: llvm.lifetime.start(i64 1
+; CHECK-NEXT: llvm.lifetime.end(i64 1
+ call void @helper_both_markers()
+; CHECK-NEXT: llvm.lifetime.start(i64 1
+; CHECK-NEXT: llvm.lifetime.end(i64 1
+ call void @helper_both_markers()
+; CHECK-NEXT: ret void
+ ret void
+}
+
+;; Without this, the inliner will simplify out @test_no_marker before adding
+;; any lifetime markers.
+declare void @use(i8* %a)
+
+define void @helper_no_markers() {
+ %a = alloca i8
+ call void @use(i8* %a)
+ ret void
+}
+
+;; We can't use CHECK-NEXT because there's an extra call void @use in between.
+;; Instead, we use CHECK-NOT to verify that there are no other lifetime calls.
+define void @test_no_marker() {
+; CHECK: @test_no_marker
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.start(i64 -1
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.end(i64 -1
+ call void @helper_no_markers()
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.start(i64 -1
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.end(i64 -1
+ call void @helper_no_markers()
+; CHECK-NOT: lifetime
+; CHECK: ret void
+ ret void
+}
+
+define void @helper_two_casts() {
+ %a = alloca i32
+ %b = bitcast i32* %a to i8*
+ call void @llvm.lifetime.start(i64 4, i8* %b)
+ %c = bitcast i32* %a to i8*
+ call void @llvm.lifetime.end(i64 4, i8* %c)
+ ret void
+}
+
+define void @test_two_casts() {
+; CHECK: @test_two_casts
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.start(i64 4
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.end(i64 4
+ call void @helper_two_casts()
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.start(i64 4
+; CHECK-NOT: lifetime
+; CHECK: llvm.lifetime.end(i64 4
+ call void @helper_two_casts()
+; CHECK-NOT: lifetime
+; CHECK: ret void
+ ret void
+}