1 ; RUN: opt -S -strip-nonlinetable-debuginfo %s -o %t.ll
2 ; RUN: cat %t.ll | FileCheck %s
3 ; RUN: cat %t.ll | FileCheck %s --check-prefix=CHECK-NEG
5 ; This test provides coverage for setting the containing type of a DISubprogram.
7 ; Generated an reduced from:
14 source_filename = "t.cpp"
15 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
16 target triple = "x86_64-apple-macosx10.12.0"
18 %struct.B = type { %struct.A }
19 %struct.A = type { i32 (...)** }
23 @b = global %struct.B zeroinitializer, align 8, !dbg !0
25 declare void @_ZN1BC2Ev(%struct.B*) unnamed_addr
27 ; Function Attrs: nounwind readnone
28 declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
31 ; Function Attrs: inlinehint nounwind ssp uwtable
32 define linkonce_odr void @_ZN1BC1Ev(%struct.B* %this) unnamed_addr #1 align 2 !dbg !25 {
34 %this.addr = alloca %struct.B*, align 8
35 store %struct.B* %this, %struct.B** %this.addr, align 8
36 ; CHECK-NOT: @llvm.dbg.declare
37 call void @llvm.dbg.declare(metadata %struct.B** %this.addr, metadata !30, metadata !32), !dbg !33
38 %this1 = load %struct.B*, %struct.B** %this.addr, align 8
39 call void @_ZN1BC2Ev(%struct.B* %this1) #2, !dbg !34
41 ; CHECK: call void @_ZN1BC2Ev(%struct.B* %this1){{.*}} !dbg !
44 attributes #0 = { nounwind readnone }
45 attributes #1 = { inlinehint nounwind ssp uwtable }
46 attributes #2 = { nounwind }
49 !llvm.module.flags = !{!21, !22, !23}
52 ; CHECK-NEG-NOT: !DI{{Basic|Composite|Derived}}Type
54 !0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
55 !1 = !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 5, type: !6, isLocal: false, isDefinition: true)
56 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 4.0.0 (trunk 282583) (llvm/trunk 282611)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
57 !3 = !DIFile(filename: "t.cpp", directory: "/")
60 !6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !3, line: 4, size: 64, align: 64, elements: !7, vtableHolder: !9, identifier: "_ZTS1B")
62 !8 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !6, baseType: !9)
63 !9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 1, size: 64, align: 64, elements: !10, vtableHolder: !9, identifier: "_ZTS1A")
65 !11 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$A", scope: !3, file: !3, baseType: !12, size: 64, flags: DIFlagArtificial)
66 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
67 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: !14, size: 64)
68 !14 = !DISubroutineType(types: !15)
70 !16 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
71 !17 = !DISubprogram(name: "~A", scope: !9, file: !3, line: 2, type: !18, isLocal: false, isDefinition: false, scopeLine: 2, containingType: !9, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, flags: DIFlagPrototyped, isOptimized: false)
72 !18 = !DISubroutineType(types: !19)
74 !20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
75 !21 = !{i32 2, !"Dwarf Version", i32 4}
76 !22 = !{i32 2, !"Debug Info Version", i32 3}
77 !23 = !{i32 1, !"PIC Level", i32 2}
78 !24 = !{!"clang version 4.0.0 (trunk 282583) (llvm/trunk 282611)"}
79 ; Only referenced by the type system.
80 ; CHECK-NEG-NOT: !DISubprogram(name: "~A"
81 !25 = distinct !DISubprogram(name: "B", linkageName: "_ZN1BC1Ev", scope: !6, file: !3, line: 4, type: !26, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !2, declaration: !29, retainedNodes: !4)
82 !26 = !DISubroutineType(types: !27)
84 !28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
85 !29 = !DISubprogram(name: "B", scope: !6, type: !26, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
86 !30 = !DILocalVariable(name: "this", arg: 1, scope: !25, type: !31, flags: DIFlagArtificial | DIFlagObjectPointer)
87 !31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64)
89 !33 = !DILocation(line: 0, scope: !25)
90 !34 = !DILocation(line: 4, column: 8, scope: !25)
92 ; CHECK: !DISubprogram(name: "B", scope: ![[FILE:.*]], file: ![[FILE]],
93 ; CHECK-NOT: containingType:
94 ; CHECK-NEG-NOT: !DISubprogram(name: "B", {{.*}}, isDefinition: false