1 ; RUN: opt -run-twice -verify -S -o - %s | FileCheck %s 2 3 ; If a module contains a DISubprogram referenced only indirectly from 4 ; instruction-level debug info metadata, but not attached to any Function 5 ; defined within the module, cloning such a module with CloneModule was 6 ; causing a DICompileUnit duplication: it would be moved in indirecty via a 7 ; DISubprogram by DebugInfoFinder (making sure DISubprogram's don't get 8 ; duplicated) first without being explicitly self-mapped within the ValueMap 9 ; shared among CloneFunctionInto calls, and then it would get copied during 10 ; named metadata cloning. 11 ; 12 ; This is to make sure we don't regress on that. 13 14 ; Derived from the following C-snippet 15 ; 16 ; static int eliminated(int j); 17 ; __attribute__((nodebug)) int nodebug(int k) { return eliminated(k); } 18 ; __attribute__((always_inline)) static int eliminated(int j) { return j * 2; } 19 ; 20 ; compiled with `clang -O1 -g1 -emit-llvm -S` 21 22 ; CHECK: DICompileUnit 23 ; CHECK-NOT: DICompileUnit 24 25 source_filename = "clone-module.c" 26 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 27 target triple = "x86_64-apple-macosx" 28 29 ; Function Attrs: norecurse nounwind readnone ssp uwtable 30 define i32 @nodebug(i32 %k) local_unnamed_addr #0 { 31 entry: 32 %mul.i = shl nsw i32 %k, 1, !dbg !8 33 ret i32 %mul.i 34 } 35 36 attributes #0 = { norecurse nounwind readnone ssp uwtable } 37 38 !llvm.dbg.cu = !{!0} 39 !llvm.module.flags = !{!3, !4, !5, !6} 40 !llvm.ident = !{!7} 41 42 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (https://git.llvm.org/git/clang.git/ 195459d046e795f5952f7d2121e505eeb59c5574) (https://git.llvm.org/git/llvm.git/ e9dc5b5ade57869d1a443c568c6cf556ccf3b7af)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) 43 !1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm/build/obj") 44 !2 = !{} 45 !3 = !{i32 2, !"Dwarf Version", i32 4} 46 !4 = !{i32 2, !"Debug Info Version", i32 3} 47 !5 = !{i32 1, !"wchar_size", i32 4} 48 !6 = !{i32 7, !"PIC Level", i32 2} 49 !7 = !{!"clang version 7.0.0 (https://git.llvm.org/git/clang.git/ 195459d046e795f5952f7d2121e505eeb59c5574) (https://git.llvm.org/git/llvm.git/ e9dc5b5ade57869d1a443c568c6cf556ccf3b7af)"} 50 !8 = !DILocation(line: 3, column: 72, scope: !9) 51 !9 = distinct !DISubprogram(name: "eliminated", scope: !1, file: !1, line: 3, type: !10, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 52 !10 = !DISubroutineType(types: !2) 53