1; RUN: opt %s --passes=inline -o - -S | FileCheck %s --implicit-check-not=dbg.value 2; RUN: opt %s --passes=inline -o - -S --try-experimental-debuginfo-iterators | FileCheck %s --implicit-check-not=dbg.value 3 4;; The inliner, specially, hoists all alloca instructions into the entry block 5;; of the calling function. Ensure that it doesn't accidentally transfer the 6;; dbg.value intrinsic from after the alloca to somewhere else. There should be 7;; one dbg.value in the resulting block after the call to ext, and before the 8;; call to init. 9;; 10;; This becomes significant in the context of non-instruction debug-info. When 11;; splicing segments of instructions around, it's typically the range from one 12;; "real" instruction to another, implicitly including all the dbg.values that 13;; come before the ending instruction. The inliner is a (unique!) location in 14;; LLVM that builds a range of only a single instruction kind (allocas) and thus 15;; doesn't transfer the dbg.value to the entry block. This needs Special 16;; Handling once we get rid of debug-intrinsics. 17 18; CHECK: define i32 @bar() 19; CHECK-NEXT: %1 = alloca [65 x i32], align 16 20; CHECK-NEXT: call void @ext() 21; CHECK-NEXT: call void @llvm.lifetime.start.p0( 22; CHECK-NEXT: #dbg_value(i32 0, !10, !DIExpression(), !12 23; CHECK-NEXT: call void @init(ptr %1) 24 25 26declare void @ext() 27declare void @init(ptr) 28 29define internal i32 @foo() !dbg !4 { 30 %1 = alloca [65 x i32], align 16 31 call void @llvm.dbg.value(metadata i32 0, metadata !11, metadata !DIExpression()), !dbg !14 32 call void @init(ptr %1) 33 %2 = load i32, ptr %1, align 4 34 ret i32 %2 35} 36 37define i32 @bar() !dbg !16 { 38 call void @ext() 39 %1 = call i32 @foo(), !dbg !17 40 ret i32 %1 41} 42 43declare void @llvm.dbg.value(metadata, metadata, metadata) 44 45!llvm.dbg.cu = !{!0} 46!llvm.module.flags = !{!8, !9} 47!llvm.ident = !{!10} 48 49!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 50!1 = !DIFile(filename: "a.cc", directory: "/tmp") 51!2 = !{} 52!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 53!5 = !DISubroutineType(types: !6) 54!6 = !{null, !7} 55!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 56!8 = !{i32 2, !"Dwarf Version", i32 4} 57!9 = !{i32 2, !"Debug Info Version", i32 3} 58!10 = !{!"clang"} 59!11 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 3, type: !7) 60!12 = !DIExpression() 61!14 = !DILocation(line: 4, column: 7, scope: !15) 62!15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 7) 63!16 = distinct !DISubprogram(name: "bar", linkageName: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 64!17 = !DILocation(line: 4, column: 7, scope: !16) 65