1 ; RUN: opt -passes='module(debugify),function(dce)' -S < %s | FileCheck %s
2 ; RUN: opt -passes='module(debugify),function(dce)' -S < %s --try-experimental-debuginfo-iterators | FileCheck %s
7 ; CHECK-NEXT: #dbg_value(i32 1, [[add:![0-9]+]], !DIExpression(DW_OP_plus_uconst, 2, DW_OP_stack_value),
9 ; CHECK-NEXT: #dbg_value(i32 1, [[sub:![0-9]+]], !DIExpression(DW_OP_plus_uconst, 2, DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value),
10 ; CHECK-NEXT: ret void
14 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
15 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind
17 ; CHECK-LABEL: @test_lifetime_alloca
18 define i32 @test_lifetime_alloca() {
19 ; Check that lifetime intrinsics are removed along with the pointer.
20 ; CHECK-NEXT: #dbg_value
21 ; CHECK-NEXT: ret i32 0
22 ; CHECK-NOT: llvm.lifetime.start
23 ; CHECK-NOT: llvm.lifetime.end
24 %i = alloca i8, align 4
25 call void @llvm.lifetime.start.p0(i64 -1, ptr %i)
26 call void @llvm.lifetime.end.p0(i64 -1, ptr %i)
30 ; CHECK-LABEL: @test_lifetime_arg
31 define i32 @test_lifetime_arg(ptr) {
32 ; Check that lifetime intrinsics are removed along with the pointer.
33 ; CHECK-NEXT: #dbg_value
34 ; CHECK-NEXT: ret i32 0
35 ; CHECK-NOT: llvm.lifetime.start
36 ; CHECK-NOT: llvm.lifetime.end
37 call void @llvm.lifetime.start.p0(i64 -1, ptr %0)
38 call void @llvm.lifetime.end.p0(i64 -1, ptr %0)
44 ; CHECK-LABEL: @test_lifetime_global
45 define i32 @test_lifetime_global() {
46 ; Check that lifetime intrinsics are removed along with the pointer.
47 ; CHECK-NEXT: #dbg_value
48 ; CHECK-NEXT: ret i32 0
49 ; CHECK-NOT: llvm.lifetime.start
50 ; CHECK-NOT: llvm.lifetime.end
51 call void @llvm.lifetime.start.p0(i64 -1, ptr @glob)
52 call void @llvm.lifetime.end.p0(i64 -1, ptr @glob)
56 ; CHECK-LABEL: @test_lifetime_bitcast
57 define i32 @test_lifetime_bitcast(ptr %arg) {
58 ; Check that lifetime intrinsics are NOT removed when the pointer is a bitcast.
59 ; It's not uncommon for two bitcasts to be made: one for lifetime, one for use.
60 ; TODO: Support the above case.
62 ; CHECK-NEXT: #dbg_value
63 ; CHECK-NEXT: llvm.lifetime.start.p0(i64 -1, ptr %cast)
64 ; CHECK-NEXT: llvm.lifetime.end.p0(i64 -1, ptr %cast)
65 ; CHECK-NEXT: ret i32 0
66 %cast = bitcast ptr %arg to ptr
67 call void @llvm.lifetime.start.p0(i64 -1, ptr %cast)
68 call void @llvm.lifetime.end.p0(i64 -1, ptr %cast)
72 ; CHECK: [[add]] = !DILocalVariable
73 ; CHECK: [[sub]] = !DILocalVariable