1 ; RUN: opt -run-twice -verify -disable-debug-info-type-map -S -o - %s | FileCheck %s 2 3 ; Generated using: 4 ; $ cat p.cpp 5 ; void sink(void *); 6 ; class A { 7 ; public: 8 ; template <typename> void m_fn2() { static int a; } 9 ; virtual void m_fn1(); 10 ; }; 11 ; void foo() { 12 ; class B : public A { 13 ; public: 14 ; B() { m_fn2<B>(); } 15 ; }; 16 ; sink(new B); 17 ; } 18 ; $ clang++ -target x86_64-unknown-linux -fvisibility=hidden -O2 -g2 -flto -S p.cpp -o p.ll 19 ; # then manually removed function/gv definitions 20 21 ; Test that when the module is cloned it does not contain a reference to 22 ; the original DICompileUnit as a result of a collision between the cloned 23 ; DISubprogram for m_fn2<B> (which refers to the non-ODR entity B via 24 ; template parameters) and the original DISubprogram. 25 26 ; CHECK: DICompileUnit 27 ; CHECK-NOT: DICompileUnit 28 29 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 30 target triple = "x86_64-unknown-linux" 31 32 !llvm.dbg.cu = !{!0} 33 !llvm.module.flags = !{!28, !29} 34 !llvm.ident = !{!30} 35 36 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3) 37 !1 = !DIFile(filename: "p.cpp", directory: "/usr/local/google/home/pcc/b682773-2-repro/small2") 38 !2 = !{} 39 !3 = !{!4} 40 !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) 41 !5 = distinct !DIGlobalVariable(name: "a", scope: !6, file: !1, line: 5, type: !27, isLocal: true, isDefinition: true) 42 !6 = distinct !DISubprogram(name: "m_fn2<B>", linkageName: "_ZN1A5m_fn2IZ3foovE1BEEvv", scope: !7, file: !1, line: 5, type: !8, isLocal: true, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !11, declaration: !23, retainedNodes: !24) 43 !7 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !1, line: 3, flags: DIFlagFwdDecl, identifier: "_ZTS1A") 44 !8 = !DISubroutineType(types: !9) 45 !9 = !{null, !10} 46 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 47 !11 = !{!12} 48 !12 = !DITemplateTypeParameter(type: !13) 49 !13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: !14, file: !1, line: 10, size: 64, elements: !17, vtableHolder: !7) 50 !14 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 9, type: !15, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 51 !15 = !DISubroutineType(types: !16) 52 !16 = !{null} 53 !17 = !{!18, !19} 54 !18 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !13, baseType: !7, flags: DIFlagPublic) 55 !19 = !DISubprogram(name: "B", scope: !13, file: !1, line: 12, type: !20, isLocal: false, isDefinition: false, scopeLine: 12, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true) 56 !20 = !DISubroutineType(types: !21) 57 !21 = !{null, !22} 58 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 59 !23 = !DISubprogram(name: "m_fn2<B>", linkageName: "_ZN1A5m_fn2IZ3foovE1BEEvv", scope: !7, file: !1, line: 5, type: !8, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true, templateParams: !11) 60 !24 = !{!25} 61 !25 = !DILocalVariable(name: "this", arg: 1, scope: !6, type: !26, flags: DIFlagArtificial | DIFlagObjectPointer) 62 !26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) 63 !27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 64 !28 = !{i32 2, !"Dwarf Version", i32 4} 65 !29 = !{i32 2, !"Debug Info Version", i32 3} 66 !30 = !{!"clang version 5.0.0 "} 67