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 3 4; CHECK-LABEL: @test 5define void @test() { 6 %add = add i32 1, 2 7; CHECK-NEXT: #dbg_value(i32 1, [[add:![0-9]+]], !DIExpression(DW_OP_plus_uconst, 2, DW_OP_stack_value), 8 %sub = sub i32 %add, 1 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 11 ret void 12} 13 14declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind 15declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind 16 17; CHECK-LABEL: @test_lifetime_alloca 18define 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) 27 ret i32 0 28} 29 30; CHECK-LABEL: @test_lifetime_arg 31define 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) 39 ret i32 0 40} 41 42@glob = global i8 1 43 44; CHECK-LABEL: @test_lifetime_global 45define 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) 53 ret i32 0 54} 55 56; CHECK-LABEL: @test_lifetime_bitcast 57define 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. 61; CHECK-NEXT: bitcast 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) 69 ret i32 0 70} 71 72; CHECK: [[add]] = !DILocalVariable 73; CHECK: [[sub]] = !DILocalVariable 74