reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
; RUN: opt -run-twice -verify -S -o - %s | FileCheck %s

; If a module contains a DISubprogram referenced only indirectly from
; instruction-level debug info metadata, but not attached to any Function
; defined within the module, cloning such a module with CloneModule was
; causing a DICompileUnit duplication: it would be moved in indirecty via a
; DISubprogram by DebugInfoFinder (making sure DISubprogram's don't get
; duplicated) first without being explicitly self-mapped within the ValueMap
; shared among CloneFunctionInto calls, and then it would get copied during
; named metadata cloning.
;
; This is to make sure we don't regress on that.

; Derived from the following C-snippet
;
; static int eliminated(int j);
; __attribute__((nodebug)) int nodebug(int k) { return eliminated(k); }
; __attribute__((always_inline)) static int eliminated(int j) { return j * 2; }
;
; compiled with `clang -O1 -g1 -emit-llvm -S`

; CHECK:     DICompileUnit
; CHECK-NOT: DICompileUnit

source_filename = "clone-module.c"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"

; Function Attrs: norecurse nounwind readnone ssp uwtable
define i32 @nodebug(i32 %k) local_unnamed_addr #0 {
entry:
  %mul.i = shl nsw i32 %k, 1, !dbg !8
  ret i32 %mul.i
}

attributes #0 = { norecurse nounwind readnone ssp uwtable }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!llvm.ident = !{!7}

!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
!1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm/build/obj")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{!"clang version 7.0.0"}
!8 = !DILocation(line: 3, column: 72, scope: !9)
!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)
!10 = !DISubroutineType(types: !2)