File: lifetime.ll

package info (click to toggle)
llvm-3.0 3.0-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 75,412 kB
  • sloc: cpp: 468,043; asm: 109,345; ansic: 13,782; sh: 12,935; ml: 4,716; python: 4,351; perl: 2,096; makefile: 1,905; pascal: 1,578; exp: 389; xml: 283; lisp: 187; csh: 117
file content (78 lines) | stat: -rw-r--r-- 2,017 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
}