2012-12-30 01:28:40 +00:00
|
|
|
; RUN: opt -inline -S < %s | FileCheck %s
|
2012-11-13 07:15:32 +00:00
|
|
|
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"
|
2011-05-22 05:22:10 +00:00
|
|
|
|
|
|
|
declare void @llvm.lifetime.start(i64, i8*)
|
|
|
|
declare void @llvm.lifetime.end(i64, i8*)
|
|
|
|
|
|
|
|
define void @helper_both_markers() {
|
|
|
|
%a = alloca i8
|
2012-11-13 07:15:32 +00:00
|
|
|
; 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)
|
2011-05-22 05:22:10 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_both_markers() {
|
|
|
|
; CHECK: @test_both_markers
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK: llvm.lifetime.start(i64 2
|
|
|
|
; CHECK-NEXT: llvm.lifetime.end(i64 2
|
2011-05-22 05:22:10 +00:00
|
|
|
call void @helper_both_markers()
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK-NEXT: llvm.lifetime.start(i64 2
|
|
|
|
; CHECK-NEXT: llvm.lifetime.end(i64 2
|
2011-05-22 05:22:10 +00:00
|
|
|
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() {
|
2012-11-13 07:15:32 +00:00
|
|
|
%a = alloca i8 ; Allocation size is 1 byte.
|
2011-05-22 05:22:10 +00:00
|
|
|
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
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK: llvm.lifetime.start(i64 1
|
2011-05-22 05:22:10 +00:00
|
|
|
; CHECK-NOT: lifetime
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK: llvm.lifetime.end(i64 1
|
2011-05-22 05:22:10 +00:00
|
|
|
call void @helper_no_markers()
|
|
|
|
; CHECK-NOT: lifetime
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK: llvm.lifetime.start(i64 1
|
2011-05-22 05:22:10 +00:00
|
|
|
; CHECK-NOT: lifetime
|
2012-11-13 07:15:32 +00:00
|
|
|
; CHECK: llvm.lifetime.end(i64 1
|
2011-05-22 05:22:10 +00:00
|
|
|
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
|
|
|
|
}
|
2012-11-13 07:15:32 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|