diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-11-13 07:15:32 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-11-13 07:15:32 +0000 |
commit | 009c4d86c14bb2f46f9473f8f517393dabab7e9e (patch) | |
tree | 810ca2837213a813032ff52c28ef5fb0cefbcfef /test/Transforms | |
parent | 266c473b91a7a204b9d0de7f1461fe8ca8bd7117 (diff) | |
download | external_llvm-009c4d86c14bb2f46f9473f8f517393dabab7e9e.zip external_llvm-009c4d86c14bb2f46f9473f8f517393dabab7e9e.tar.gz external_llvm-009c4d86c14bb2f46f9473f8f517393dabab7e9e.tar.bz2 |
Figure out <size> argument of llvm.lifetime intrinsics at the moment they are created (during function inlining)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/Inline/lifetime-no-datalayout.ll | 23 | ||||
-rw-r--r-- | test/Transforms/Inline/lifetime.ll | 44 |
2 files changed, 56 insertions, 11 deletions
diff --git a/test/Transforms/Inline/lifetime-no-datalayout.ll b/test/Transforms/Inline/lifetime-no-datalayout.ll new file mode 100644 index 0000000..9ad1428 --- /dev/null +++ b/test/Transforms/Inline/lifetime-no-datalayout.ll @@ -0,0 +1,23 @@ +; RUN: opt -inline %s -S -o - | FileCheck %s + +declare void @use(i8* %a) + +define void @helper() { + %a = alloca i8 + call void @use(i8* %a) + ret void +} + +; Size in llvm.lifetime.X should be -1 (unknown). +define void @test() { +; CHECK: @test +; CHECK-NOT: lifetime +; CHECK: llvm.lifetime.start(i64 -1 +; CHECK-NOT: lifetime +; CHECK: llvm.lifetime.end(i64 -1 + call void @helper() +; CHECK-NOT: lifetime +; CHECK: ret void + ret void +} + diff --git a/test/Transforms/Inline/lifetime.ll b/test/Transforms/Inline/lifetime.ll index a95c836..fb52049 100644 --- a/test/Transforms/Inline/lifetime.ll +++ b/test/Transforms/Inline/lifetime.ll @@ -1,22 +1,25 @@ ; RUN: opt -inline %s -S -o - | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 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) + ; Size in llvm.lifetime.start / llvm.lifetime.end differs from + ; allocation size. We should use the former. + call void @llvm.lifetime.start(i64 2, i8* %a) + call void @llvm.lifetime.end(i64 2, 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 +; CHECK: llvm.lifetime.start(i64 2 +; CHECK-NEXT: llvm.lifetime.end(i64 2 call void @helper_both_markers() -; CHECK-NEXT: llvm.lifetime.start(i64 1 -; CHECK-NEXT: llvm.lifetime.end(i64 1 +; CHECK-NEXT: llvm.lifetime.start(i64 2 +; CHECK-NEXT: llvm.lifetime.end(i64 2 call void @helper_both_markers() ; CHECK-NEXT: ret void ret void @@ -27,7 +30,7 @@ define void @test_both_markers() { declare void @use(i8* %a) define void @helper_no_markers() { - %a = alloca i8 + %a = alloca i8 ; Allocation size is 1 byte. call void @use(i8* %a) ret void } @@ -37,14 +40,14 @@ define void @helper_no_markers() { define void @test_no_marker() { ; CHECK: @test_no_marker ; CHECK-NOT: lifetime -; CHECK: llvm.lifetime.start(i64 -1 +; CHECK: llvm.lifetime.start(i64 1 ; CHECK-NOT: lifetime -; CHECK: llvm.lifetime.end(i64 -1 +; CHECK: llvm.lifetime.end(i64 1 call void @helper_no_markers() ; CHECK-NOT: lifetime -; CHECK: llvm.lifetime.start(i64 -1 +; CHECK: llvm.lifetime.start(i64 1 ; CHECK-NOT: lifetime -; CHECK: llvm.lifetime.end(i64 -1 +; CHECK: llvm.lifetime.end(i64 1 call void @helper_no_markers() ; CHECK-NOT: lifetime ; CHECK: ret void @@ -76,3 +79,22 @@ define void @test_two_casts() { ; CHECK: ret void ret void } + +define void @helper_arrays_alloca() { + %a = alloca [10 x i32], align 16 + %1 = bitcast [10 x i32]* %a to i8* + call void @use(i8* %1) + ret void +} + +define void @test_arrays_alloca() { +; CHECK: @test_arrays_alloca +; CHECK-NOT: lifetime +; CHECK: llvm.lifetime.start(i64 40, +; CHECK-NOT: lifetime +; CHECK: llvm.lifetime.end(i64 40, + call void @helper_arrays_alloca() +; CHECK-NOT: lifetime +; CHECK: ret void + ret void +} |