1; RUN: opt < %s -passes=inline -S | FileCheck %s 2; RUN: opt < %s -passes=inline -S --try-experimental-debuginfo-iterators | FileCheck %s 3 4; This tests that functions with the attribute `no-inline-line-tables` have the 5; correct debug information when they are inlined. 6 7; ModuleID = 't.c' 8source_filename = "t.c" 9target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 10target triple = "x86_64-unknown-windows-msvc" 11 12; Function Attrs: alwaysinline nounwind 13define dso_local i32 @f(i32 %x) #0 !dbg !7 { 14entry: 15 %x.addr = alloca i32, align 4 16 store i32 %x, ptr %x.addr, align 4 17 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 18 %0 = load i32, ptr %x.addr, align 4, !dbg !14 19 ret i32 %0, !dbg !14 20} 21 22; Function Attrs: nounwind readnone speculatable willreturn 23declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 24 25; Function Attrs: alwaysinline nounwind 26define i32 @g(i32 %x) #0 !dbg !15 { 27entry: 28 %x.addr = alloca i32, align 4 29 store i32 %x, ptr %x.addr, align 4 30 call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !16, metadata !DIExpression()), !dbg !17 31 br label %L, !dbg !17 32 33L: ; preds = %entry 34 call void @llvm.dbg.label(metadata !18), !dbg !19 35 store i32 42, ptr %x.addr, align 4, !dbg !20 36 %0 = load i32, ptr %x.addr, align 4, !dbg !21 37 ret i32 %0, !dbg !21 38} 39 40; Function Attrs: nounwind readnone speculatable willreturn 41declare void @llvm.dbg.label(metadata) #1 42 43; Check that debug info for inlined code uses the call location and that debug 44; intrinsics are removed. 45; Function Attrs: noinline nounwind optnone 46define i32 @main() #2 !dbg !22 { 47entry: 48; CHECK-LABEL: @main() 49; CHECK-NOT: @f 50; CHECK-NOT: @llvm.dbg.declare 51; CHECK: %{{[0-9]+}} = load i32, ptr %x.addr.i, align 4, !dbg ![[VAR1:[0-9]+]] 52 %call = call i32 @f(i32 3), !dbg !25 53 54; Another test for inlining debug intrinsics where the intrinsic appears at the 55; start of the basic block. 56; CHECK-NOT: @g 57; CHECK-NOT: @llvm.dbg.label 58; CHECK: %{{[0-9]+}} = load i32, ptr %x.addr.i1, align 4, !dbg ![[VAR2:[0-9]+]] 59 %call1 = call i32 @g(i32 340), !dbg !26 60 ret i32 0, !dbg !27 61} 62 63; CHECK: ![[VAR1]] = !DILocation(line: 10, scope: ![[SCOPE:[0-9]+]]) 64; CHECK: ![[VAR2]] = !DILocation(line: 11, scope: ![[SCOPE]]) 65 66attributes #0 = { alwaysinline nounwind "no-inline-line-tables" } 67attributes #2 = { noinline nounwind optnone "no-inline-line-tables"} 68 69!llvm.dbg.cu = !{!0} 70!llvm.module.flags = !{!3, !4, !5} 71!llvm.ident = !{!6} 72 73!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 03ec3a12a94bbbaa11999b6da3a43221a5aa54a5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) 74!1 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/akhuang/testing/inline-line-tables", checksumkind: CSK_MD5, checksum: "38a4785b48742d3ea655b8f3461436a4") 75!2 = !{} 76!3 = !{i32 2, !"CodeView", i32 1} 77!4 = !{i32 2, !"Debug Info Version", i32 3} 78!5 = !{i32 1, !"wchar_size", i32 4} 79!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 03ec3a12a94bbbaa11999b6da3a43221a5aa54a5)"} 80!7 = distinct !DISubprogram(name: "f", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 81!8 = !DIFile(filename: "t.c", directory: "/usr/local/google/home/akhuang/testing/inline-line-tables", checksumkind: CSK_MD5, checksum: "38a4785b48742d3ea655b8f3461436a4") 82!9 = !DISubroutineType(types: !10) 83!10 = !{!11, !11} 84!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 85!12 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !8, line: 1, type: !11) 86!13 = !DILocation(line: 1, scope: !7) 87!14 = !DILocation(line: 2, scope: !7) 88!15 = distinct !DISubprogram(name: "g", scope: !8, file: !8, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 89!16 = !DILocalVariable(name: "x", arg: 1, scope: !15, file: !8, line: 4, type: !11) 90!17 = !DILocation(line: 4, scope: !15) 91!18 = !DILabel(scope: !15, name: "L", file: !8, line: 5) 92!19 = !DILocation(line: 5, scope: !15) 93!20 = !DILocation(line: 6, scope: !15) 94!21 = !DILocation(line: 7, scope: !15) 95!22 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 9, type: !23, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 96!23 = !DISubroutineType(types: !24) 97!24 = !{!11} 98!25 = !DILocation(line: 10, scope: !22) 99!26 = !DILocation(line: 11, scope: !22) 100!27 = !DILocation(line: 12, scope: !22) 101