diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Linker/Inputs/only-needed-debug-metadata.ll | 27 | ||||
-rw-r--r-- | llvm/test/Linker/only-needed-debug-metadata.ll | 49 | ||||
-rw-r--r-- | llvm/test/Linker/thinlto_funcimport_debug.ll | 13 | ||||
-rw-r--r-- | llvm/test/tools/gold/X86/Inputs/linkonce-weak.ll | 20 | ||||
-rw-r--r-- | llvm/test/tools/gold/X86/linkonce-weak.ll | 26 |
5 files changed, 128 insertions, 7 deletions
diff --git a/llvm/test/Linker/Inputs/only-needed-debug-metadata.ll b/llvm/test/Linker/Inputs/only-needed-debug-metadata.ll new file mode 100644 index 00000000000..ec7f02f4d19 --- /dev/null +++ b/llvm/test/Linker/Inputs/only-needed-debug-metadata.ll @@ -0,0 +1,27 @@ +@X = external global i32 + +declare i32 @foo() + +define void @bar() !dbg !4 { + load i32, i32* @X, !dbg !10 + call i32 @foo(), !dbg !11 + ret void, !dbg !12 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!7, !8} +!llvm.ident = !{!9} + +!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: 1, enums: !2, subprograms: !3) +!1 = !DIFile(filename: "linkused.b.c", directory: ".") +!2 = !{} +!3 = !{!4} +!4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, isOptimized: true, variables: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{null} +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} +!10 = !DILocation(line: 6, column: 7, scope: !4) +!11 = !DILocation(line: 6, column: 3, scope: !4) +!12 = !DILocation(line: 7, column: 1, scope: !4) diff --git a/llvm/test/Linker/only-needed-debug-metadata.ll b/llvm/test/Linker/only-needed-debug-metadata.ll new file mode 100644 index 00000000000..f327fe03bf4 --- /dev/null +++ b/llvm/test/Linker/only-needed-debug-metadata.ll @@ -0,0 +1,49 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-as %p/Inputs/only-needed-debug-metadata.ll -o %t2.bc + +; Without -only-needed, we need to link in both DISubprogram. +; RUN: llvm-link -S %t2.bc %t.bc | FileCheck %s +; CHECK: distinct !DISubprogram(name: "foo" +; CHECK: distinct !DISubprogram(name: "unused" + +; With -only-needed, we only need to link in foo's DISubprogram. +; RUN: llvm-link -S -only-needed %t2.bc %t.bc | FileCheck %s -check-prefix=ONLYNEEDED +; ONLYNEEDED: distinct !DISubprogram(name: "foo" +; ONLYNEEDED-NOT: distinct !DISubprogram(name: "unused" + +@X = global i32 5 +@U = global i32 6 +@U_linkonce = linkonce_odr hidden global i32 6 +define i32 @foo() !dbg !4 { + ret i32 7, !dbg !20 +} +define i32 @unused() !dbg !10 { + ret i32 8, !dbg !21 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!16, !17} +!llvm.ident = !{!18} + +!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: 1, enums: !2, subprograms: !3, globals: !13) +!1 = !DIFile(filename: "linkused2.c", directory: "/usr/local/google/home/tejohnson/llvm/tmp") +!2 = !{} +!3 = !{!4, !10} +!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, variables: !8) +!5 = !DISubroutineType(types: !6) +!6 = !{!7, !7} +!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!8 = !{!9} +!9 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !1, line: 4, type: !7) +!10 = distinct !DISubprogram(name: "unused", scope: !1, file: !1, line: 8, type: !11, isLocal: false, isDefinition: true, scopeLine: 8, isOptimized: true, variables: !2) +!11 = !DISubroutineType(types: !12) +!12 = !{!7} +!13 = !{!14, !15} +!14 = !DIGlobalVariable(name: "X", scope: !0, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, variable: i32* @X) +!15 = !DIGlobalVariable(name: "U", scope: !0, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, variable: i32* @U) +!16 = !{i32 2, !"Dwarf Version", i32 4} +!17 = !{i32 2, !"Debug Info Version", i32 3} +!18 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} +!19 = !DIExpression() +!20 = !DILocation(line: 4, column: 13, scope: !4) +!21 = !DILocation(line: 9, column: 3, scope: !10) diff --git a/llvm/test/Linker/thinlto_funcimport_debug.ll b/llvm/test/Linker/thinlto_funcimport_debug.ll index 6c33caacf9e..02f43b24c17 100644 --- a/llvm/test/Linker/thinlto_funcimport_debug.ll +++ b/llvm/test/Linker/thinlto_funcimport_debug.ll @@ -3,13 +3,22 @@ ; RUN: llvm-as -function-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc -; Confirm that we link the metadata for the imported module. +; If we import func1 and not func2 we should only link DISubprogram for func1 ; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s ; CHECK: declare i32 @func2 ; CHECK: define available_externally i32 @func1 + +; Extract out the list of subprograms from each compile unit and ensure +; that neither contains null. +; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs1:[0-9]+]] +; CHECK-NOT: ![[SPs1]] = !{{{.*}}null{{.*}}} +; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs2:[0-9]+]] +; CHECK-NOT: ![[SPs2]] = !{{{.*}}null{{.*}}} + ; CHECK: distinct !DISubprogram(name: "func1" -; CHECK: distinct !DISubprogram(name: "func2" +; CHECK-NOT: distinct !DISubprogram(name: "func2" + ; ModuleID = 'dbg.o' target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/tools/gold/X86/Inputs/linkonce-weak.ll b/llvm/test/tools/gold/X86/Inputs/linkonce-weak.ll index f42af8faa84..3b7dad1b1ef 100644 --- a/llvm/test/tools/gold/X86/Inputs/linkonce-weak.ll +++ b/llvm/test/tools/gold/X86/Inputs/linkonce-weak.ll @@ -1,3 +1,19 @@ -define weak_odr void @f() { - ret void +define weak_odr void @f() !dbg !4 { + ret void, !dbg !10 } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!7, !8} +!llvm.ident = !{!9} + +!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: 1, enums: !2, subprograms: !3) +!1 = !DIFile(filename: "linkonce-weak.c", directory: ".") +!2 = !{} +!3 = !{!4} +!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, variables: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{null} +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} +!10 = !DILocation(line: 2, column: 1, scope: !4) diff --git a/llvm/test/tools/gold/X86/linkonce-weak.ll b/llvm/test/tools/gold/X86/linkonce-weak.ll index a0cccea56cf..3397c3480a7 100644 --- a/llvm/test/tools/gold/X86/linkonce-weak.ll +++ b/llvm/test/tools/gold/X86/linkonce-weak.ll @@ -11,9 +11,29 @@ ; RUN: -shared %t2.o %t.o -o %t3.o ; RUN: llvm-dis %t3.o -o - | FileCheck %s -define linkonce_odr void @f() { - ret void +define linkonce_odr void @f() !dbg !4 { + ret void, !dbg !10 } ; Test that we get a weak_odr regardless of the order of the files -; CHECK: define weak_odr void @f() { +; CHECK: define weak_odr void @f() + +; Test that we only get a single DISubprogram for @f +; CHECK: !DISubprogram(name: "f" +; CHECK-NOT: !DISubprogram(name: "f" + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!7, !8} +!llvm.ident = !{!9} + +!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: 1, enums: !2, subprograms: !3) +!1 = !DIFile(filename: "linkonce-weak.c", directory: ".") +!2 = !{} +!3 = !{!4} +!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, variables: !2) +!5 = !DISubroutineType(types: !6) +!6 = !{null} +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} +!10 = !DILocation(line: 2, column: 1, scope: !4) |