2015-12-18 01:14:09 +08:00
|
|
|
; Do setup work for all below tests: generate bitcode and combined index
|
2016-04-13 05:35:18 +08:00
|
|
|
; RUN: opt -module-summary %s -o %t.bc
|
|
|
|
; RUN: opt -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc
|
2015-12-18 01:14:09 +08:00
|
|
|
; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
|
|
|
|
|
2015-12-19 01:51:37 +08:00
|
|
|
; If we import func1 and not func2 we should only link DISubprogram for func1
|
2016-03-15 08:04:37 +08:00
|
|
|
; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s
|
2015-12-18 01:14:09 +08:00
|
|
|
|
|
|
|
; CHECK: declare i32 @func2
|
|
|
|
; CHECK: define available_externally i32 @func1
|
2015-12-19 01:51:37 +08:00
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
; Ensure that each subprogram points to the correct CU.
|
|
|
|
; CHECK: ![[CU1:[0-9]+]] = distinct !DICompileUnit(
|
|
|
|
; CHECK: ![[CU2:[0-9]+]] = distinct !DICompileUnit(
|
2015-12-19 01:51:37 +08:00
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
; CHECK: distinct !DISubprogram(name: "main", {{.*}}, unit: ![[CU1]]
|
|
|
|
; CHECK: distinct !DISubprogram(name: "func1", {{.*}}, unit: ![[CU2]]
|
2015-12-19 01:51:37 +08:00
|
|
|
; CHECK-NOT: distinct !DISubprogram(name: "func2"
|
2016-04-15 23:57:41 +08:00
|
|
|
; CHECK: distinct !DISubprogram(name: "func3", {{.*}}, unit: ![[CU2]]
|
|
|
|
; CHECK: distinct !DISubprogram(name: "func4", {{.*}}, unit: ![[CU2]]
|
2015-12-19 01:51:37 +08:00
|
|
|
|
2015-12-18 01:14:09 +08:00
|
|
|
|
|
|
|
; ModuleID = 'dbg.o'
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone uwtable
|
|
|
|
define i32 @func1(i32 %n) #0 !dbg !4 {
|
|
|
|
entry:
|
|
|
|
tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !9, metadata !17), !dbg !18
|
|
|
|
tail call void @llvm.dbg.value(metadata i32 5, i64 0, metadata !10, metadata !17), !dbg !19
|
|
|
|
%cmp = icmp sgt i32 %n, 10, !dbg !20
|
|
|
|
%. = select i1 %cmp, i32 10, i32 5, !dbg !22
|
|
|
|
tail call void @llvm.dbg.value(metadata i32 %., i64 0, metadata !10, metadata !17), !dbg !19
|
|
|
|
ret i32 %., !dbg !23
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone uwtable
|
|
|
|
define i32 @func2(i32 %n) #0 !dbg !11 {
|
|
|
|
entry:
|
|
|
|
tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !13, metadata !17), !dbg !24
|
|
|
|
ret i32 %n, !dbg !25
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
|
|
|
|
|
2019-12-25 08:11:33 +08:00
|
|
|
attributes #0 = { nounwind readnone uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
2015-12-18 01:14:09 +08:00
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!14, !15}
|
|
|
|
!llvm.ident = !{!16}
|
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
2015-12-18 01:14:09 +08:00
|
|
|
!1 = !DIFile(filename: "dbg.c", directory: ".")
|
|
|
|
!2 = !{}
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!4 = distinct !DISubprogram(name: "func1", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8)
|
2015-12-18 01:14:09 +08:00
|
|
|
!5 = !DISubroutineType(types: !6)
|
|
|
|
!6 = !{!7, !7}
|
|
|
|
!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
|
|
!8 = !{!9, !10}
|
|
|
|
!9 = !DILocalVariable(name: "n", arg: 1, scope: !4, file: !1, line: 1, type: !7)
|
|
|
|
!10 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 2, type: !7)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!11 = distinct !DISubprogram(name: "func2", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
|
2015-12-18 01:14:09 +08:00
|
|
|
!12 = !{!13}
|
|
|
|
!13 = !DILocalVariable(name: "n", arg: 1, scope: !11, file: !1, line: 8, type: !7)
|
|
|
|
!14 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!15 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!16 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"}
|
|
|
|
!17 = !DIExpression()
|
|
|
|
!18 = !DILocation(line: 1, column: 15, scope: !4)
|
|
|
|
!19 = !DILocation(line: 2, column: 7, scope: !4)
|
2016-01-26 06:04:56 +08:00
|
|
|
!20 = !DILocation(line: 3, column: 9, scope: !21, inlinedAt: !26)
|
|
|
|
!21 = distinct !DILexicalBlock(scope: !27, file: !1, line: 3, column: 7)
|
2015-12-18 01:14:09 +08:00
|
|
|
!22 = !DILocation(line: 3, column: 7, scope: !4)
|
|
|
|
!23 = !DILocation(line: 5, column: 3, scope: !4)
|
|
|
|
!24 = !DILocation(line: 8, column: 15, scope: !11)
|
|
|
|
!25 = !DILocation(line: 9, column: 3, scope: !11)
|
2016-01-26 06:04:56 +08:00
|
|
|
!26 = !DILocation(line: 9, column: 3, scope: !4)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!27 = distinct !DISubprogram(name: "func3", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !28)
|
2016-01-26 06:04:56 +08:00
|
|
|
!28 = !{!29}
|
|
|
|
!29 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!30 = distinct !DISubprogram(name: "func4", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !31)
|
2016-01-26 06:04:56 +08:00
|
|
|
!31 = !{!32}
|
|
|
|
!32 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7)
|
|
|
|
|