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