diff options
Diffstat (limited to 'test/tools')
259 files changed, 3653 insertions, 269 deletions
diff --git a/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map b/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map new file mode 100644 index 000000000000..a23e0c34c3f8 --- /dev/null +++ b/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map @@ -0,0 +1,15 @@ +# This is a dummy debug map used for some tests where the contents of the +# map are just an implementation detail. The tests wanting to use that file +# should put all there object files in an explicitely named sub-directory +# of Inputs, and they should be named 1.o, 2.o, ... +# As not finding an object file or symbols isn't a fatal error for dsymutil, +# you can extend this file with as much object files and symbols as needed. + +--- +triple: 'arm64-apple-darwin' +objects: + - filename: 1.o + symbols: + - { sym: _bar, objAddr: 0x0, binAddr: 0x10000, size: 0x10 } +... + diff --git a/test/tools/dsymutil/ARM/empty-map.test b/test/tools/dsymutil/ARM/empty-map.test new file mode 100644 index 000000000000..54d9a35cc6e4 --- /dev/null +++ b/test/tools/dsymutil/ARM/empty-map.test @@ -0,0 +1,8 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s + +--- +triple: 'thumbv7-apple-darwin' +... + +# CHECK: warning: no debug symbols in executable (-arch armv7) diff --git a/test/tools/dsymutil/ARM/fat-arch-name.test b/test/tools/dsymutil/ARM/fat-arch-name.test new file mode 100644 index 000000000000..ac7af1e55d55 --- /dev/null +++ b/test/tools/dsymutil/ARM/fat-arch-name.test @@ -0,0 +1,21 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -no-output %p/../Inputs/fat-test.arm.dylib -o %t.dSYM -verbose 2>&1 | FileCheck %s + +# We detect thumb triples from the binaries, because those are the only ones +# that are guaranteed to be able to generate a Target instance (for example +# we would detect armv7m-apple-darwin as non-thumb triple, but you can't +# instantiate a Target from that). In the user-visible architecture names, and +# in the lipo invocation, we need to rewrite the thumb arch names to the arm +# ones. + +# CHECK: warning: no debug symbols in executable (-arch armv7) + +# CHECK: warning: no debug symbols in executable (-arch armv7s) + +# CHECK: warning: no debug symbols in executable (-arch arm64) + +# CHECK: Running lipo +# CHECK-NEXT: lipo -create +# CHECK-SAME: -segalign armv7 +# CHECK-SAME: -segalign armv7s +# CHECK-SAME: -segalign arm64 diff --git a/test/tools/dsymutil/ARM/fat-arch-not-found.test b/test/tools/dsymutil/ARM/fat-arch-not-found.test new file mode 100644 index 000000000000..e15d9b69b5fe --- /dev/null +++ b/test/tools/dsymutil/ARM/fat-arch-not-found.test @@ -0,0 +1,13 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - 2>&1 | FileCheck %s + +--- +triple: 'armv7-apple-darwin' +objects: + - filename: libfat-test.a(fat-test.o) + symbols: + - { sym: _armv7_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 } +... + +# CHECK: libfat-test.a(fat-test.o): No object file for requested architecture + diff --git a/test/tools/dsymutil/ARM/inlined-low_pc.c b/test/tools/dsymutil/ARM/inlined-low_pc.c new file mode 100644 index 000000000000..7ade33e3e44b --- /dev/null +++ b/test/tools/dsymutil/ARM/inlined-low_pc.c @@ -0,0 +1,15 @@ +/* Compiled with: clang -arch=arm64 -O2 -g -c inlined_low_pc.c */ + +static int foo(int i) { return 42 + i; } +int bar(int a) { return foo(a); } + +// RUN: llvm-dsymutil -f -y %p/dummy-debug-map-amr64.map -oso-prepend-path %p/../Inputs/inlined-low_pc -o - | llvm-dwarfdump - | FileCheck %s + +// CHECK: DW_TAG_subprogram +// CHECK: DW_AT_low_pc{{.*}}0x0000000000010000 +// CHECK: DW_AT_name{{.*}}"bar" +// CHECK-NOT: NULL +// CHECK: DW_TAG_inlined_subroutine +// CHECK-NEXT: DW_AT_abstract_origin{{.*}}"foo" +// CHECK-NEXT: DW_AT_low_pc{{.*}}0x0000000000010000 + diff --git a/test/tools/dsymutil/ARM/lit.local.cfg b/test/tools/dsymutil/ARM/lit.local.cfg new file mode 100644 index 000000000000..442cd554bfed --- /dev/null +++ b/test/tools/dsymutil/ARM/lit.local.cfg @@ -0,0 +1,7 @@ +if not 'ARM' in config.root.targets: + config.unsupported = True +if not 'AArch64' in config.root.targets: + config.unsupported = True + +config.suffixes = ['.test', '.cpp', '.c'] + diff --git a/test/tools/dsymutil/Inputs/absolute_sym.macho.i386 b/test/tools/dsymutil/Inputs/absolute_sym.macho.i386 Binary files differnew file mode 100755 index 000000000000..5ca0f2d6868a --- /dev/null +++ b/test/tools/dsymutil/Inputs/absolute_sym.macho.i386 diff --git a/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o b/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o Binary files differnew file mode 100644 index 000000000000..445e32271cf5 --- /dev/null +++ b/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o diff --git a/test/tools/dsymutil/Inputs/basic.macho.i386 b/test/tools/dsymutil/Inputs/basic.macho.i386 Binary files differnew file mode 100755 index 000000000000..ee6be096fe5a --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic.macho.i386 diff --git a/test/tools/dsymutil/Inputs/basic2-custom-linetable.macho.x86_64.o b/test/tools/dsymutil/Inputs/basic2-custom-linetable.macho.x86_64.o Binary files differnew file mode 100644 index 000000000000..07b36a20c1da --- /dev/null +++ b/test/tools/dsymutil/Inputs/basic2-custom-linetable.macho.x86_64.o diff --git a/test/tools/dsymutil/Inputs/basic2.c b/test/tools/dsymutil/Inputs/basic2.c index 13c6d07c2a08..4524e9bc6cc3 100644 --- a/test/tools/dsymutil/Inputs/basic2.c +++ b/test/tools/dsymutil/Inputs/basic2.c @@ -20,3 +20,9 @@ int foo(int arg) { return bar(arg+val) + inc() + baz++; } +/* This file was also used to create basic2-custom-linetable.macho.x86_64.o + with a custom clang that had different settings for the linetable + encoding constants: line_base == -1 and line_range == 4. + + clang -c -g basic2.c -o basic2-custom-linetable.macho.x86_64.o +*/ diff --git a/test/tools/dsymutil/Inputs/dead-stripped/1.o b/test/tools/dsymutil/Inputs/dead-stripped/1.o Binary files differnew file mode 100644 index 000000000000..fbdffbc61a77 --- /dev/null +++ b/test/tools/dsymutil/Inputs/dead-stripped/1.o diff --git a/test/tools/dsymutil/Inputs/empty_range/1.o b/test/tools/dsymutil/Inputs/empty_range/1.o Binary files differnew file mode 100644 index 000000000000..671bf4a0ccdb --- /dev/null +++ b/test/tools/dsymutil/Inputs/empty_range/1.o diff --git a/test/tools/dsymutil/Inputs/fat-test.arm.dylib b/test/tools/dsymutil/Inputs/fat-test.arm.dylib Binary files differnew file mode 100755 index 000000000000..a8d4f37be4de --- /dev/null +++ b/test/tools/dsymutil/Inputs/fat-test.arm.dylib diff --git a/test/tools/dsymutil/Inputs/fat-test.arm.o b/test/tools/dsymutil/Inputs/fat-test.arm.o Binary files differnew file mode 100644 index 000000000000..1cf16803e892 --- /dev/null +++ b/test/tools/dsymutil/Inputs/fat-test.arm.o diff --git a/test/tools/dsymutil/Inputs/fat-test.c b/test/tools/dsymutil/Inputs/fat-test.c new file mode 100644 index 000000000000..f6c4c76fe2f4 --- /dev/null +++ b/test/tools/dsymutil/Inputs/fat-test.c @@ -0,0 +1,28 @@ +/* Compile with: + clang -c -g -arch x86_64h -arch x86_64 -arch i386 fat-test.c + libtool -static -o libfat-test.a fat-test.o + + to generate a dylib instead: + clang -arch ... -arch ... -arch ... -dynamiclib fat-test.o -o fat-test.dylib + + To reduce the size of the fat binary: + lipo -thin i386 -o fat-test.i386.o fat-test.o + lipo -thin x86_64 -o fat-test.x86_64.o fat-test.o + lipo -thin x86_64h -o fat-test.x86_64h.o fat-test.o + lipo -create -arch x86_64h fat-test.x86_64h.o -arch x86_64 fat-test.x86_64.o -arch i386 fat-test.i386.o -o fat-test.o -segalign i386 8 -segalign x86_64 8 -segalign x86_64h 8 + */ +#ifdef __x86_64h__ +int x86_64h_var; +#elif defined(__x86_64__) +int x86_64_var; +#elif defined(__i386__) +int i386_var; +#elif defined(__ARM_ARCH_7S__) +int armv7s_var; +#elif defined(__ARM_ARCH_7A__) +int armv7_var; +#elif defined(__ARM64_ARCH_8__) +int arm64_var; +#else +#error "Unknown architecture" +#endif diff --git a/test/tools/dsymutil/Inputs/fat-test.dylib b/test/tools/dsymutil/Inputs/fat-test.dylib Binary files differnew file mode 100755 index 000000000000..4def340a9507 --- /dev/null +++ b/test/tools/dsymutil/Inputs/fat-test.dylib diff --git a/test/tools/dsymutil/Inputs/fat-test.o b/test/tools/dsymutil/Inputs/fat-test.o Binary files differnew file mode 100644 index 000000000000..8159cc749772 --- /dev/null +++ b/test/tools/dsymutil/Inputs/fat-test.o diff --git a/test/tools/dsymutil/Inputs/frame-dw2.ll b/test/tools/dsymutil/Inputs/frame-dw2.ll index 7ffc93397315..d07c529d3108 100644 --- a/test/tools/dsymutil/Inputs/frame-dw2.ll +++ b/test/tools/dsymutil/Inputs/frame-dw2.ll @@ -4,7 +4,7 @@ target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" target triple = "i386-apple-macosx10.11.0" ; Function Attrs: nounwind ssp -define i32 @bar(i32 %b) #0 { +define i32 @bar(i32 %b) #0 !dbg !4 { entry: %b.addr = alloca i32, align 4 %var = alloca i32, align 4 @@ -24,7 +24,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 declare i32 @foo(i32*) #2 ; Function Attrs: nounwind ssp -define i32 @baz(i32 %b) #0 { +define i32 @baz(i32 %b) #0 !dbg !8 { entry: %b.addr = alloca i32, align 4 store i32 %b, i32* %b.addr, align 4 @@ -42,29 +42,29 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n !llvm.module.flags = !{!9, !10, !11} !llvm.ident = !{!12} -!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) !1 = !DIFile(filename: "frame.c", directory: "/tmp") !2 = !{} !3 = !{!4, !8} -!4 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @bar, variables: !2) +!4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!8 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @baz, variables: !2) +!8 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !9 = !{i32 2, !"Dwarf Version", i32 2} !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{i32 1, !"PIC Level", i32 2} !12 = !{!"clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)"} -!13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) +!13 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) !14 = !DIExpression() !15 = !DILocation(line: 3, column: 13, scope: !4) -!16 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "var", scope: !4, file: !1, line: 4, type: !7) +!16 = !DILocalVariable(name: "var", scope: !4, file: !1, line: 4, type: !7) !17 = !DILocation(line: 4, column: 6, scope: !4) !18 = !DILocation(line: 4, column: 12, scope: !4) !19 = !DILocation(line: 4, column: 14, scope: !4) !20 = !DILocation(line: 5, column: 9, scope: !4) !21 = !DILocation(line: 5, column: 2, scope: !4) -!22 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) +!22 = !DILocalVariable(name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) !23 = !DILocation(line: 8, column: 13, scope: !8) !24 = !DILocation(line: 9, column: 13, scope: !8) !25 = !DILocation(line: 9, column: 9, scope: !8) diff --git a/test/tools/dsymutil/Inputs/frame-dw4.ll b/test/tools/dsymutil/Inputs/frame-dw4.ll index c8674b13e585..f3df896a3bb5 100644 --- a/test/tools/dsymutil/Inputs/frame-dw4.ll +++ b/test/tools/dsymutil/Inputs/frame-dw4.ll @@ -4,7 +4,7 @@ target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" target triple = "i386-apple-macosx10.11.0" ; Function Attrs: nounwind ssp -define i32 @bar(i32 %b) #0 { +define i32 @bar(i32 %b) #0 !dbg !4 { entry: %b.addr = alloca i32, align 4 %var = alloca i32, align 4 @@ -24,7 +24,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 declare i32 @foo(i32*) #2 ; Function Attrs: nounwind ssp -define i32 @baz(i32 %b) #0 { +define i32 @baz(i32 %b) #0 !dbg !8 { entry: %b.addr = alloca i32, align 4 store i32 %b, i32* %b.addr, align 4 @@ -42,29 +42,29 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n !llvm.module.flags = !{!9, !10, !11} !llvm.ident = !{!12} -!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) !1 = !DIFile(filename: "frame.c", directory: "/tmp") !2 = !{} !3 = !{!4, !8} -!4 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @bar, variables: !2) +!4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!8 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @baz, variables: !2) +!8 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !9 = !{i32 2, !"Dwarf Version", i32 4} !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{i32 1, !"PIC Level", i32 2} !12 = !{!"clang version 3.7.0 (trunk 239176) (llvm/trunk 239190)"} -!13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) +!13 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 3, type: !7) !14 = !DIExpression() !15 = !DILocation(line: 3, column: 13, scope: !4) -!16 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "var", scope: !4, file: !1, line: 4, type: !7) +!16 = !DILocalVariable(name: "var", scope: !4, file: !1, line: 4, type: !7) !17 = !DILocation(line: 4, column: 6, scope: !4) !18 = !DILocation(line: 4, column: 12, scope: !4) !19 = !DILocation(line: 4, column: 14, scope: !4) !20 = !DILocation(line: 5, column: 9, scope: !4) !21 = !DILocation(line: 5, column: 2, scope: !4) -!22 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) +!22 = !DILocalVariable(name: "b", arg: 1, scope: !8, file: !1, line: 8, type: !7) !23 = !DILocation(line: 8, column: 13, scope: !8) !24 = !DILocation(line: 9, column: 13, scope: !8) !25 = !DILocation(line: 9, column: 9, scope: !8) diff --git a/test/tools/dsymutil/Inputs/inlined-low_pc/1.o b/test/tools/dsymutil/Inputs/inlined-low_pc/1.o Binary files differnew file mode 100644 index 000000000000..7ab4e9205bbd --- /dev/null +++ b/test/tools/dsymutil/Inputs/inlined-low_pc/1.o diff --git a/test/tools/dsymutil/Inputs/libfat-test.a b/test/tools/dsymutil/Inputs/libfat-test.a Binary files differnew file mode 100644 index 000000000000..6b34b0fd6f90 --- /dev/null +++ b/test/tools/dsymutil/Inputs/libfat-test.a diff --git a/test/tools/dsymutil/Inputs/mismatch/1.o b/test/tools/dsymutil/Inputs/mismatch/1.o Binary files differnew file mode 100644 index 000000000000..2a855ae293dc --- /dev/null +++ b/test/tools/dsymutil/Inputs/mismatch/1.o diff --git a/test/tools/dsymutil/Inputs/mismatch/mismatch.pcm b/test/tools/dsymutil/Inputs/mismatch/mismatch.pcm Binary files differnew file mode 100644 index 000000000000..94f3cf5fffb6 --- /dev/null +++ b/test/tools/dsymutil/Inputs/mismatch/mismatch.pcm diff --git a/test/tools/dsymutil/Inputs/modules/1.o b/test/tools/dsymutil/Inputs/modules/1.o Binary files differnew file mode 100644 index 000000000000..eca930c905c4 --- /dev/null +++ b/test/tools/dsymutil/Inputs/modules/1.o diff --git a/test/tools/dsymutil/Inputs/modules/Bar.pcm b/test/tools/dsymutil/Inputs/modules/Bar.pcm Binary files differnew file mode 100644 index 000000000000..f3c0d07f2c50 --- /dev/null +++ b/test/tools/dsymutil/Inputs/modules/Bar.pcm diff --git a/test/tools/dsymutil/Inputs/modules/Foo.pcm b/test/tools/dsymutil/Inputs/modules/Foo.pcm Binary files differnew file mode 100644 index 000000000000..4a39a06c24dd --- /dev/null +++ b/test/tools/dsymutil/Inputs/modules/Foo.pcm diff --git a/test/tools/dsymutil/Inputs/odr-anon-namespace/1.o b/test/tools/dsymutil/Inputs/odr-anon-namespace/1.o Binary files differnew file mode 100644 index 000000000000..20d4b7fd84ed --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-anon-namespace/1.o diff --git a/test/tools/dsymutil/Inputs/odr-anon-namespace/2.o b/test/tools/dsymutil/Inputs/odr-anon-namespace/2.o Binary files differnew file mode 100644 index 000000000000..df8e567bc3a5 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-anon-namespace/2.o diff --git a/test/tools/dsymutil/Inputs/odr-member-functions/1.o b/test/tools/dsymutil/Inputs/odr-member-functions/1.o Binary files differnew file mode 100644 index 000000000000..f957a9b9d423 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-member-functions/1.o diff --git a/test/tools/dsymutil/Inputs/odr-member-functions/2.o b/test/tools/dsymutil/Inputs/odr-member-functions/2.o Binary files differnew file mode 100644 index 000000000000..c696866fcad6 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-member-functions/2.o diff --git a/test/tools/dsymutil/Inputs/odr-member-functions/3.o b/test/tools/dsymutil/Inputs/odr-member-functions/3.o Binary files differnew file mode 100644 index 000000000000..962bf6e2b382 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-member-functions/3.o diff --git a/test/tools/dsymutil/Inputs/odr-uniquing/1.o b/test/tools/dsymutil/Inputs/odr-uniquing/1.o Binary files differnew file mode 100644 index 000000000000..c52093030055 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-uniquing/1.o diff --git a/test/tools/dsymutil/Inputs/odr-uniquing/2.o b/test/tools/dsymutil/Inputs/odr-uniquing/2.o Binary files differnew file mode 100644 index 000000000000..c52093030055 --- /dev/null +++ b/test/tools/dsymutil/Inputs/odr-uniquing/2.o diff --git a/test/tools/dsymutil/Inputs/submodules/1.o b/test/tools/dsymutil/Inputs/submodules/1.o Binary files differnew file mode 100644 index 000000000000..d38e30f67c2c --- /dev/null +++ b/test/tools/dsymutil/Inputs/submodules/1.o diff --git a/test/tools/dsymutil/Inputs/submodules/Parent.pcm b/test/tools/dsymutil/Inputs/submodules/Parent.pcm Binary files differnew file mode 100644 index 000000000000..e6909d7afa5e --- /dev/null +++ b/test/tools/dsymutil/Inputs/submodules/Parent.pcm diff --git a/test/tools/dsymutil/X86/basic-linking-bundle.test b/test/tools/dsymutil/X86/basic-linking-bundle.test new file mode 100644 index 000000000000..c07fa5894f36 --- /dev/null +++ b/test/tools/dsymutil/X86/basic-linking-bundle.test @@ -0,0 +1,38 @@ +RUN: rm -rf %T/basic-linking-bundle +RUN: mkdir -p %T/basic-linking-bundle/dsymdest +RUN: cat %p/../Inputs/basic.macho.x86_64 > %T/basic-linking-bundle/basic.macho.x86_64 + +RUN: llvm-dsymutil -oso-prepend-path=%p/.. %T/basic-linking-bundle/basic.macho.x86_64 + +Check that the object file in the bundle exists and is sane: +RUN: llvm-dwarfdump %T/basic-linking-bundle/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test + +Check that llvm-dwarfdump recognizes the bundle as a dSYM: +RUN: llvm-dwarfdump %T/basic-linking-bundle/basic.macho.x86_64.dSYM | FileCheck %S/basic-linking-x86.test + +RUN: FileCheck %s --input-file %T/basic-linking-bundle/basic.macho.x86_64.dSYM/Contents/Info.plist + +RUN: llvm-dsymutil -oso-prepend-path=%p/.. %T/basic-linking-bundle/basic.macho.x86_64 -o %T/basic-linking-bundle/dsymdest/basic.macho.x86_64.dSYM +RUN: llvm-dwarfdump %T/basic-linking-bundle/dsymdest/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test +RUN: FileCheck %s --input-file %T/basic-linking-bundle/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist + +CHECK: <?xml version="1.0" encoding="UTF-8"?> +CHECK-NEXT: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +CHECK-NEXT: <plist version="1.0"> +CHECK-NEXT: <dict> +CHECK-NEXT: <key>CFBundleDevelopmentRegion</key> +CHECK-NEXT: <string>English</string> +CHECK-NEXT: <key>CFBundleIdentifier</key> +CHECK-NEXT: <string>com.apple.xcode.dsym.basic.macho.x86_64</string> +CHECK-NEXT: <key>CFBundleInfoDictionaryVersion</key> +CHECK-NEXT: <string>6.0</string> +CHECK-NEXT: <key>CFBundlePackageType</key> +CHECK-NEXT: <string>dSYM</string> +CHECK-NEXT: <key>CFBundleSignature</key> +CHECK-NEXT: <string>????</string> +CHECK-NEXT: <key>CFBundleShortVersionString</key> +CHECK-NEXT: <string>1.0</string> +CHECK-NEXT: <key>CFBundleVersion</key> +CHECK-NEXT: <string>1</string> +CHECK-NEXT: </dict> +CHECK-NEXT: </plist> diff --git a/test/tools/dsymutil/X86/basic-linking-x86.test b/test/tools/dsymutil/X86/basic-linking-x86.test index 19b4e3bef663..37797a323504 100644 --- a/test/tools/dsymutil/X86/basic-linking-x86.test +++ b/test/tools/dsymutil/X86/basic-linking-x86.test @@ -1,13 +1,12 @@ -REQUIRES: shell RUN: cat %p/../Inputs/basic.macho.x86_64 > %t1 -RUN: llvm-dsymutil -oso-prepend-path=%p/.. %t1 +RUN: llvm-dsymutil -f -oso-prepend-path=%p/.. %t1 RUN: llvm-dwarfdump %t1.dwarf | FileCheck %s -RUN: llvm-dsymutil -o %t2 -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 +RUN: llvm-dsymutil -f -o %t2 -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 RUN: llvm-dwarfdump %t2 | FileCheck %s -RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC -RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE -RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dsymutil -y -o - - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC -RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dsymutil -o - -y - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE +RUN: llvm-dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC +RUN: llvm-dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE +RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dsymutil -f -y -o - - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC +RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dsymutil -f -o - -y - | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE CHECK: file format Mach-O 64-bit x86-64 diff --git a/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test b/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test index ad3ba5a15b6b..56b78588b758 100644 --- a/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test +++ b/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test @@ -1,5 +1,4 @@ -REQUIRES: shell -RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump - | FileCheck %s +RUN: llvm-dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump - | FileCheck %s CHECK: file format Mach-O 64-bit x86-64 diff --git a/test/tools/dsymutil/X86/basic-lto-linking-x86.test b/test/tools/dsymutil/X86/basic-lto-linking-x86.test index 395234e96166..68103aa44ca9 100644 --- a/test/tools/dsymutil/X86/basic-lto-linking-x86.test +++ b/test/tools/dsymutil/X86/basic-lto-linking-x86.test @@ -1,6 +1,5 @@ -REQUIRES: shell -RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump - | FileCheck %s -RUN: llvm-dsymutil -oso-prepend-path=%p/.. -dump-debug-map %p/../Inputs/basic-lto.macho.x86_64 | llvm-dsymutil -o - -y - | llvm-dwarfdump - | FileCheck %s +RUN: llvm-dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump - | FileCheck %s +RUN: llvm-dsymutil -oso-prepend-path=%p/.. -dump-debug-map %p/../Inputs/basic-lto.macho.x86_64 | llvm-dsymutil -f -o - -y - | llvm-dwarfdump - | FileCheck %s CHECK: file format Mach-O 64-bit x86-64 @@ -117,7 +116,7 @@ CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: DW_AT_location [DW_FORM_data4] (0x00000025) CHECK: DW_TAG_lexical_block [14] * CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f94) -CHECK DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fa7) +CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fa7) CHECK: DW_TAG_inlined_subroutine [15] CHECK: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x009a => {0x000001d4} "inc") CHECK: DW_AT_ranges [DW_FORM_data4] (0x00000000 diff --git a/test/tools/dsymutil/X86/custom-line-table.test b/test/tools/dsymutil/X86/custom-line-table.test new file mode 100644 index 000000000000..86fd7e294686 --- /dev/null +++ b/test/tools/dsymutil/X86/custom-line-table.test @@ -0,0 +1,40 @@ +# RUN: llvm-dsymutil -oso-prepend-path %p/../Inputs -y %s -f -o - | llvm-dwarfdump - -debug-dump=line | FileCheck %s + +# This test runs dsymutil on an object file with non-standard (as far +# as llvm is concerned) line table settings. + +--- +triple: 'x86_64-apple-darwin' +objects: + - filename: basic2-custom-linetable.macho.x86_64.o + symbols: + - { sym: _foo, objAddr: 0x0, binAddr: 0x1000, size: 0x12 } + +# CHECK: 0x0000000000001000 19 0 {{.*}} is_stmt +# CHECK: 0x0000000000001012 20 14 {{.*}} is_stmt prologue_end +# CHECK: 0x0000000000001015 20 18 {{.*}} +# CHECK: 0x0000000000001017 20 17 {{.*}} +# CHECK: 0x0000000000001019 20 10 {{.*}} +# CHECK: 0x000000000000101e 20 25 {{.*}} +# CHECK: 0x0000000000001026 20 23 {{.*}} +# CHECK: 0x000000000000102b 20 36 {{.*}} +# CHECK: 0x000000000000103c 20 31 {{.*}} +# CHECK: 0x000000000000103e 20 3 {{.*}} +# CHECK: 0x0000000000001046 20 3 {{.*}} end_sequence + + - { sym: _inc, objAddr: 0x0, binAddr: 0x2000, size: 0x12 } + +# CHECK: 0x0000000000002000 14 0 {{.*}} is_stmt +# CHECK: 0x0000000000002004 15 10 {{.*}} is_stmt prologue_end +# CHECK: 0x0000000000002013 15 3 {{.*}} +# CHECK: 0x0000000000002015 15 3 {{.*}} end_sequence + + - { sym: _unused1, objAddr: 0x0, binAddr: 0x3000, size: 0x12 } + +# CHECK: 0x0000000000003000 10 0 {{.*}} is_stmt +# CHECK: 0x0000000000003004 11 7 {{.*}} is_stmt prologue_end +# CHECK: 0x000000000000300e 11 3 {{.*}} +# CHECK: 0x0000000000003013 12 1 {{.*}} is_stmt +# CHECK: 0x000000000000301c 12 1 {{.*}} is_stmt end_sequence +... + diff --git a/test/tools/dsymutil/X86/dead-stripped.cpp b/test/tools/dsymutil/X86/dead-stripped.cpp new file mode 100644 index 000000000000..ecab7580ec0f --- /dev/null +++ b/test/tools/dsymutil/X86/dead-stripped.cpp @@ -0,0 +1,48 @@ +// RUN: llvm-dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/dead-stripped -o - | llvm-dwarfdump - -debug-dump=info | FileCheck %s + +// The test was compiled with: +// clang++ -O2 -g -c dead-strip.cpp -o 1.o + +// The goal of the test is to exercise dsymutil's behavior in presence of +// functions/variables that have been dead-stripped by the linker but +// that are still present in the linked debug info (in this case because +// they have been DW_TAG_import'd in another namespace). + +// Everything in the N namespace bellow doesn't have a debug map entry, and +// thus is considered dead (::foo() has a debug map entry, otherwse dsymutil +// would just drop the CU altogether). + +namespace N { +int blah = 42; +// This is actually a dsymutil-classic bug that we reproduced +// CHECK: DW_TAG_variable +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_location + +__attribute__((always_inline)) int foo() { return blah; } +// CHECK: DW_TAG_subprogram +// CHECK-NOT: DW_AT_low_pc +// CHECK-NOT: DW_AT_high_pc +// CHECK: DW_AT_frame_base + +// CHECK: DW_TAG_subprogram + +int bar(unsigned i) { + int val = foo(); + if (i) + return val + bar(i-1); + return foo(); +} +// CHECK: DW_TAG_subprogram +// CHECK-NOT: DW_AT_low_pc +// CHECK-NOT: DW_AT_high_pc +// CHECK: DW_AT_frame_base +// CHECK-NOT: DW_AT_location +// CHECK-NOT: DW_AT_low_pc +// CHECK-NOT: DW_AT_high_pc + +} +// CHECK: TAG_imported_module +using namespace N; + +void foo() {} diff --git a/test/tools/dsymutil/X86/dsym-companion.test b/test/tools/dsymutil/X86/dsym-companion.test new file mode 100644 index 000000000000..4327a2953d97 --- /dev/null +++ b/test/tools/dsymutil/X86/dsym-companion.test @@ -0,0 +1,339 @@ +RUN: llvm-dsymutil -o - %p/../Inputs/basic.macho.i386 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK32 +RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK64 + +This test checks that the dSYM companion binaries generated in 32 and 64 bits +are correct. The check are pretty strict (we check even the offsets and sizes +of the sections) in order to test the VM address layout algorithm. As the +debug sections are generated, this is a bit risky, but I don't expect +llvm-dsymutil's output to change much for these tiny C programs so this should +be OK. +The 32bits version doesn't have object files, thus it has basically no debug +sections. + +CHECK32: Format: Mach-O 32-bit i386 +CHECK32: Arch: i386 +CHECK32: AddressSize: 32bit +CHECK64: Format: Mach-O 64-bit x86-64 +CHECK64: Arch: x86_64 +CHECK64: AddressSize: 64bit +CHECK: MachHeader { +CHECK32: Magic: Magic (0xFEEDFACE) +CHECK32: CpuType: X86 (0x7) +CHECK32: CpuSubType: CPU_SUBTYPE_I386_ALL (0x3) +CHECK64: Magic: Magic64 (0xFEEDFACF) +CHECK64: CpuType: X86-64 (0x1000007) +CHECK64: CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3) +CHECK: FileType: DWARFSymbol (0xA) +CHECK: NumOfLoadCommands: 7 +CHECK: Flags [ (0x0) +CHECK: } +CHECK: Sections [ +CHECK: Section { +CHECK: Name: __text +CHECK: Segment: __TEXT +CHECK32: Address: 0x1E90 +CHECK32: Size: 0x11A +CHECK64: Address: 0x100000EA0 +CHECK64: Size: 0x109 +CHECK: Offset: 0 +CHECK: Alignment: 4 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x800004) +CHECK: PureInstructions (0x800000) +CHECK: SomeInstructions (0x4) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __unwind_info +CHECK: Segment: __TEXT +CHECK32: Address: 0x1FAC +CHECK64: Address: 0x100000FAC +CHECK: Size: 0x48 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK32: Section { +CHECK32: Name: __nl_symbol_ptr +CHECK32: Segment: __DATA +CHECK32: Address: 0x2000 +CHECK32: Size: 0x4 +CHECK32: Offset: 0 +CHECK32: Alignment: 2 +CHECK32: RelocationOffset: 0x0 +CHECK32: RelocationCount: 0 +CHECK32: Type: 0x6 +CHECK32: Attributes [ (0x0) +CHECK32: ] +CHECK32: Reserved1: 0x0 +CHECK32: Reserved2: 0x0 +CHECK32: } +CHECK: Section { +CHECK: Name: __data +CHECK: Segment: __DATA +CHECK32: Address: 0x2004 +CHECK64: Address: 0x100001000 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __common +CHECK: Segment: __DATA +CHECK32: Address: 0x2008 +CHECK64: Address: 0x100001004 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: LocReloc (0x1) +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __bss +CHECK: Segment: __DATA +CHECK32: Address: 0x200C +CHECK64: Address: 0x100001008 +CHECK: Size: 0x4 +CHECK: Offset: 0 +CHECK: Alignment: 2 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: LocReloc (0x1) +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK64: Section { +CHECK64: Name: __debug_line +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003000 +CHECK64: Size: 0xEA +CHECK64: Offset: 8192 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_pubnames +CHECK64: Segment: __DWARF +CHECK64: Address: 0x1000030EA +CHECK64: Size: 0x7F +CHECK64: Offset: 8426 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_pubtypes +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003169 +CHECK64: Size: 0x57 +CHECK64: Offset: 8553 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_aranges +CHECK64: Segment: __DWARF +CHECK64: Address: 0x1000031C0 +CHECK64: Size: 0xB0 +CHECK64: Offset: 8640 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK64: Section { +CHECK64: Name: __debug_info +CHECK64: Segment: __DWARF +CHECK64: Address: 0x100003270 +CHECK64: Size: 0x1BC +CHECK64: Offset: 8816 +CHECK64: Alignment: 0 +CHECK64: RelocationOffset: 0x0 +CHECK64: RelocationCount: 0 +CHECK64: Type: 0x0 +CHECK64: Attributes [ (0x0) +CHECK64: ] +CHECK64: Reserved1: 0x0 +CHECK64: Reserved2: 0x0 +CHECK64: } +CHECK: Section { +CHECK: Name: __debug_abbrev +CHECK: Segment: __DWARF +CHECK32: Address: 0x4000 +CHECK32: Size: 0x1 +CHECK32: Offset: 8192 +CHECK64: Address: 0x10000342C +CHECK64: Size: 0x8F +CHECK64: Offset: 9260 +CHECK: Alignment: 0 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: Section { +CHECK: Name: __debug_str +CHECK: Segment: __DWARF +CHECK32: Address: 0x4001 +CHECK32: Size: 0x1 +CHECK32: Offset: 8193 +CHECK64: Address: 0x1000034BB +CHECK64: Size: 0x9F +CHECK64: Offset: 9403 +CHECK: Alignment: 0 +CHECK: RelocationOffset: 0x0 +CHECK: RelocationCount: 0 +CHECK: Type: 0x0 +CHECK: Attributes [ (0x0) +CHECK: ] +CHECK: Reserved1: 0x0 +CHECK: Reserved2: 0x0 +CHECK: } +CHECK: ] +CHECK: Symbols [ +CHECK: Symbol { +CHECK: Name: _inc (2) +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F20 +CHECK64: Value: 0x100000F20 +CHECK: } +CHECK: Symbol { +CHECK: Name: _inc (2) +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F90 +CHECK64: Value: 0x100000F90 +CHECK: } +CHECK: Symbol { +CHECK: Name: _baz (7) +CHECK: Type: Section (0xE) +CHECK: Section: __data +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x2004 +CHECK64: Value: 0x100001000 +CHECK: } +CHECK: Symbol { +CHECK: Name: _private_int (12) +CHECK: Type: Section (0xE) +CHECK: Section: __bss +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x200C +CHECK64: Value: 0x100001008 +CHECK: } +CHECK: Symbol { +CHECK: Name: __mh_execute_header (25) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x10) +CHECK: ReferencedDynamically (0x10) +CHECK: ] +CHECK32: Value: 0x1000 +CHECK64: Value: 0x100000000 +CHECK: } +CHECK: Symbol { +CHECK: Name: _bar (45) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1F40 +CHECK64: Value: 0x100000F40 +CHECK: } +CHECK: Symbol { +CHECK: Name: _foo (50) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1EC0 +CHECK64: Value: 0x100000ED0 +CHECK: } +CHECK: Symbol { +CHECK: Name: _main (55) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __text +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x1E90 +CHECK64: Value: 0x100000EA0 +CHECK: } +CHECK: Symbol { +CHECK: Name: _val (61) +CHECK: Extern +CHECK: Type: Section (0xE) +CHECK: Section: __common +CHECK: RefType: UndefinedNonLazy (0x0) +CHECK: Flags [ (0x0) +CHECK: ] +CHECK32: Value: 0x2008 +CHECK64: Value: 0x100001004 +CHECK: } +CHECK: ] + diff --git a/test/tools/dsymutil/X86/dummy-debug-map.map b/test/tools/dsymutil/X86/dummy-debug-map.map new file mode 100644 index 000000000000..f9bc7b099858 --- /dev/null +++ b/test/tools/dsymutil/X86/dummy-debug-map.map @@ -0,0 +1,22 @@ +# This is a dummy debug map used for some tests where the contents of the +# map are just an implementation detail. The tests wanting to use that file +# should put all there object files in an explicitely named sub-directory +# of Inputs, and they should be named 1.o, 2.o, ... +# As not finding an object file or symbols isn't a fatal error for dsymutil, +# you can extend this file with as much object files and symbols as needed. + +--- +triple: 'x86_64-apple-darwin' +objects: + - filename: 1.o + symbols: + - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 } + - filename: 2.o + symbols: + - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x20000, size: 0x10 } + - filename: 3.o + symbols: + - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x30000, size: 0x10 } + - { sym: __ZN1S3bazIiEEvT_, objAddr: 0x0, binAddr: 0x30010, size: 0x10 } +... + diff --git a/test/tools/dsymutil/X86/empty_range.s b/test/tools/dsymutil/X86/empty_range.s new file mode 100644 index 000000000000..dfe734f1b2bb --- /dev/null +++ b/test/tools/dsymutil/X86/empty_range.s @@ -0,0 +1,61 @@ +# This test verifies that an empty range list in the .debug_ranges section +# doesn't crash llvm-dsymutil. As clang does not produce this kind of debug +# info anymore, we used this hand-crafted assembly file to produce a testcase +# Compile with: +# llvm-mc -triple x86_64-apple-darwin -filetype=obj -o 1.o empty_range.o + +# RUN: llvm-dsymutil -f -y %p/dummy-debug-map.map -oso-prepend-path %p/../Inputs/empty_range -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + + .section __TEXT,__text,regular,pure_instructions + .macosx_version_min 10, 11 + .globl __Z3foov + .align 4, 0x90 +__Z3foov: ## @_Z3foov +Lfunc_begin0: + pushq %rbp + movq %rsp, %rbp + popq %rbp + retq +Lfunc_end0: + .section __DWARF,__debug_abbrev,regular,debug +Lsection_abbrev: + .byte 1 ## Abbreviation Code + .byte 17 ## DW_TAG_compile_unit + .byte 1 ## DW_CHILDREN_yes + .byte 0 ## EOM(1) + .byte 0 ## EOM(2) + .byte 2 ## Abbreviation Code + .byte 46 ## DW_TAG_subprogram + .byte 0 ## DW_CHILDREN_no + .byte 17 ## DW_AT_low_pc + .byte 1 ## DW_FORM_addr + .byte 0x55 ## DW_AT_ranges + .byte 6 ## DW_FORM_data4 + .byte 0 ## EOM(1) + .byte 0 ## EOM(2) + .byte 0 ## EOM(3) + .section __DWARF,__debug_info,regular,debug +Lsection_info: + .long 22 ## Length of Unit + .short 2 ## DWARF version number + .long 0 ## Offset Into Abbrev. Section + .byte 8 ## Address Size (in bytes) + .byte 1 ## Abbrev [1] DW_TAG_compile_unit + .byte 2 ## Abbrev [2] DW_TAG_subprogram + .quad Lfunc_begin0 ## DW_AT_low_pc + .long 0 ## DW_AT_ranges (pointing at an empty entry) + .byte 0 ## End Of Children Mark + .section __DWARF,__debug_ranges,regular,debug +Ldebug_range: + .long 0 + .long 0 + +# CHECK: DW_TAG_compile_unit +# CHECK: DW_TAG_subprogram +# CHECK-NEXT: DW_AT_low_pc{{.*}}(0x0000000000010000) +# CHECK-NEXT: DW_AT_ranges{{.*}}(0x00000000) + +# There was a bug that would use the currently active object file when a +# debug map object isn't found. Check that we only linked one file. +# CHECK-NOT: DW_TAG_compile_unit + diff --git a/test/tools/dsymutil/X86/fat-archive-input-i386.test b/test/tools/dsymutil/X86/fat-archive-input-i386.test new file mode 100644 index 000000000000..f4ea288768c8 --- /dev/null +++ b/test/tools/dsymutil/X86/fat-archive-input-i386.test @@ -0,0 +1,16 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +--- +triple: 'i386-apple-darwin' +objects: + - filename: libfat-test.a(fat-test.o) + symbols: + - { sym: _i386_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 } +... + +# CHECK: .debug_info contents: +# CHECK: DW_TAG_variable +# CHECK-NOT: {{DW_TAG|NULL}} +# CHECK: DW_AT_name{{.*}}"i386_var" + diff --git a/test/tools/dsymutil/X86/fat-object-input-x86_64.test b/test/tools/dsymutil/X86/fat-object-input-x86_64.test new file mode 100644 index 000000000000..cdd5a4c08d9c --- /dev/null +++ b/test/tools/dsymutil/X86/fat-object-input-x86_64.test @@ -0,0 +1,16 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +--- +triple: 'x86_64-apple-darwin' +objects: + - filename: fat-test.o + symbols: + - { sym: _x86_64_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 } +... + +# CHECK: .debug_info contents: +# CHECK: DW_TAG_variable +# CHECK-NOT: {{DW_TAG|NULL}} +# CHECK: DW_AT_name{{.*}}"x86_64_var" + diff --git a/test/tools/dsymutil/X86/fat-object-input-x86_64h.test b/test/tools/dsymutil/X86/fat-object-input-x86_64h.test new file mode 100644 index 000000000000..53aed1ec4443 --- /dev/null +++ b/test/tools/dsymutil/X86/fat-object-input-x86_64h.test @@ -0,0 +1,16 @@ +# REQUIRES: object-emission +# RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs -y %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +--- +triple: 'x86_64h-apple-darwin' +objects: + - filename: fat-test.o + symbols: + - { sym: _x86_64h_var, objAddr: 0x0, binAddr: 0x1000, size: 0x4 } +... + +# CHECK: .debug_info contents: +# CHECK: DW_TAG_variable +# CHECK-NOT: {{DW_TAG|NULL}} +# CHECK: DW_AT_name{{.*}}"x86_64h_var" + diff --git a/test/tools/dsymutil/X86/frame-1.test b/test/tools/dsymutil/X86/frame-1.test index 7852e68a142a..27bc17d75984 100644 --- a/test/tools/dsymutil/X86/frame-1.test +++ b/test/tools/dsymutil/X86/frame-1.test @@ -2,14 +2,14 @@ # RUN: rm -rf %t # RUN: mkdir -p %t # RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o -# RUN: llvm-dsymutil -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s +# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s # This test is meant to verify that identical CIEs will get reused # in the same file but also inbetween files. For this to happen, we # link twice the same file using this made-up debug map: --- -triple: 'i386-unknown-unknown-macho' +triple: 'i386-apple-darwin' objects: - filename: frame-dw2.o symbols: diff --git a/test/tools/dsymutil/X86/frame-2.test b/test/tools/dsymutil/X86/frame-2.test index 168e342a4f74..89a7670f86f0 100644 --- a/test/tools/dsymutil/X86/frame-2.test +++ b/test/tools/dsymutil/X86/frame-2.test @@ -3,7 +3,7 @@ # RUN: mkdir -p %t # RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o # RUN: llc -filetype=obj %p/../Inputs/frame-dw4.ll -o %t/frame-dw4.o -# RUN: llvm-dsymutil -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s +# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-dump=frames - | FileCheck %s # Check the handling of multiple different CIEs. To have CIEs that # appear to be different, use a dwarf2 version of the file along with @@ -12,7 +12,7 @@ # appears again. This is a behavior we inherited from dsymutil-classic # but this should be fixed (see comment in patchFrameInfoForObject()) --- -triple: 'i386-unknown-unknown-macho' +triple: 'i386-apple-darwin' objects: - filename: frame-dw2.o symbols: diff --git a/test/tools/dsymutil/X86/lit.local.cfg b/test/tools/dsymutil/X86/lit.local.cfg index c8625f4d9d24..05f8b38b3346 100644 --- a/test/tools/dsymutil/X86/lit.local.cfg +++ b/test/tools/dsymutil/X86/lit.local.cfg @@ -1,2 +1,4 @@ if not 'X86' in config.root.targets: config.unsupported = True + +config.suffixes = ['.test', '.cpp', '.m', '.s'] diff --git a/test/tools/dsymutil/X86/mismatch.m b/test/tools/dsymutil/X86/mismatch.m new file mode 100644 index 000000000000..33ae782df057 --- /dev/null +++ b/test/tools/dsymutil/X86/mismatch.m @@ -0,0 +1,23 @@ +/* Compile with: + cat >modules.modulemap <<EOF + module mismatch { + header "mismatch.h" + } + EOF + echo "struct s;"> mismatch.h + clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \ + -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \ + -fdisable-module-hash mismatch.m -o 1.o + echo > mismatch.h + clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \ + -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \ + -fdisable-module-hash mismatch.m -o /dev/null +*/ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/mismatch \ +// RUN: -y %p/dummy-debug-map.map -o %t.bin 2>&1 | FileCheck %s + +@import mismatch; + +void f() {} +// CHECK: warning: hash mismatch diff --git a/test/tools/dsymutil/X86/modules.m b/test/tools/dsymutil/X86/modules.m new file mode 100644 index 000000000000..046a8c1304a0 --- /dev/null +++ b/test/tools/dsymutil/X86/modules.m @@ -0,0 +1,117 @@ +/* Compile with: + cat >modules.modulemap <<EOF + module Foo { + header "Foo.h" + export * + } + module Bar { + header "Bar.h" + export * + } +EOF + clang -D BAR_H -E -o Bar.h modules.m + clang -D FOO_H -E -o Foo.h modules.m + clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \ + -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \ + -fdisable-module-hash modules.m -o 1.o +*/ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/modules \ +// RUN: -y %p/dummy-debug-map.map -o - \ +// RUN: | llvm-dwarfdump --debug-dump=info - | FileCheck %s + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/modules -y \ +// RUN: %p/dummy-debug-map.map -o %t 2>&1 | FileCheck --check-prefix=WARN %s + +// WARN-NOT: warning: hash mismatch + +// --------------------------------------------------------------------- +#ifdef BAR_H +// --------------------------------------------------------------------- +// CHECK: DW_TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Bar" +// CHECK: 0x0[[BAR:.*]]: DW_TAG_structure_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"Bar" +// CHECK-NOT: DW_TAG +// CHECK: DW_TAG_member +// CHECK: DW_AT_name {{.*}}"value" +// CHECK: DW_TAG_structure_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"PruneMeNot" + +struct Bar { + int value; +}; + +struct PruneMeNot; + +#else +// --------------------------------------------------------------------- +#ifdef FOO_H +// --------------------------------------------------------------------- +// CHECK: DW_TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: 0x0[[FOO:.*]]: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Foo" +// CHECK-NOT: DW_TAG +// CHECK: DW_TAG_typedef +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x{{0*}}[[BAR]]) +// CHECK: DW_TAG_structure_type +// CHECK-NEXT: DW_AT_name{{.*}}"S" +// CHECK-NOT: DW_TAG +// CHECK: 0x0[[INTERFACE:.*]]: DW_TAG_structure_type +// CHECK-NEXT: DW_AT_name{{.*}}"Foo" + +@import Bar; +typedef struct Bar Bar; +struct S {}; + +@interface Foo { + int ivar; +} +@end + +// --------------------------------------------------------------------- +#else +// --------------------------------------------------------------------- + +// CHECK: DW_TAG_compile_unit +// CHECK: DW_AT_low_pc +// CHECK-NOT:DW_TAG +// CHECK: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Foo" +// CHECK-NOT: DW_TAG +// CHECK: DW_TAG_typedef +// CHECK-NOT: DW_TAG +// CHECK: NULL +// +// CHECK: DW_TAG_imported_declaration +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_import [DW_FORM_ref_addr] (0x{{0*}}[[FOO]] +// +// CHECK: DW_TAG_subprogram +// CHECK: DW_AT_name {{.*}}"main" +// +// CHECK: DW_TAG_variable +// CHECK: DW_TAG_variable +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name{{.*}}"foo" +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_type {{.*}}{0x{{0*}}[[PTR:.*]]} +// +// CHECK: 0x{{0*}}[[PTR]]: DW_TAG_pointer_type +// CHECK-NEXT DW_AT_type [DW_FORM_ref_addr] {0x{{0*}}[[INTERFACE]]) + +@import Foo; +int main(int argc, char **argv) { + Bar bar; + Foo *foo = 0; + bar.value = 42; + return bar.value; +} +#endif +#endif diff --git a/test/tools/dsymutil/X86/multiple-inputs.test b/test/tools/dsymutil/X86/multiple-inputs.test new file mode 100644 index 000000000000..01b4f1bf52b5 --- /dev/null +++ b/test/tools/dsymutil/X86/multiple-inputs.test @@ -0,0 +1,31 @@ +RUN: rm -rf %T/multiple-inputs +RUN: mkdir -p %T/multiple-inputs + +RUN: cat %p/../Inputs/basic.macho.x86_64 > %T/multiple-inputs/basic.macho.x86_64 +RUN: cat %p/../Inputs/basic-archive.macho.x86_64 > %T/multiple-inputs/basic-archive.macho.x86_64 +RUN: cat %p/../Inputs/basic-lto.macho.x86_64 > %T/multiple-inputs/basic-lto.macho.x86_64 +RUN: cat %p/../Inputs/basic-lto-dw4.macho.x86_64 > %T/multiple-inputs/basic-lto-dw4.macho.x86_64 + +# Multiple inputs in flat mode +RUN: llvm-dsymutil -f -oso-prepend-path=%p/.. %T/multiple-inputs/basic.macho.x86_64 %T/multiple-inputs/basic-archive.macho.x86_64 %T/multiple-inputs/basic-lto.macho.x86_64 %T/multiple-inputs/basic-lto-dw4.macho.x86_64 +RUN: llvm-dwarfdump %T/multiple-inputs/basic.macho.x86_64.dwarf \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=BASIC +RUN: llvm-dwarfdump %T/multiple-inputs/basic-archive.macho.x86_64.dwarf \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=ARCHIVE +RUN: llvm-dwarfdump %T/multiple-inputs/basic-lto.macho.x86_64.dwarf | FileCheck %S/basic-lto-linking-x86.test +RUN: llvm-dwarfdump %T/multiple-inputs/basic-lto-dw4.macho.x86_64.dwarf | FileCheck %S/basic-lto-dw4-linking-x86.test + +# Multiple inputs that end up in the same named bundle +RUN: llvm-dsymutil -oso-prepend-path=%p/.. %T/multiple-inputs/basic.macho.x86_64 %T/multiple-inputs/basic-archive.macho.x86_64 %T/multiple-inputs/basic-lto.macho.x86_64 %T/multiple-inputs/basic-lto-dw4.macho.x86_64 -o %t.dSYM +RUN: llvm-dwarfdump %t.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=BASIC +RUN: llvm-dwarfdump %t.dSYM/Contents/Resources/DWARF/basic-archive.macho.x86_64 \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=ARCHIVE +RUN: llvm-dwarfdump %t.dSYM/Contents/Resources/DWARF/basic-lto.macho.x86_64 | FileCheck %S/basic-lto-linking-x86.test +RUN: llvm-dwarfdump %t.dSYM/Contents/Resources/DWARF/basic-lto-dw4.macho.x86_64 | FileCheck %S/basic-lto-dw4-linking-x86.test + +# Multiple inputs in a named bundle in flat mode... impossible. +RUN: not llvm-dsymutil -f -oso-prepend-path=%p/.. %T/multiple-inputs/basic.macho.x86_64 %T/multiple-inputs/basic-archive.macho.x86_64 %T/multiple-inputs/basic-lto.macho.x86_64 %T/multiple-inputs/basic-lto-dw4.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s + +CHECK: error: cannot use -o with multiple inputs in flat mode + diff --git a/test/tools/dsymutil/X86/odr-anon-namespace.cpp b/test/tools/dsymutil/X86/odr-anon-namespace.cpp new file mode 100644 index 000000000000..a66fc830b67a --- /dev/null +++ b/test/tools/dsymutil/X86/odr-anon-namespace.cpp @@ -0,0 +1,65 @@ +/* Compile with: + for FILE in `seq 2`; do + clang -g -c odr-anon-namespace.cpp -DFILE$FILE -o odr-anon-namespace/$FILE.o + done + */ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/odr-anon-namespace -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +#ifdef FILE1 +// Currently llvm-dsymutil will unique the contents of anonymous +// namespaces if they are from the same file/line. Force this +// namespace to appear different eventhough it's the same (this +// uniquing is actually a bug kept for backward compatibility, see the +// comments in DeclContextTree::getChildDeclContext()). +#line 42 +#endif +namespace { +class C {}; +} + +void foo() { + C c; +} + +// Keep the ifdef guards for FILE1 and FILE2 even if all the code is +// above to clearly show what the CHECK lines are testing. +#ifdef FILE1 + +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-anon-namespace.cpp" + +// CHECK: DW_TAG_variable +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"c" +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_type {{.*}}0x00000000[[C_FILE1:[0-9a-f]*]] + +// CHECK: DW_TAG_namespace +// CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}} +// CHECK: 0x[[C_FILE1]]:{{.*}}DW_TAG_class_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name{{.*}}"C" + +#elif defined(FILE2) + +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-anon-namespace.cpp" + +// CHECK: DW_TAG_variable +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"c" +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_type {{.*}}0x00000000[[C_FILE2:[0-9a-f]*]] + +// CHECK: DW_TAG_namespace +// CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}} +// CHECK: 0x[[C_FILE2]]:{{.*}}DW_TAG_class_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name{{.*}}"C" + +#else +#error "You must define which file you generate" +#endif diff --git a/test/tools/dsymutil/X86/odr-member-functions.cpp b/test/tools/dsymutil/X86/odr-member-functions.cpp new file mode 100644 index 000000000000..737d5a7abf61 --- /dev/null +++ b/test/tools/dsymutil/X86/odr-member-functions.cpp @@ -0,0 +1,109 @@ +/* Compile with: + for FILE in `seq 3`; do + clang -g -c odr-member-functions.cpp -DFILE$FILE -o odr-member-functions/$FILE.o + done + */ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/odr-member-functions -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +struct S { + __attribute__((always_inline)) void foo() { bar(); } + __attribute__((always_inline)) void foo(int i) { if (i) bar(); } + void bar(); + + template<typename T> void baz(T t) {} +}; + +#ifdef FILE1 +void foo() { + S s; +} + +// CHECK: TAG_compile_unit +// CHECK-NOT: {{DW_TAG|NULL}} +// CHECK: AT_name{{.*}}"odr-member-functions.cpp" + +// CHECK: 0x[[S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// CHECK-NOT: {{DW_TAG|NULL}} +// CHECK: DW_AT_name{{.*}}"S" +// CHECK-NOT: NULL +// CHECK: 0x[[FOO:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram +// CHECK-NEXT: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEv" +// CHECK: NULL +// CHECK: 0x[[FOOI:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram +// CHECK-NEXT: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEi" + +#elif defined(FILE2) +void foo() { + S s; + // Check that the overloaded member functions are resolved correctly + s.foo(); + s.foo(1); +} + +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-member-functions.cpp" + +// Normal member functions should be desribed by the type in the first +// CU, thus we should be able to reuse its definition and avoid +// reemiting it. +// CHECK-NOT: DW_TAG_structure_type + +// CHECK: 0x[[FOO_SUB:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram +// CHECK-NEXT: DW_AT_specification{{.*}}[[FOO]] +// CHECK-NOT: DW_TAG_structure_type +// CHECK: 0x[[FOOI_SUB:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram +// CHECK-NEXT: DW_AT_specification{{.*}}[[FOOI]] +// CHECK-NOT: DW_TAG_structure_type + +// CHECK: DW_TAG_variable +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"s" +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_type {{.*}}[[S]]) +// CHECK: DW_TAG_inlined_subroutine +// CHECK-NEXT: DW_AT_abstract_origin{{.*}}[[FOO_SUB]] +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_call_line{{.*}}40 +// CHECK: DW_TAG_inlined_subroutine +// CHECK-NEXT: DW_AT_abstract_origin{{.*}}[[FOOI_SUB]] +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_call_line{{.*}}41 + +#elif defined(FILE3) +void foo() { + S s; + s.baz<int>(42); +} + +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-member-functions.cpp" + +// Template or other implicit members will be included in the type +// only if they are generated. Thus actually creating a new type. +// CHECK: DW_TAG_structure_type + +// Skip 'normal' member functions +// CHECK: DW_TAG_subprogram +// CHECK: DW_TAG_subprogram +// CHECK: DW_TAG_subprogram + +// This is the 'baz' member +// CHECK: 0x[[BAZ:[0-9a-f]*]]: DW_TAG_subprogram +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_MIPS_linkage_name {{.*}}"_ZN1S3bazIiEEvT_" +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"baz<int>" + +// Skip foo3 +// CHECK: DW_TAG_subprogram + +// baz instanciation: +// CHECK: DW_TAG_subprogram +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_specification {{.*}}[[BAZ]] "_ZN1S3bazIiEEvT_" +#else +#error "You must define which file you generate" +#endif diff --git a/test/tools/dsymutil/X86/odr-uniquing.cpp b/test/tools/dsymutil/X86/odr-uniquing.cpp new file mode 100644 index 000000000000..bb7ae50a2c72 --- /dev/null +++ b/test/tools/dsymutil/X86/odr-uniquing.cpp @@ -0,0 +1,187 @@ +/* Compile with: + clang -g -c odr-uniquing.cpp -o odr-uniquing/1.o + cp odr-uniquing/1.o odr-uniquing/2.o + The aim of these test is to check that all the 'type types' that + should be uniqued through the ODR really are. + + The resulting object file is linked against itself using a fake + debug map. The end result is: + - with ODR uniquing: all types (expect for the union for now) in + the second CU should point back to the types of the first CU. + - without ODR uniquing: all types are re-emited in the second CU + */ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -debug-dump=info - | FileCheck -check-prefix=ODR -check-prefix=CHECK %s +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/odr-uniquing -y %p/dummy-debug-map.map -no-odr -o - | llvm-dwarfdump -debug-dump=info - | FileCheck -check-prefix=NOODR -check-prefix=CHECK %s + +// The first compile unit contains all the types: +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-uniquing.cpp" + +struct S { + struct Nested {}; +}; + +// CHECK: 0x[[S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// CHECK-NEXT: DW_AT_name{{.*}}"S" +// CHECK-NOT: NULL +// CHECK: 0x[[NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name{{.*}}"Nested" +// CHECK: NULL + +namespace N { +class C {}; +} + +// CHECK: DW_TAG_namespace +// CHECK-NEXT: DW_AT_name{{.*}}"N" +// CHECK-NOT: NULL +// CHECK: 0x[[NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type +// CHECK-NEXT: DW_AT_name{{.*}}"C" +// CHECK: NULL + +union U { + class C {} C; + struct S {} S; +}; + +// CHECK: 0x[[U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type +// CHECK-NEXT: DW_AT_name{{.*}}"U" +// CHECK-NOT: NULL +// CHECK: 0x[[UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type +// CHECK-NOT: NULL +// CHECK: 0x[[US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// CHECK: NULL + +typedef S AliasForS; + +// CHECK: 0x[[ALIASFORS:[0-9a-f]*]]:{{.*}}DW_TAG_typedef +// CHECK-NEXT: DW_AT_type{{.*}}[[S]] +// CHECK-NEXT: DW_AT_name{{.*}}"AliasForS" + +namespace { +class AnonC {}; +} + +// CHECK: DW_TAG_namespace +// CHECK-NOT: {{DW_AT_name|NULL|DW_TAG}} +// CHECK: 0x[[ANONC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type +// CHECK-NEXT: DW_AT_name{{.*}}"AnonC" + +// This function is only here to hold objects that refer to the above types. +void foo() { + AliasForS s; + S::Nested n; + N::C nc; + AnonC ac; + U u; +} + +// The second CU contents depend on wether we disabled ODR uniquing or +// not. + +// CHECK: TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: AT_name{{.*}}"odr-uniquing.cpp" + +// The union itself is not uniqued for now (for dsymutil-compatibility), +// but the types defined inside it should be. +// ODR: DW_TAG_union_type +// ODR-NEXT: DW_AT_name{{.*}}"U" +// ODR: DW_TAG_member +// ODR-NEXT: DW_AT_name{{.*}}"C" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[UC]] +// ODR: DW_TAG_member +// ODR-NEXT: DW_AT_name{{.*}}"S" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[US]] + +// Check that the variables point to the right type +// ODR: DW_TAG_subprogram +// ODR-NOT: DW_TAG +// ODR: DW_AT_name{{.*}}"foo" +// ODR-NOT: NULL +// ODR: DW_TAG_variable +// ODR-NOT: DW_TAG +// ODR: DW_AT_name{{.*}}"s" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[ALIASFORS]] +// ODR: DW_AT_name{{.*}}"n" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[NESTED]] +// ODR: DW_TAG_variable +// ODR-NOT: DW_TAG +// ODR: DW_AT_name{{.*}}"nc" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[NC]] +// ODR: DW_TAG_variable +// ODR-NOT: DW_TAG +// ODR: DW_AT_name{{.*}}"ac" +// ODR-NOT: DW_TAG +// ODR: DW_AT_type{{.*}}[[ANONC]] + +// With no ODR uniquing, we should get copies of all the types: + +// This is "struct S" +// NOODR: 0x[[DUP_S:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// NOODR-NEXT: DW_AT_name{{.*}}"S" +// NOODR-NOT: NULL +// NOODR: 0x[[DUP_NESTED:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"Nested" + +// This is "class N::C" +// NOODR: DW_TAG_namespace +// NOODR-NEXT: DW_AT_name{{.*}}"N" +// NOODR: 0x[[DUP_NC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type +// NOODR-NEXT: DW_AT_name{{.*}}"C" + +// This is "union U" +// NOODR: 0x[[DUP_U:[0-9a-f]*]]:{{.*}}DW_TAG_union_type +// NOODR-NEXT: DW_AT_name{{.*}}"U" +// NOODR-NOT: NULL +// NOODR: 0x[[DUP_UC:[0-9a-f]*]]:{{.*}}DW_TAG_class_type +// NOODR-NOT: NULL +// NOODR: 0x[[DUP_US:[0-9a-f]*]]:{{.*}}DW_TAG_structure_type +// NOODR: NULL + +// Check that the variables point to the right type +// NOODR: DW_TAG_subprogram +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"foo" +// NOODR-NOT: NULL +// NOODR: DW_TAG_variable +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"s" +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_type{{.*}}0x[[DUP_ALIASFORS:[0-9a-f]*]] +// NOODR: DW_TAG_variable +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"n" +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_type{{.*}}[[DUP_NESTED]] +// NOODR: DW_TAG_variable +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"nc" +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_type{{.*}}[[DUP_NC]] +// NOODR: DW_TAG_variable +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"ac" +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_type{{.*}}0x[[DUP_ANONC:[0-9a-f]*]] + +// This is "AliasForS" +// NOODR: 0x[[DUP_ALIASFORS]]:{{.*}}DW_TAG_typedef +// NOODR-NOT: DW_TAG +// NOODR: DW_AT_name{{.*}}"AliasForS" + +// This is "(anonymous namespace)::AnonC" +// NOODR: DW_TAG_namespace +// NOODR-NOT: {{DW_AT_name|NULL|DW_TAG}} +// NOODR: 0x[[DUP_ANONC]]:{{.*}}DW_TAG_class_type +// NOODR-NEXT: DW_AT_name{{.*}}"AnonC" + diff --git a/test/tools/dsymutil/X86/submodules.m b/test/tools/dsymutil/X86/submodules.m new file mode 100644 index 000000000000..b2425a91cbda --- /dev/null +++ b/test/tools/dsymutil/X86/submodules.m @@ -0,0 +1,52 @@ +/* Compile with: + cat >modules.modulemap <<EOF + module Parent { + module Child { + header "Child.h" + } + module Empty { + header "Empty.h" + } + } +EOF + clang -D CHILD_H -E -o Child.h submodules.m + touch empty.h + clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \ + -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \ + -fdisable-module-hash submodules.m -o 1.o +*/ + +// RUN: llvm-dsymutil -f -oso-prepend-path=%p/../Inputs/submodules \ +// RUN: -y %p/dummy-debug-map.map -o - \ +// RUN: | llvm-dwarfdump --debug-dump=info - | FileCheck %s + +// --------------------------------------------------------------------- +#ifdef CHILD_H +// --------------------------------------------------------------------- + +// CHECK: DW_TAG_compile_unit +// CHECK-NOT: DW_TAG +// CHECK: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Parent" +// CHECK: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Child" +// CHECK: DW_TAG_structure_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"PruneMeNot" +struct PruneMeNot; + +// --------------------------------------------------------------------- +#else +// --------------------------------------------------------------------- + +// CHECK: DW_TAG_compile_unit +// CHECK: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Parent" +// CHECK: 0x0[[EMPTY:.*]]: DW_TAG_module +// CHECK-NEXT: DW_AT_name{{.*}}"Empty" + +// CHECK: DW_AT_import {{.*}}0x{{0*}}[[EMPTY]] +@import Parent.Child; +@import Parent.Empty; +int main(int argc, char **argv) { return 0; } +#endif diff --git a/test/tools/dsymutil/absolute_symbol.test b/test/tools/dsymutil/absolute_symbol.test new file mode 100644 index 000000000000..cdd6ae832136 --- /dev/null +++ b/test/tools/dsymutil/absolute_symbol.test @@ -0,0 +1,16 @@ +RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s + +The tested object file has been created by the dummy Objective-C code: +@interface Foo +@end + +@implementation Foo +@end + +int main() { return 0; } + +compiled for i386. This create an absolute symbol .objc_class_name_Foo +We must not consider this symbol for debug info linking as its address +might conflict with other real symbols in the same file. + +CHECK-NOT: objc_class_name_Foo diff --git a/test/tools/dsymutil/arch-option.test b/test/tools/dsymutil/arch-option.test new file mode 100644 index 000000000000..0920efb529d6 --- /dev/null +++ b/test/tools/dsymutil/arch-option.test @@ -0,0 +1,39 @@ +Processing of the -arch option happens at debug map parsing time, thus just +looking at the dumped debug maps is enough to validate their effects. + +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib | FileCheck %s -check-prefix=ARM64 -check-prefix=ARMV7S -check-prefix=ARMV7 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch all | FileCheck %s -check-prefix=ARM64 -check-prefix=ARMV7S -check-prefix=ARMV7 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch='*' | FileCheck %s -check-prefix=ARM64 -check-prefix=ARMV7S -check-prefix=ARMV7 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 | FileCheck %s -check-prefix=ARM64 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm | FileCheck %s -check-prefix=ARMV7S -check-prefix=ARMV7 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch armv7 | FileCheck %s -check-prefix=ARMV7 -check-prefix=CHECK +RUN: llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm64 -arch armv7s | FileCheck %s -check-prefix=ARM64 -check-prefix=ARMV7S -check-prefix=CHECK +RUN: not llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch arm42 2>&1 | FileCheck %s -check-prefix=BADARCH +RUN: not llvm-dsymutil -oso-prepend-path %p -dump-debug-map %p/Inputs/fat-test.arm.dylib -arch i386 2>&1 | FileCheck %s -check-prefix=EMPTY + + +ARMV7: --- +ARMV7-NOT: ... +ARMV7: triple: 'thumbv7-apple-darwin' +ARMV7-NOT: ... +ARMV7: sym: _armv7_var +ARMV7-NOT: --- + +ARMV7S: --- +ARMV7S-NOT: ... +ARMV7S: triple: 'thumbv7s-apple-darwin' +ARMV7S-NOT: ... +ARMV7S: sym: _armv7s_var +ARMV7S-NOT: --- + +ARM64: --- +ARM64-NOT: ... +ARM64: triple: 'arm64-apple-darwin' +ARM64-NOT: ... +ARM64: sym: _arm64_var +ARM64-NOT: --- + +CHECK: ... + +BADARCH: error: Unsupported cpu architecture: 'arm42' +EMPTY: error: no architecture to link diff --git a/test/tools/dsymutil/archive-timestamp.test b/test/tools/dsymutil/archive-timestamp.test new file mode 100644 index 000000000000..f3f2162fa595 --- /dev/null +++ b/test/tools/dsymutil/archive-timestamp.test @@ -0,0 +1,24 @@ +# RUN: llvm-dsymutil -no-output -oso-prepend-path=%p -y %s 2>&1 | FileCheck %s + +# This is the archive member part of basic-archive.macho.x86_64 debug map with corrupted timestamps. + +# CHECK: warning: {{.*}}libbasic.a(basic2.macho.x86_64.o): {{[Nn]o}} such file +# CHECK: warning: {{.*}}libbasic.a(basic3.macho.x86_64.o): {{[Nn]o}} such file + +--- +triple: 'x86_64-apple-darwin' +objects: + - filename: '/Inputs/libbasic.a(basic2.macho.x86_64.o)' + timestamp: 141869239 + symbols: + - { sym: _foo, objAddr: 0x0000000000000020, binAddr: 0x0000000100000ED0, size: 0x00000050 } + - { sym: _private_int, objAddr: 0x0000000000000560, binAddr: 0x0000000100001004, size: 0x00000000 } + - { sym: _inc, objAddr: 0x0000000000000070, binAddr: 0x0000000100000F20, size: 0x00000017 } + - { sym: _baz, objAddr: 0x0000000000000310, binAddr: 0x0000000100001000, size: 0x00000000 } + - filename: '/Inputs/libbasic.a(basic3.macho.x86_64.o)' + timestamp: 418692393 + symbols: + - { sym: _val, objAddr: 0x0000000000000004, binAddr: 0x0000000100001008, size: 0x00000000 } + - { sym: _bar, objAddr: 0x0000000000000020, binAddr: 0x0000000100000F40, size: 0x00000050 } + - { sym: _inc, objAddr: 0x0000000000000070, binAddr: 0x0000000100000F90, size: 0x00000019 } +... diff --git a/test/tools/dsymutil/basic-linking.test b/test/tools/dsymutil/basic-linking.test index ec6a5b771461..bff5b5df9e66 100644 --- a/test/tools/dsymutil/basic-linking.test +++ b/test/tools/dsymutil/basic-linking.test @@ -1,6 +1,7 @@ -RUN: llvm-dsymutil -no-output -v -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s -RUN: llvm-dsymutil -no-output -v -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO -RUN: llvm-dsymutil -no-output -v -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE +RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s +RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO +RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE +RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 %p/Inputs/basic-lto.macho.x86_64 %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LTO --check-prefix=CHECK-ARCHIVE This test check the basic Dwarf linking process through the debug dumps. diff --git a/test/tools/dsymutil/debug-map-parsing.test b/test/tools/dsymutil/debug-map-parsing.test index 5091dfbfc24d..2b9d0917609d 100644 --- a/test/tools/dsymutil/debug-map-parsing.test +++ b/test/tools/dsymutil/debug-map-parsing.test @@ -1,15 +1,16 @@ -RUN: llvm-dsymutil -v -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s -RUN: llvm-dsymutil -v -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO -RUN: llvm-dsymutil -v -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE -RUN: llvm-dsymutil -v -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=NOT-FOUND -RUN: not llvm-dsymutil -v -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck %s --check-prefix=NO-EXECUTABLE +RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s +RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO +RUN: llvm-dsymutil -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE +RUN: llvm-dsymutil -dump-debug-map %p/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefix=NOT-FOUND +RUN: not llvm-dsymutil -dump-debug-map %p/Inputs/inexistant 2>&1 | FileCheck %s --check-prefix=NO-EXECUTABLE Check that We can parse the debug map of the basic executable. CHECK-NOT: error CHECK: --- -CHECK: triple: 'x86_64-unknown-unknown-macho' +CHECK: triple: 'x86_64-apple-darwin' +CHECK: binary-path:{{.*}}/Inputs/basic.macho.x86_64 CHECK: filename:{{.*}}/Inputs/basic1.macho.x86_64.o CHECK-DAG: sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000EA0, size: 0x00000024 CHECK: filename{{.*}}/Inputs/basic2.macho.x86_64.o @@ -28,7 +29,8 @@ Check that we can parse the debug-map of the basic-lto executable CHECK-LTO-NOT: error CHECK-LTO: --- -CHECK-LTO: triple: 'x86_64-unknown-unknown-macho' +CHECK-LTO: triple: 'x86_64-apple-darwin' +CHECK-LTO: binary-path:{{.*}}/Inputs/basic-lto.macho.x86_64 CHECK-LTO: /Inputs/basic-lto.macho.x86_64.o CHECK-LTO-DAG: sym: _bar, objAddr: 0x0000000000000050, binAddr: 0x0000000100000F90, size: 0x00000024 CHECK-LTO-DAG: sym: _baz, objAddr: 0x0000000000000658, binAddr: 0x0000000100001000, size: 0x00000000 @@ -51,7 +53,8 @@ CHECK-ARCHIVE-NEXT: found member in current archive. CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic3.macho.x86_64.o)' CHECK-ARCHIVE-NEXT: found member in current archive. CHECK-ARCHIVE: --- -CHECK-ARCHIVE: triple: 'x86_64-unknown-unknown-macho' +CHECK-ARCHIVE: triple: 'x86_64-apple-darwin' +CHECK-ARCHIVE: binary-path:{{.*}}/Inputs/basic-archive.macho.x86_64 CHECK-ARCHIVE: /Inputs/basic1.macho.x86_64.o CHECK-ARCHIVE-DAG: sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000EA0, size: 0x00000024 CHECK-ARCHIVE: /Inputs/./libbasic.a(basic2.macho.x86_64.o) @@ -72,7 +75,8 @@ NOT-FOUND: cannot open{{.*}}"/Inputs/basic1.macho.x86_64.o": {{[Nn]o}} such file NOT-FOUND: cannot open{{.*}}"/Inputs/basic2.macho.x86_64.o": {{[Nn]o}} such file NOT-FOUND: cannot open{{.*}}"/Inputs/basic3.macho.x86_64.o": {{[Nn]o}} such file NOT-FOUND: --- -NOT-FOUND-NEXT: triple: 'x86_64-unknown-unknown-macho' +NOT-FOUND-NEXT: triple: 'x86_64-apple-darwin' +NOT-FOUND-NEXT: binary-path:{{.*}}/Inputs/basic.macho.x86_64 NOT-FOUND-NEXT: ... Check that we correctly error out on invalid executatble. diff --git a/test/tools/dsymutil/dump-symtab.test b/test/tools/dsymutil/dump-symtab.test new file mode 100644 index 000000000000..b83ac7f7ad17 --- /dev/null +++ b/test/tools/dsymutil/dump-symtab.test @@ -0,0 +1,44 @@ +RUN: llvm-dsymutil -s %p/Inputs/fat-test.dylib | FileCheck -check-prefix=ALL -check-prefix=I386 %s +RUN: llvm-dsymutil -arch i386 -s %p/Inputs/fat-test.dylib | FileCheck -check-prefix=I386 -check-prefix=ONE %s + + +ALL: ---------------------------------------------------------------------- +ALL-NEXT: Symbol table for: '{{.*}}fat-test.dylib' (x86_64) +ALL-NEXT: ---------------------------------------------------------------------- +ALL-NEXT: Index n_strx n_type n_sect n_desc n_value +ALL-NEXT: ======== -------- ------------------ ------ ------ ---------------- +ALL-NEXT: [ 0] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Inputs/' +ALL-NEXT: [ 1] 0000000b 64 (N_SO ) 00 0000 0000000000000000 'fat-test.c' +ALL-NEXT: [ 2] 00000016 66 (N_OSO ) 03 0001 0000000055b1d0b9 '/Inputs/fat-test.o' +ALL-NEXT: [ 3] 00000029 20 (N_GSYM ) 00 0000 0000000000000000 '_x86_64_var' +ALL-NEXT: [ 4] 00000001 64 (N_SO ) 01 0000 0000000000000000 +ALL-NEXT: [ 5] 00000035 0f ( SECT EXT) 02 0000 0000000000001000 '_x86_64_var' +ALL-NEXT: [ 6] 00000041 01 ( UNDF EXT) 00 0100 0000000000000000 'dyld_stub_binder' + +I386: ---------------------------------------------------------------------- +I386-NEXT: Symbol table for: '{{.*}}fat-test.dylib' (i386) +I386-NEXT: ---------------------------------------------------------------------- +I386-NEXT: Index n_strx n_type n_sect n_desc n_value +I386-NEXT: ======== -------- ------------------ ------ ------ ---------------- +I386-NEXT: [ 0] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Inputs/' +I386-NEXT: [ 1] 0000000b 64 (N_SO ) 00 0000 0000000000000000 'fat-test.c' +I386-NEXT: [ 2] 00000016 66 (N_OSO ) 03 0001 0000000055b1d0b9 '/Inputs/fat-test.o' +I386-NEXT: [ 3] 00000029 20 (N_GSYM ) 00 0000 0000000000000000 '_i386_var' +I386-NEXT: [ 4] 00000001 64 (N_SO ) 01 0000 0000000000000000 +I386-NEXT: [ 5] 00000033 0f ( SECT EXT) 02 0000 0000000000001000 '_i386_var' +I386-NEXT: [ 6] 0000003d 01 ( UNDF EXT) 00 0100 0000000000000000 'dyld_stub_binder' + +ONE-NOT: Symbol table + +ALL: ---------------------------------------------------------------------- +ALL-NEXT: Symbol table for: '{{.*}}fat-test.dylib' (x86_64h) +ALL-NEXT: ---------------------------------------------------------------------- +ALL-NEXT: Index n_strx n_type n_sect n_desc n_value +ALL-NEXT: ======== -------- ------------------ ------ ------ ---------------- +ALL-NEXT: [ 0] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Inputs/' +ALL-NEXT: [ 1] 0000000b 64 (N_SO ) 00 0000 0000000000000000 'fat-test.c' +ALL-NEXT: [ 2] 00000016 66 (N_OSO ) 08 0001 0000000055b1d0b9 '/Inputs/fat-test.o' +ALL-NEXT: [ 3] 00000029 20 (N_GSYM ) 00 0000 0000000000000000 '_x86_64h_var' +ALL-NEXT: [ 4] 00000001 64 (N_SO ) 01 0000 0000000000000000 +ALL-NEXT: [ 5] 00000036 0f ( SECT EXT) 02 0000 0000000000001000 '_x86_64h_var' +ALL-NEXT: [ 6] 00000043 01 ( UNDF EXT) 00 0100 0000000000000000 'dyld_stub_binder'
\ No newline at end of file diff --git a/test/tools/dsymutil/fat-binary-output.test b/test/tools/dsymutil/fat-binary-output.test new file mode 100644 index 000000000000..fafef14ebe9b --- /dev/null +++ b/test/tools/dsymutil/fat-binary-output.test @@ -0,0 +1,32 @@ +RUN: llvm-dsymutil -f -verbose -no-output %p/Inputs/fat-test.dylib -oso-prepend-path %p | FileCheck %s + +This test doesn't produce any filesytstem output, we just look at the verbose +log output. + +For each arch in the binary, check that we emit the right triple with the right +file and the right symbol inside it (each slice has a different symbol, so that +means that the logic is looking at the right file slice too). + +After the link of each architecture, check that lipo is correctly invoked to +generate the fat output binary. + +CHECK: triple: 'x86_64-apple-darwin' +CHECK: - filename: {{'?}}[[INPUTS_PATH:.*]]fat-test.o +CHECK: DW_AT_name{{.*}} "x86_64_var" + +CHECK: triple: 'i386-apple-darwin' +CHECK: - filename: {{'?}}[[INPUTS_PATH]]fat-test.o +CHECK: DW_AT_name{{.*}} "i386_var" + +CHECK: triple: 'x86_64h-apple-darwin' +CHECK: - filename: {{'?}}[[INPUTS_PATH]]fat-test.o +CHECK: DW_AT_name{{.*}} "x86_64h_var" + +CHECK: Running lipo +CHECK-NEXT: lipo -create +CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf +CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf +CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf +CHECK-SAME: -segalign x86_64 20 -segalign i386 20 -segalign x86_64h 20 +CHECK-SAME: -output [[INPUTS_PATH]]fat-test.dylib.dwarf + diff --git a/test/tools/dsymutil/yaml-object-address-rewrite.test b/test/tools/dsymutil/yaml-object-address-rewrite.test index dcb39be891cd..749719fc5bd9 100644 --- a/test/tools/dsymutil/yaml-object-address-rewrite.test +++ b/test/tools/dsymutil/yaml-object-address-rewrite.test @@ -1,16 +1,19 @@ -# RUN: llvm-dsymutil -v -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s +# RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p -y %s | FileCheck %s # # The YAML debug map bellow is the one from basic-archive.macho.x86_64 with # the object addresses set to zero. Check that the YAML import is able to # rewrite these addresses to the right values. # # CHECK: --- -# CHECK-NEXT: triple:{{.*}}'x86_64-unknown-unknown-macho' +# CHECK-NEXT: triple:{{.*}}'x86_64-apple-darwin' +# CHECK-NEXT: binary-path:{{.*}}'' # CHECK-NEXT: objects: # CHECK-NEXT: filename:{{.*}}/Inputs/basic1.macho.x86_64.o +# CHECK-NEXT: timestamp: 0 # CHECK-NEXT: symbols: # CHECK-NEXT: sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000EA0, size: 0x00000024 # CHECK-NEXT: filename:{{.*}}/Inputs/./libbasic.a(basic2.macho.x86_64.o)' +# CHECK-NEXT: timestamp: 0 # CHECK-NEXT: symbols: # CHECK-DAG: sym: _foo, objAddr: 0x0000000000000020, binAddr: 0x0000000100000ED0, size: 0x00000050 # CHECK-DAG: sym: _private_int, objAddr: 0x0000000000000560, binAddr: 0x0000000100001004, size: 0x00000000 @@ -18,6 +21,7 @@ # CHECK-DAG: sym: _baz, objAddr: 0x0000000000000310, binAddr: 0x0000000100001000, size: 0x00000000 # CHECK-NOT: { sym: # CHECK-NEXT: filename:{{.*}}/Inputs/./libbasic.a(basic3.macho.x86_64.o)' +# CHECK-NEXT: timestamp: 0 # CHECK-NEXT: symbols: # CHECK-DAG: sym: _val, objAddr: 0x0000000000000004, binAddr: 0x0000000100001008, size: 0x00000000 # CHECK-DAG: sym: _bar, objAddr: 0x0000000000000020, binAddr: 0x0000000100000F40, size: 0x00000050 @@ -25,7 +29,7 @@ # CHECK-NOT: { sym: # CHECK-NEXT: ... --- -triple: 'x86_64-unknown-unknown-macho' +triple: 'x86_64-apple-darwin' objects: - filename: /Inputs/basic1.macho.x86_64.o symbols: diff --git a/test/tools/gold/Inputs/linkonce-weak.ll b/test/tools/gold/Inputs/linkonce-weak.ll deleted file mode 100644 index f42af8faa844..000000000000 --- a/test/tools/gold/Inputs/linkonce-weak.ll +++ /dev/null @@ -1,3 +0,0 @@ -define weak_odr void @f() { - ret void -} diff --git a/test/tools/gold/lit.local.cfg b/test/tools/gold/PowerPC/lit.local.cfg index a59549d47abe..d968938d24ce 100644 --- a/test/tools/gold/lit.local.cfg +++ b/test/tools/gold/PowerPC/lit.local.cfg @@ -1,4 +1,3 @@ if (not 'ld_plugin' in config.available_features or - not 'X86' in config.root.targets or not 'PowerPC' in config.root.targets): config.unsupported = True diff --git a/test/tools/gold/mtriple.ll b/test/tools/gold/PowerPC/mtriple.ll index 87b226014cab..87b226014cab 100644 --- a/test/tools/gold/mtriple.ll +++ b/test/tools/gold/PowerPC/mtriple.ll diff --git a/test/tools/gold/Inputs/alias-1.ll b/test/tools/gold/X86/Inputs/alias-1.ll index 96183aa9537c..96183aa9537c 100644 --- a/test/tools/gold/Inputs/alias-1.ll +++ b/test/tools/gold/X86/Inputs/alias-1.ll diff --git a/test/tools/gold/X86/Inputs/available-externally.ll b/test/tools/gold/X86/Inputs/available-externally.ll new file mode 100644 index 000000000000..cbc5c12c65d5 --- /dev/null +++ b/test/tools/gold/X86/Inputs/available-externally.ll @@ -0,0 +1,3 @@ +define void @zed() { + ret void +} diff --git a/test/tools/gold/Inputs/bcsection.s b/test/tools/gold/X86/Inputs/bcsection.s index ede1e5c532dd..ede1e5c532dd 100644 --- a/test/tools/gold/Inputs/bcsection.s +++ b/test/tools/gold/X86/Inputs/bcsection.s diff --git a/test/tools/gold/Inputs/comdat.ll b/test/tools/gold/X86/Inputs/comdat.ll index 464aefa49dc1..734115180fff 100644 --- a/test/tools/gold/Inputs/comdat.ll +++ b/test/tools/gold/X86/Inputs/comdat.ll @@ -17,9 +17,9 @@ bb21: @r21 = global i32* @v1 @r22 = global i32(i8*)* @f1 -@a21 = alias i32* @v1 -@a22 = alias bitcast (i32* @v1 to i16*) +@a21 = alias i32, i32* @v1 +@a22 = alias i16, bitcast (i32* @v1 to i16*) -@a23 = alias i32(i8*)* @f1 -@a24 = alias bitcast (i32(i8*)* @f1 to i16*) -@a25 = alias i16* @a24 +@a23 = alias i32(i8*), i32(i8*)* @f1 +@a24 = alias i16, bitcast (i32(i8*)* @f1 to i16*) +@a25 = alias i16, i16* @a24 diff --git a/test/tools/gold/X86/Inputs/comdat2.ll b/test/tools/gold/X86/Inputs/comdat2.ll new file mode 100644 index 000000000000..5b7f74cf0b24 --- /dev/null +++ b/test/tools/gold/X86/Inputs/comdat2.ll @@ -0,0 +1,9 @@ +$foo = comdat any +@foo = global i8 1, comdat +define void @zed() { + call void @bar() + ret void +} +define void @bar() comdat($foo) { + ret void +} diff --git a/test/tools/gold/Inputs/common.ll b/test/tools/gold/X86/Inputs/common.ll index 46f199e167af..46f199e167af 100644 --- a/test/tools/gold/Inputs/common.ll +++ b/test/tools/gold/X86/Inputs/common.ll diff --git a/test/tools/gold/X86/Inputs/ctors2.ll b/test/tools/gold/X86/Inputs/ctors2.ll new file mode 100644 index 000000000000..af1590eb277c --- /dev/null +++ b/test/tools/gold/X86/Inputs/ctors2.ll @@ -0,0 +1,5 @@ +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }] + +define void @bar() { + ret void +} diff --git a/test/tools/gold/Inputs/drop-debug.bc b/test/tools/gold/X86/Inputs/drop-debug.bc Binary files differindex f9c471f8e0d1..f9c471f8e0d1 100644 --- a/test/tools/gold/Inputs/drop-debug.bc +++ b/test/tools/gold/X86/Inputs/drop-debug.bc diff --git a/test/tools/gold/X86/Inputs/drop-linkage.ll b/test/tools/gold/X86/Inputs/drop-linkage.ll new file mode 100644 index 000000000000..075306114331 --- /dev/null +++ b/test/tools/gold/X86/Inputs/drop-linkage.ll @@ -0,0 +1,9 @@ +$foo = comdat any +define linkonce void @foo() comdat { + ret void +} + +define void @bar() { + call void @foo() + ret void +} diff --git a/test/tools/gold/Inputs/invalid.bc b/test/tools/gold/X86/Inputs/invalid.bc Binary files differindex 2e7ca8d2e105..2e7ca8d2e105 100644 --- a/test/tools/gold/Inputs/invalid.bc +++ b/test/tools/gold/X86/Inputs/invalid.bc diff --git a/test/tools/gold/Inputs/linker-script.export b/test/tools/gold/X86/Inputs/linker-script.export index 2062a081ffe2..2062a081ffe2 100644 --- a/test/tools/gold/Inputs/linker-script.export +++ b/test/tools/gold/X86/Inputs/linker-script.export diff --git a/test/tools/gold/X86/Inputs/linkonce-weak.ll b/test/tools/gold/X86/Inputs/linkonce-weak.ll new file mode 100644 index 000000000000..3b7dad1b1eff --- /dev/null +++ b/test/tools/gold/X86/Inputs/linkonce-weak.ll @@ -0,0 +1,19 @@ +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/test/tools/gold/Inputs/pr19901-1.ll b/test/tools/gold/X86/Inputs/pr19901-1.ll index 2f7153268aca..2f7153268aca 100644 --- a/test/tools/gold/Inputs/pr19901-1.ll +++ b/test/tools/gold/X86/Inputs/pr19901-1.ll diff --git a/test/tools/gold/X86/Inputs/resolve-to-alias.ll b/test/tools/gold/X86/Inputs/resolve-to-alias.ll new file mode 100644 index 000000000000..eff02a6f4d1e --- /dev/null +++ b/test/tools/gold/X86/Inputs/resolve-to-alias.ll @@ -0,0 +1,4 @@ +@bar = alias void (), void ()* @zed +define void @zed() { + ret void +} diff --git a/test/tools/gold/X86/Inputs/thinlto.ll b/test/tools/gold/X86/Inputs/thinlto.ll new file mode 100644 index 000000000000..4e0840f3691e --- /dev/null +++ b/test/tools/gold/X86/Inputs/thinlto.ll @@ -0,0 +1,4 @@ +define void @g() { +entry: + ret void +} diff --git a/test/tools/gold/X86/Inputs/type-merge.ll b/test/tools/gold/X86/Inputs/type-merge.ll new file mode 100644 index 000000000000..4dc214922dc5 --- /dev/null +++ b/test/tools/gold/X86/Inputs/type-merge.ll @@ -0,0 +1,5 @@ +define void @zed() { + call void @bar() + ret void +} +declare void @bar() diff --git a/test/tools/gold/X86/Inputs/type-merge2.ll b/test/tools/gold/X86/Inputs/type-merge2.ll new file mode 100644 index 000000000000..a354757ee2e7 --- /dev/null +++ b/test/tools/gold/X86/Inputs/type-merge2.ll @@ -0,0 +1,5 @@ +%zed = type { i16 } +define void @bar(%zed* %this) { + store %zed* %this, %zed** null + ret void +} diff --git a/test/tools/gold/Inputs/weak.ll b/test/tools/gold/X86/Inputs/weak.ll index 53b1d1650d1b..53b1d1650d1b 100644 --- a/test/tools/gold/Inputs/weak.ll +++ b/test/tools/gold/X86/Inputs/weak.ll diff --git a/test/tools/gold/alias.ll b/test/tools/gold/X86/alias.ll index b4edb05a4e46..c659f73d7e83 100644 --- a/test/tools/gold/alias.ll +++ b/test/tools/gold/X86/alias.ll @@ -9,5 +9,5 @@ ; CHECK-NEXT: @b = global i32 1 ; CHECK-NOT: alias -@a = weak alias i32* @b +@a = weak alias i32, i32* @b @b = global i32 1 diff --git a/test/tools/gold/X86/alias2.ll b/test/tools/gold/X86/alias2.ll new file mode 100644 index 000000000000..4727e0508fae --- /dev/null +++ b/test/tools/gold/X86/alias2.ll @@ -0,0 +1,23 @@ +; RUN: llvm-as %s -o %t.o +; RUN: %gold -shared -o %t2.bc -plugin %llvmshlibdir/LLVMgold.so %t.o -plugin-opt=emit-llvm +; RUN: llvm-dis %t2.bc -o - | FileCheck %s + +@bar = alias void (), void ()* @zed +define void @foo() { + call void @bar() + ret void +} +define void @zed() { + ret void +} + +; CHECK: @bar = alias void (), void ()* @zed + +; CHECK: define void @foo() { +; CHECK-NEXT: call void @bar() +; CHECK-NEXT: ret void +; CHECK-NEXT: } + +; CHECK: define void @zed() { +; CHECK-NEXT: ret void +; CHECK-NEXT: } diff --git a/test/tools/gold/linkonce-weak.ll b/test/tools/gold/X86/available-externally.ll index a0cccea56cfe..d47a536dc094 100644 --- a/test/tools/gold/linkonce-weak.ll +++ b/test/tools/gold/X86/available-externally.ll @@ -1,5 +1,5 @@ ; RUN: llvm-as %s -o %t.o -; RUN: llvm-as %p/Inputs/linkonce-weak.ll -o %t2.o +; RUN: llvm-as %p/Inputs/available-externally.ll -o %t2.o ; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ ; RUN: --plugin-opt=emit-llvm \ @@ -11,9 +11,17 @@ ; RUN: -shared %t2.o %t.o -o %t3.o ; RUN: llvm-dis %t3.o -o - | FileCheck %s -define linkonce_odr void @f() { +define void @foo() { + call void @bar() + call void @zed() + ret void +} +define available_externally void @bar() { + ret void +} +define available_externally void @zed() { ret void } -; Test that we get a weak_odr regardless of the order of the files -; CHECK: define weak_odr void @f() { +; CHECK-DAG: define available_externally void @bar() { +; CHECK-DAG: define void @zed() { diff --git a/test/tools/gold/bad-alias.ll b/test/tools/gold/X86/bad-alias.ll index a98bf710b454..c4e3c3fe82fc 100644 --- a/test/tools/gold/bad-alias.ll +++ b/test/tools/gold/X86/bad-alias.ll @@ -9,5 +9,5 @@ @g1 = global i32 1 @g2 = global i32 2 -@a = alias inttoptr(i32 sub (i32 ptrtoint (i32* @g1 to i32), - i32 ptrtoint (i32* @g2 to i32)) to i32*) +@a = alias i32, inttoptr(i32 sub (i32 ptrtoint (i32* @g1 to i32), + i32 ptrtoint (i32* @g2 to i32)) to i32*) diff --git a/test/tools/gold/X86/bcsection.ll b/test/tools/gold/X86/bcsection.ll new file mode 100644 index 000000000000..f7ebe375770e --- /dev/null +++ b/test/tools/gold/X86/bcsection.ll @@ -0,0 +1,13 @@ +; RUN: llvm-as -o %T/bcsection.bc %s + +; RUN: llvm-mc -I=%T -filetype=obj -triple=x86_64-unknown-unknown -o %T/bcsection.bco %p/Inputs/bcsection.s +; RUN: llvm-nm -no-llvm-bc %T/bcsection.bco | count 0 +; RUN: %gold -r -o %T/bcsection.o -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so %T/bcsection.bco +; RUN: llvm-nm -no-llvm-bc %T/bcsection.o | FileCheck %s + +target triple = "x86_64-unknown-unknown" + +; CHECK: main +define i32 @main() { + ret i32 0 +} diff --git a/test/tools/gold/coff.ll b/test/tools/gold/X86/coff.ll index 5d8a1c9da5fc..5d8a1c9da5fc 100644 --- a/test/tools/gold/coff.ll +++ b/test/tools/gold/X86/coff.ll diff --git a/test/tools/gold/X86/comdat.ll b/test/tools/gold/X86/comdat.ll new file mode 100644 index 000000000000..f65ca73c8063 --- /dev/null +++ b/test/tools/gold/X86/comdat.ll @@ -0,0 +1,65 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/comdat.ll -o %t2.o +; RUN: %gold -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t.o %t2.o \ +; RUN: -plugin-opt=emit-llvm +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +$c1 = comdat any + +@v1 = weak_odr global i32 42, comdat($c1) +define weak_odr i32 @f1(i8*) comdat($c1) { +bb10: + br label %bb11 +bb11: + ret i32 42 +} + +@r11 = global i32* @v1 +@r12 = global i32 (i8*)* @f1 + +@a11 = alias i32, i32* @v1 +@a12 = alias i16, bitcast (i32* @v1 to i16*) + +@a13 = alias i32 (i8*), i32 (i8*)* @f1 +@a14 = alias i16, bitcast (i32 (i8*)* @f1 to i16*) +@a15 = alias i16, i16* @a14 + +; CHECK: $c1 = comdat any +; CHECK: $c2 = comdat any + +; CHECK-DAG: @v1 = weak_odr global i32 42, comdat($c1) + +; CHECK-DAG: @r11 = global i32* @v1{{$}} +; CHECK-DAG: @r12 = global i32 (i8*)* @f1{{$}} + +; CHECK-DAG: @r21 = global i32* @v1{{$}} +; CHECK-DAG: @r22 = global i32 (i8*)* @f1{{$}} + +; CHECK-DAG: @v1.1 = internal global i32 41, comdat($c2) + +; CHECK-DAG: @a11 = alias i32, i32* @v1{{$}} +; CHECK-DAG: @a12 = alias i16, bitcast (i32* @v1 to i16*) + +; CHECK-DAG: @a13 = alias i32 (i8*), i32 (i8*)* @f1{{$}} +; CHECK-DAG: @a14 = alias i16, bitcast (i32 (i8*)* @f1 to i16*) + +; CHECK-DAG: @a21 = alias i32, i32* @v1.1{{$}} +; CHECK-DAG: @a22 = alias i16, bitcast (i32* @v1.1 to i16*) + +; CHECK-DAG: @a23 = alias i32 (i8*), i32 (i8*)* @f1.2{{$}} +; CHECK-DAG: @a24 = alias i16, bitcast (i32 (i8*)* @f1.2 to i16*) + +; CHECK: define weak_odr protected i32 @f1(i8*) comdat($c1) { +; CHECK-NEXT: bb10: +; CHECK-NEXT: br label %bb11{{$}} +; CHECK: bb11: +; CHECK-NEXT: ret i32 42 +; CHECK-NEXT: } + +; CHECK: define internal i32 @f1.2(i8* %this) comdat($c2) { +; CHECK-NEXT: bb20: +; CHECK-NEXT: store i8* %this, i8** null +; CHECK-NEXT: br label %bb21 +; CHECK: bb21: +; CHECK-NEXT: ret i32 41 +; CHECK-NEXT: } diff --git a/test/tools/gold/X86/comdat2.ll b/test/tools/gold/X86/comdat2.ll new file mode 100644 index 000000000000..2156efd207bb --- /dev/null +++ b/test/tools/gold/X86/comdat2.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-as %p/Inputs/comdat2.ll -o %t2.bc +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.bc %t2.bc -o %t3.bc +; RUN: llvm-dis %t3.bc -o - | FileCheck %s + + +$foo = comdat any +@foo = global i8 0, comdat + +; CHECK: @foo = global i8 0, comdat + +; CHECK: define void @zed() { +; CHECK: call void @bar() +; CHECK: ret void +; CHECK: } + +; CHECK: declare void @bar() diff --git a/test/tools/gold/common.ll b/test/tools/gold/X86/common.ll index ef18e6831045..ef18e6831045 100644 --- a/test/tools/gold/common.ll +++ b/test/tools/gold/X86/common.ll diff --git a/test/tools/gold/X86/ctors.ll b/test/tools/gold/X86/ctors.ll new file mode 100644 index 000000000000..24c8e342beb0 --- /dev/null +++ b/test/tools/gold/X86/ctors.ll @@ -0,0 +1,13 @@ +; RUN: llvm-as %s -o %t.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o -o %t2.o +; RUN: llvm-dis %t2.o -o - | FileCheck %s + +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }] + +define internal void @foo() { + ret void +} + +; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }] diff --git a/test/tools/gold/X86/ctors2.ll b/test/tools/gold/X86/ctors2.ll new file mode 100644 index 000000000000..c39cb7132d93 --- /dev/null +++ b/test/tools/gold/X86/ctors2.ll @@ -0,0 +1,14 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/ctors2.ll -o %t2.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }] + +define void @foo() { + ret void +} + +; CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }] diff --git a/test/tools/gold/X86/disable-verify.ll b/test/tools/gold/X86/disable-verify.ll new file mode 100644 index 000000000000..5b8dbb054478 --- /dev/null +++ b/test/tools/gold/X86/disable-verify.ll @@ -0,0 +1,25 @@ +; RUN: llvm-as %s -o %t.o +; REQUIRES: asserts + +; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=disable-verify \ +; RUN: --plugin-opt=-debug-pass=Arguments \ +; RUN: -shared %t.o -o %t2.o 2>&1 | FileCheck %s + +; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=-debug-pass=Arguments \ +; RUN: -shared %t.o -o %t2.o 2>&1 | FileCheck %s -check-prefix=VERIFY + +target triple = "x86_64-unknown-linux-gnu" + +; -disable-verify should disable output verification from the optimization +; pipeline. +; CHECK: Pass Arguments: {{.*}} -verify -forceattrs +; CHECK-NOT: -verify + +; VERIFY: Pass Arguments: {{.*}} -verify {{.*}} -verify + +define void @f() { +entry: + ret void +} diff --git a/test/tools/gold/drop-debug.ll b/test/tools/gold/X86/drop-debug.ll index b8c4d8c62a9b..b8c4d8c62a9b 100644 --- a/test/tools/gold/drop-debug.ll +++ b/test/tools/gold/X86/drop-debug.ll diff --git a/test/tools/gold/X86/drop-linkage.ll b/test/tools/gold/X86/drop-linkage.ll new file mode 100644 index 000000000000..d4c1dd052c79 --- /dev/null +++ b/test/tools/gold/X86/drop-linkage.ll @@ -0,0 +1,14 @@ +; RUN: llc %s -o %t.s +; RUN: llvm-mc %t.s -o %t.o -filetype=obj +; RUN: llvm-as %p/Inputs/drop-linkage.ll -o %t2.o + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +define void @foo() { + ret void +} + +; CHECK: declare extern_weak void @foo(){{$}} diff --git a/test/tools/gold/emit-llvm.ll b/test/tools/gold/X86/emit-llvm.ll index bfb90c4bc28a..4a6d5963cff0 100644 --- a/test/tools/gold/emit-llvm.ll +++ b/test/tools/gold/X86/emit-llvm.ll @@ -12,6 +12,7 @@ ; RUN: -shared %t.o -o %t3.o ; RUN: llvm-dis %t3.o.bc -o - | FileCheck %s ; RUN: llvm-dis %t3.o.opt.bc -o - | FileCheck --check-prefix=OPT %s +; RUN: llvm-dis %t3.o.opt.bc -o - | FileCheck --check-prefix=OPT2 %s ; RUN: llvm-nm %t3.o.o | FileCheck --check-prefix=NM %s ; RUN: rm -f %t4.o @@ -29,42 +30,42 @@ target triple = "x86_64-unknown-linux-gnu" @g8 = external global i32 -; CHECK: define internal void @f1() -; OPT-NOT: @f1 +; CHECK-DAG: define internal void @f1() +; OPT2-NOT: @f1 define hidden void @f1() { ret void } -; CHECK: define hidden void @f2() -; OPT: define hidden void @f2() +; CHECK-DAG: define hidden void @f2() +; OPT-DAG: define hidden void @f2() define hidden void @f2() { ret void } @llvm.used = appending global [1 x i8*] [ i8* bitcast (void ()* @f2 to i8*)] -; CHECK: define void @f3() -; OPT: define void @f3() +; CHECK-DAG: define void @f3() +; OPT-DAG: define void @f3() define void @f3() { call void @f4() ret void } -; CHECK: define internal void @f4() -; OPT-NOT: @f4 +; CHECK-DAG: define internal void @f4() +; OPT2-NOT: @f4 define linkonce_odr void @f4() { ret void } -; CHECK: define linkonce_odr void @f5() -; OPT: define linkonce_odr void @f5() +; CHECK-DAG: define linkonce_odr void @f5() +; OPT-DAG: define linkonce_odr void @f5() define linkonce_odr void @f5() { ret void } @g5 = global void()* @f5 -; CHECK: define internal void @f6() unnamed_addr -; OPT: define internal void @f6() unnamed_addr +; CHECK-DAG: define internal void @f6() unnamed_addr +; OPT-DAG: define internal void @f6() unnamed_addr define linkonce_odr void @f6() unnamed_addr { ret void } diff --git a/test/tools/gold/invalid.ll b/test/tools/gold/X86/invalid.ll index 858cd47adbed..858cd47adbed 100644 --- a/test/tools/gold/invalid.ll +++ b/test/tools/gold/X86/invalid.ll diff --git a/test/tools/gold/linker-script.ll b/test/tools/gold/X86/linker-script.ll index 7c88b0ffd5fb..7c88b0ffd5fb 100644 --- a/test/tools/gold/linker-script.ll +++ b/test/tools/gold/X86/linker-script.ll diff --git a/test/tools/gold/X86/linkonce-weak.ll b/test/tools/gold/X86/linkonce-weak.ll new file mode 100644 index 000000000000..3397c3480a7c --- /dev/null +++ b/test/tools/gold/X86/linkonce-weak.ll @@ -0,0 +1,39 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/linkonce-weak.ll -o %t2.o + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t2.o %t.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +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() + +; 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) diff --git a/test/tools/gold/X86/lit.local.cfg b/test/tools/gold/X86/lit.local.cfg new file mode 100644 index 000000000000..ddcd48ca470d --- /dev/null +++ b/test/tools/gold/X86/lit.local.cfg @@ -0,0 +1,3 @@ +if (not 'ld_plugin' in config.available_features or + not 'X86' in config.root.targets): + config.unsupported = True diff --git a/test/tools/gold/no-map-whole-file.ll b/test/tools/gold/X86/no-map-whole-file.ll index 4c261d70a249..4c261d70a249 100644 --- a/test/tools/gold/no-map-whole-file.ll +++ b/test/tools/gold/X86/no-map-whole-file.ll diff --git a/test/tools/gold/opt-level.ll b/test/tools/gold/X86/opt-level.ll index 3deb0af37a74..3deb0af37a74 100644 --- a/test/tools/gold/opt-level.ll +++ b/test/tools/gold/X86/opt-level.ll diff --git a/test/tools/gold/X86/parallel.ll b/test/tools/gold/X86/parallel.ll new file mode 100644 index 000000000000..00a0bafda251 --- /dev/null +++ b/test/tools/gold/X86/parallel.ll @@ -0,0 +1,22 @@ +; RUN: llvm-as -o %t.bc %s +; RUN: env LD_PRELOAD=%llvmshlibdir/LLVMgold.so %gold -plugin %llvmshlibdir/LLVMgold.so -u foo -u bar -plugin-opt jobs=2 -plugin-opt save-temps -m elf_x86_64 -o %t %t.bc +; RUN: llvm-nm %t.o0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-nm %t.o1 | FileCheck --check-prefix=CHECK1 %s + +target triple = "x86_64-unknown-linux-gnu" + +; CHECK0-NOT: bar +; CHECK0: T foo +; CHECK0-NOT: bar +define void @foo() { + call void @bar() + ret void +} + +; CHECK1-NOT: foo +; CHECK1: T bar +; CHECK1-NOT: foo +define void @bar() { + call void @foo() + ret void +} diff --git a/test/tools/gold/pr19901.ll b/test/tools/gold/X86/pr19901.ll index 71bb134ead7b..71bb134ead7b 100644 --- a/test/tools/gold/pr19901.ll +++ b/test/tools/gold/X86/pr19901.ll diff --git a/test/tools/gold/X86/pr25907.ll b/test/tools/gold/X86/pr25907.ll new file mode 100644 index 000000000000..502938cf8126 --- /dev/null +++ b/test/tools/gold/X86/pr25907.ll @@ -0,0 +1,28 @@ +; RUN: llvm-as %s -o %t.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: -shared %t.o -o %t2 +; RUN: llvm-nm %t2 | FileCheck %s +; CHECK: T main + +@main.L = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@main, %L1), i8* blockaddress(@main, %L2), i8* null], align 16 + +define i32 @main() #0 { +entry: + br label %L1 + +L1: ; preds = %entry, %L1 + %i.0 = phi i32 [ 0, %entry ], [ %inc, %L1 ] + %inc = add i32 %i.0, 1 + %idxprom = zext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds [3 x i8*], [3 x i8*]* @main.L, i64 0, i64 %idxprom + %0 = load i8*, i8** %arrayidx, align 8, !tbaa !1 + indirectbr i8* %0, [label %L1, label %L2] + +L2: ; preds = %L1 + ret i32 0 +} + +!1 = !{!2, !2, i64 0} +!2 = !{!"any pointer", !3, i64 0} +!3 = !{!"omnipotent char", !4, i64 0} +!4 = !{!"Simple C/C++ TBAA"} diff --git a/test/tools/gold/X86/pr25915.ll b/test/tools/gold/X86/pr25915.ll new file mode 100644 index 000000000000..2d8807e04bb4 --- /dev/null +++ b/test/tools/gold/X86/pr25915.ll @@ -0,0 +1,17 @@ +; RUN: llvm-as %s -o %t.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: -plugin-opt=emit-llvm \ +; RUN: -shared %t.o -o %t2 +; RUN: llvm-dis %t2 -o - | FileCheck %s +; CHECK-NOT: subprograms + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4} +!llvm.ident = !{!5} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256170) (llvm/trunk 256171)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2) +!1 = !DIFile(filename: "pr25915.cc", directory: ".") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{!"clang version 3.8.0 (trunk 256170) (llvm/trunk 256171)"} diff --git a/test/tools/gold/remarks.ll b/test/tools/gold/X86/remarks.ll index c4fa7f787f26..51bd121cebce 100644 --- a/test/tools/gold/remarks.ll +++ b/test/tools/gold/X86/remarks.ll @@ -1,9 +1,9 @@ ; RUN: llvm-as %s -o %t.o -; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: not %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ ; RUN: -plugin-opt=-pass-remarks=inline %t.o -o %t2.o 2>&1 | FileCheck %s -; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: not %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \ ; RUN: %t.o -o %t2.o 2>&1 | FileCheck -allow-empty --check-prefix=NO-REMARK %s @@ -12,8 +12,11 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" +declare i32 @bar() + define i32 @f() { - ret i32 0 + %a = call i32 @bar() + ret i32 %a } define i32 @_start() { diff --git a/test/tools/gold/X86/resolve-to-alias.ll b/test/tools/gold/X86/resolve-to-alias.ll new file mode 100644 index 000000000000..102da6f80f4d --- /dev/null +++ b/test/tools/gold/X86/resolve-to-alias.ll @@ -0,0 +1,33 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/resolve-to-alias.ll -o %t2.o + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t.bc +; RUN: llvm-dis %t.bc -o %t.ll +; RUN: FileCheck --check-prefix=PASS1 %s < %t.ll +; RUN: FileCheck --check-prefix=PASS2 %s < %t.ll + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t2.o %t.o -o %t.bc +; RUN: llvm-dis %t.bc -o %t.ll +; RUN: FileCheck --check-prefix=PASS1 %s < %t.ll +; RUN: FileCheck --check-prefix=PASS2 %s < %t.ll + +define void @foo() { + call void @bar() + ret void +} +declare void @bar() + +; PASS1: @bar = alias void (), void ()* @zed + +; PASS1: define void @foo() { +; PASS1-NEXT: call void @bar() +; PASS1-NEXT: ret void +; PASS1-NEXT: } + +; PASS2: define void @zed() { +; PASS2-NEXT: ret void +; PASS2-NEXT: } diff --git a/test/tools/gold/slp-vectorize.ll b/test/tools/gold/X86/slp-vectorize.ll index 30950b2d2de8..30950b2d2de8 100644 --- a/test/tools/gold/slp-vectorize.ll +++ b/test/tools/gold/X86/slp-vectorize.ll diff --git a/test/tools/gold/stats.ll b/test/tools/gold/X86/stats.ll index b3c829798df2..b3c829798df2 100644 --- a/test/tools/gold/stats.ll +++ b/test/tools/gold/X86/stats.ll diff --git a/test/tools/gold/X86/thinlto.ll b/test/tools/gold/X86/thinlto.ll new file mode 100644 index 000000000000..97def3d7a14d --- /dev/null +++ b/test/tools/gold/X86/thinlto.ll @@ -0,0 +1,34 @@ +; First ensure that the ThinLTO handling in the gold plugin handles +; bitcode without function summary sections gracefully. +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=thinlto \ +; RUN: -shared %t.o %t2.o -o %t3 + +; RUN: llvm-as -function-summary %s -o %t.o +; RUN: llvm-as -function-summary %p/Inputs/thinlto.ll -o %t2.o + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=thinlto \ +; RUN: -shared %t.o %t2.o -o %t3 +; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED +; RUN: not test -e %t3 + +; COMBINED: <MODULE_STRTAB_BLOCK +; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' +; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' +; COMBINED-NEXT: </MODULE_STRTAB_BLOCK +; COMBINED-NEXT: <FUNCTION_SUMMARY_BLOCK +; COMBINED-NEXT: <COMBINED_ENTRY +; COMBINED-NEXT: <COMBINED_ENTRY +; COMBINED-NEXT: </FUNCTION_SUMMARY_BLOCK +; COMBINED-NEXT: <VALUE_SYMTAB +; COMBINED-NEXT: <COMBINED_FNENTRY {{.*}} record string = '{{f|g}}' +; COMBINED-NEXT: <COMBINED_FNENTRY {{.*}} record string = '{{f|g}}' +; COMBINED-NEXT: </VALUE_SYMTAB + +define void @f() { +entry: + ret void +} diff --git a/test/tools/gold/X86/type-merge.ll b/test/tools/gold/X86/type-merge.ll new file mode 100644 index 000000000000..d903894345d4 --- /dev/null +++ b/test/tools/gold/X86/type-merge.ll @@ -0,0 +1,24 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/type-merge.ll -o %t2.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +define void @foo() { + call void @bar(i8* null) + ret void +} +declare void @bar(i8*) + +; CHECK: define void @foo() { +; CHECK-NEXT: call void @bar(i8* null) +; CHECK-NEXT: ret void +; CHECK-NEXT: } + +; CHECK: declare void @bar(i8*) + +; CHECK: define void @zed() { +; CHECK-NEXT: call void bitcast (void (i8*)* @bar to void ()*)() +; CHECK-NEXT: ret void +; CHECK-NEXT: } diff --git a/test/tools/gold/X86/type-merge2.ll b/test/tools/gold/X86/type-merge2.ll new file mode 100644 index 000000000000..42ad0dafb29b --- /dev/null +++ b/test/tools/gold/X86/type-merge2.ll @@ -0,0 +1,26 @@ +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %p/Inputs/type-merge2.ll -o %t2.o +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o %t2.o -o %t3.o +; RUN: llvm-dis %t3.o -o - | FileCheck %s + +%zed = type { i8 } +define void @foo() { + call void @bar(%zed* null) + ret void +} +declare void @bar(%zed*) + +; CHECK: %zed = type { i8 } +; CHECK-NEXT: %zed.0 = type { i16 } + +; CHECK: define void @foo() { +; CHECK-NEXT: call void bitcast (void (%zed.0*)* @bar to void (%zed*)*)(%zed* null) +; CHECK-NEXT: ret void +; CHECK-NEXT: } + +; CHECK: define void @bar(%zed.0* %this) { +; CHECK-NEXT: store %zed.0* %this, %zed.0** null +; CHECK-NEXT: ret void +; CHECK-NEXT: } diff --git a/test/tools/gold/X86/unnamed-addr.ll b/test/tools/gold/X86/unnamed-addr.ll new file mode 100644 index 000000000000..290f73d85484 --- /dev/null +++ b/test/tools/gold/X86/unnamed-addr.ll @@ -0,0 +1,14 @@ +; RUN: llvm-as %s -o %t.o + +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=emit-llvm \ +; RUN: -shared %t.o -o %t2.o +; RUN: llvm-dis %t2.o -o - | FileCheck %s + +@a = internal unnamed_addr constant i8 42 + +define i8* @f() { + ret i8* @a +} + +; CHECK: @a = internal unnamed_addr constant i8 42 diff --git a/test/tools/gold/vectorize.ll b/test/tools/gold/X86/vectorize.ll index 5f003dd02e21..5f003dd02e21 100644 --- a/test/tools/gold/vectorize.ll +++ b/test/tools/gold/X86/vectorize.ll diff --git a/test/tools/gold/weak.ll b/test/tools/gold/X86/weak.ll index 6d8d7a871f1b..6d8d7a871f1b 100644 --- a/test/tools/gold/weak.ll +++ b/test/tools/gold/X86/weak.ll diff --git a/test/tools/gold/bcsection.ll b/test/tools/gold/bcsection.ll deleted file mode 100644 index 37d2994cc780..000000000000 --- a/test/tools/gold/bcsection.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llvm-as -o %T/bcsection.bc %s - -; RUN: llvm-mc -I=%T -filetype=obj -o %T/bcsection.bco %p/Inputs/bcsection.s -; RUN: llvm-nm -no-llvm-bc %T/bcsection.bco | count 0 -; RUN: %gold -r -o %T/bcsection.o -plugin %llvmshlibdir/LLVMgold.so %T/bcsection.bco -; RUN: llvm-nm -no-llvm-bc %T/bcsection.o | FileCheck %s - -; CHECK: main -define i32 @main() { - ret i32 0 -} diff --git a/test/tools/gold/comdat.ll b/test/tools/gold/comdat.ll deleted file mode 100644 index 370bf5641f31..000000000000 --- a/test/tools/gold/comdat.ll +++ /dev/null @@ -1,65 +0,0 @@ -; RUN: llvm-as %s -o %t.o -; RUN: llvm-as %p/Inputs/comdat.ll -o %t2.o -; RUN: %gold -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t.o %t2.o \ -; RUN: -plugin-opt=emit-llvm -; RUN: llvm-dis %t3.o -o - | FileCheck %s - -$c1 = comdat any - -@v1 = weak_odr global i32 42, comdat($c1) -define weak_odr i32 @f1(i8*) comdat($c1) { -bb10: - br label %bb11 -bb11: - ret i32 42 -} - -@r11 = global i32* @v1 -@r12 = global i32 (i8*)* @f1 - -@a11 = alias i32* @v1 -@a12 = alias bitcast (i32* @v1 to i16*) - -@a13 = alias i32 (i8*)* @f1 -@a14 = alias bitcast (i32 (i8*)* @f1 to i16*) -@a15 = alias i16* @a14 - -; CHECK: $c1 = comdat any -; CHECK: $c2 = comdat any - -; CHECK: @v1 = weak_odr global i32 42, comdat($c1) - -; CHECK: @r11 = global i32* @v1{{$}} -; CHECK: @r12 = global i32 (i8*)* @f1{{$}} - -; CHECK: @r21 = global i32* @v1{{$}} -; CHECK: @r22 = global i32 (i8*)* @f1{{$}} - -; CHECK: @v11 = internal global i32 41, comdat($c2) - -; CHECK: @a11 = alias i32* @v1{{$}} -; CHECK: @a12 = alias bitcast (i32* @v1 to i16*) - -; CHECK: @a13 = alias i32 (i8*)* @f1{{$}} -; CHECK: @a14 = alias bitcast (i32 (i8*)* @f1 to i16*) - -; CHECK: @a21 = alias i32* @v11{{$}} -; CHECK: @a22 = alias bitcast (i32* @v11 to i16*) - -; CHECK: @a23 = alias i32 (i8*)* @f12{{$}} -; CHECK: @a24 = alias bitcast (i32 (i8*)* @f12 to i16*) - -; CHECK: define weak_odr protected i32 @f1(i8*) comdat($c1) { -; CHECK-NEXT: bb10: -; CHECK-NEXT: br label %bb11{{$}} -; CHECK: bb11: -; CHECK-NEXT: ret i32 42 -; CHECK-NEXT: } - -; CHECK: define internal i32 @f12(i8* %this) comdat($c2) { -; CHECK-NEXT: bb20: -; CHECK-NEXT: store i8* %this, i8** null -; CHECK-NEXT: br label %bb21 -; CHECK: bb21: -; CHECK-NEXT: ret i32 41 -; CHECK-NEXT: } diff --git a/test/tools/llvm-cxxdump/trivial.test b/test/tools/llvm-cxxdump/trivial.test index 450ed3b3780d..2c36620bff2f 100644 --- a/test/tools/llvm-cxxdump/trivial.test +++ b/test/tools/llvm-cxxdump/trivial.test @@ -56,3 +56,6 @@ ELF-I386: _ZTS1A: 1A ELF-I386-NEXT: _ZTV1A[0]: 0 ELF-I386-NEXT: _ZTV1A[4]: _ZTI1A ELF-I386-NEXT: _ZTV1A[8]: _ZN1A1fEv + +RUN: not llvm-cxxdump %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s +ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory diff --git a/test/tools/llvm-dwp/Inputs/simple/notypes/a.dwo b/test/tools/llvm-dwp/Inputs/simple/notypes/a.dwo Binary files differnew file mode 100644 index 000000000000..7bdb2a7b9f82 --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/simple/notypes/a.dwo diff --git a/test/tools/llvm-dwp/Inputs/simple/notypes/b.dwo b/test/tools/llvm-dwp/Inputs/simple/notypes/b.dwo Binary files differnew file mode 100644 index 000000000000..f41243dc722b --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/simple/notypes/b.dwo diff --git a/test/tools/llvm-dwp/Inputs/simple/types/a.dwo b/test/tools/llvm-dwp/Inputs/simple/types/a.dwo Binary files differnew file mode 100644 index 000000000000..1fc71ca8d175 --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/simple/types/a.dwo diff --git a/test/tools/llvm-dwp/Inputs/simple/types/b.dwo b/test/tools/llvm-dwp/Inputs/simple/types/b.dwo Binary files differnew file mode 100644 index 000000000000..a69cd69eb995 --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/simple/types/b.dwo diff --git a/test/tools/llvm-dwp/Inputs/type_dedup/a.dwo b/test/tools/llvm-dwp/Inputs/type_dedup/a.dwo Binary files differnew file mode 100644 index 000000000000..cfd54c5fbc1a --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/type_dedup/a.dwo diff --git a/test/tools/llvm-dwp/Inputs/type_dedup/b.dwo b/test/tools/llvm-dwp/Inputs/type_dedup/b.dwo Binary files differnew file mode 100644 index 000000000000..278369f80d66 --- /dev/null +++ b/test/tools/llvm-dwp/Inputs/type_dedup/b.dwo diff --git a/test/tools/llvm-dwp/X86/lit.local.cfg b/test/tools/llvm-dwp/X86/lit.local.cfg new file mode 100644 index 000000000000..05f8b38b3346 --- /dev/null +++ b/test/tools/llvm-dwp/X86/lit.local.cfg @@ -0,0 +1,4 @@ +if not 'X86' in config.root.targets: + config.unsupported = True + +config.suffixes = ['.test', '.cpp', '.m', '.s'] diff --git a/test/tools/llvm-dwp/X86/simple.test b/test/tools/llvm-dwp/X86/simple.test new file mode 100644 index 000000000000..d7365c814435 --- /dev/null +++ b/test/tools/llvm-dwp/X86/simple.test @@ -0,0 +1,98 @@ +RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t +RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=NOTYP %s +RUN: llvm-objdump -h %t | FileCheck --check-prefix=NOTYPOBJ %s +RUN: llvm-dwp %p/../Inputs/simple/types/a.dwo %p/../Inputs/simple/types/b.dwo -o %t +RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=TYPES %s + +FIXME: For some reason, piping straight from llvm-dwp to llvm-dwarfdump doesn't behave well - looks like dwarfdump is reading/closes before dwp has finished. + +DWP from non-type-unit debug info for these two translation units: +a.cpp: + struct foo { }; + foo a; + +b.cpp: + struct bar { }; + void b(bar) { + } + +CHECK-LABEL: .debug_abbrev.dwo contents: +CHECK-LABEL: Abbrev table for offset: +CHECK: 0x0000[[AAOFF:.*]] +CHECK: DW_TAG_compile_unit +CHECK: DW_TAG_variable +CHECK: DW_TAG_structure_type +CHECK-LABEL: Abbrev table for offset: +CHECK: 0x0000[[BAOFF:.*]] +CHECK: DW_TAG_compile_unit +CHECK: DW_TAG_structure_type +CHECK: DW_TAG_subprogram +CHECK: DW_TAG_formal_parameter + +CHECK: .debug_info.dwo contents: +CHECK: [[AOFF:0x[0-9a-f]*]]: +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = +CHECK: 0x[[AAOFF]] addr_size = 0x08 (next unit at [[BOFF:.*]]) +CHECK: DW_TAG_compile_unit +CHECK: DW_AT_name {{.*}} "a.cpp" +CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOA:.*]]) +CHECK: DW_TAG_variable +CHECK: DW_AT_name {{.*}} "a" +CHECK: DW_TAG_structure_type +NOTYP: DW_AT_name {{.*}} "foo" +TYPES: DW_AT_signature {{.*}} ([[FOOSIG:.*]]) + +CHECK: [[BOFF]]: +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = +CHECK: 0x[[BAOFF]] addr_size = 0x08 (next unit at [[XOFF:.*]]) +CHECK: DW_AT_name {{.*}} "b.cpp" +CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOB:.*]]) +CHECK: DW_TAG_structure_type +NOTYP: DW_AT_name {{.*}} "bar" +TYPES: DW_AT_signature {{.*}} ([[BARSIG:.*]]) +CHECK: DW_TAG_subprogram +CHECK: DW_AT_name {{.*}} "b" +CHECK: DW_TAG_formal_parameter + +NOTYP-NOT: .debug_types.dwo contents: +TYPES-LABEL: .debug_types.dwo contents: +TYPES: [[FOOUOFF:0x[0-9a-f]*]]: +TYPES-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +TYPES: 0x[[AAOFF]] addr_size = 0x08 type_signature = [[FOOSIG]] type_offset = 0x[[FOOOFF:.*]] (next unit at [[BARUOFF:.*]]) +TYPES: DW_TAG_type_unit +TYPES: [[FOOOFF]]: DW_TAG_structure_type +TYPES: DW_AT_name {{.*}} "foo" +TYPES: [[BARUOFF]]: +TYPES-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +TYPES: 0x[[BAOFF]] addr_size = 0x08 type_signature = [[BARSIG]] type_offset = 0x001e (next unit at [[XUOFF:.*]]) +TYPES: DW_TAG_type_unit +TYPES: 0x00000042: DW_TAG_structure_type +TYPES: DW_AT_name {{.*}} "bar" + +CHECK-LABEL: .debug_cu_index contents: +CHECK: Index Signature INFO ABBREV LINE STR_OFFSETS +TYPES: 1 [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) +TYPES: 3 [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) +NOTYP: 3 [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x00000011) [0x00000000, 0x00000010) +NOTYP: 4 [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x00000075) [0x00000011, 0x00000022) [0x00000010, 0x00000024) + +CHECK-LABEL: .debug_tu_index contents: +NOTYP-NOT: Index +TYPES: Index Signature TYPES ABBREV LINE STR_OFFSETS +TYPES: 1 [[FOOSIG]] {{\[}}[[FOOUOFF]], [[BARUOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000000, 0x0000001a) [0x00000000, 0x00000010) +TYPES: 4 [[BARSIG]] {{\[}}[[BARUOFF]], [[XUOFF]]) [0x0000[[BAOFF]], 0x00000099) [0x0000001a, 0x00000034) [0x00000010, 0x00000024) + +Ensure we do not create a debug_tu_index, even an empty or malformed one. +NOTYPOBJ-NOT: .debug_tu_index + +CHECK-LABEL: .debug_str.dwo contents: +CHECK: "clang version +CHECK: 0x[[ACPP:.*]]: "a.cpp" +CHECK-NOT: "clang version +CHECK: 0x[[BCPP:.*]]: "b.cpp" + +CHECK-LABEL: .debug_str_offsets.dwo contents: +CHECK: : 00000000 +CHECK: : [[ACPP]] +CHECK: : 00000000 +CHECK: : [[BCPP]] diff --git a/test/tools/llvm-dwp/X86/type_dedup.test b/test/tools/llvm-dwp/X86/type_dedup.test new file mode 100644 index 000000000000..3005705fcaa0 --- /dev/null +++ b/test/tools/llvm-dwp/X86/type_dedup.test @@ -0,0 +1,35 @@ +RUN: llvm-dwp %p/../Inputs/type_dedup/a.dwo %p/../Inputs/type_dedup/b.dwo -o %t +RUN: llvm-dwarfdump %t | FileCheck %s + +a.cpp: + struct common { }; + common a1; + struct adistinct { }; + adistinct a2; + +b.cpp: + struct common { }; + common b1; + struct bdistinct { }; + bdistinct b2; + +CHECK-LABEL: .debug_types.dwo contents: +CHECK: [[COMMONUOFF:0x[0-9a-f]*]]: +CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +CHECK: 0x0000 addr_size = 0x08 type_signature = [[COMMONSIG:0x[0-9a-f]*]] type_offset = 0x[[COMMONOFF:.*]] (next unit at [[AUOFF:.*]]) +CHECK: DW_TAG_type_unit +CHECK: [[COMMONOFF]]: DW_TAG_structure_type +CHECK: DW_AT_name {{.*}} "common" +CHECK: [[AUOFF]]: +CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +CHECK: 0x0000 addr_size = 0x08 type_signature = [[ASIG:0x[0-9a-f]*]] type_offset = 0x[[AOFF:.*]] (next unit at [[BUOFF:.*]]) +CHECK: DW_TAG_type_unit +CHECK: 0x00000042: DW_TAG_structure_type +CHECK: DW_AT_name {{.*}} "adistinct" +CHECK: [[BUOFF]]: +CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset = +CHECK: 0x{{.*}} addr_size = 0x08 type_signature = [[BSIG:0x[0-9a-f]*]] type_offset = 0x[[BOFF:.*]] (next unit at [[XUOFF:.*]]) +CHECK: DW_TAG_type_unit +CHECK: 0x00000066: DW_TAG_structure_type +CHECK: DW_AT_name {{.*}} "bdistinct" +CHECK-NOT: Type Unit diff --git a/test/tools/llvm-lto/Inputs/thinlto.ll b/test/tools/llvm-lto/Inputs/thinlto.ll new file mode 100644 index 000000000000..4e0840f3691e --- /dev/null +++ b/test/tools/llvm-lto/Inputs/thinlto.ll @@ -0,0 +1,4 @@ +define void @g() { +entry: + ret void +} diff --git a/test/tools/llvm-lto/thinlto.ll b/test/tools/llvm-lto/thinlto.ll new file mode 100644 index 000000000000..5bd9dd975d2d --- /dev/null +++ b/test/tools/llvm-lto/thinlto.ll @@ -0,0 +1,24 @@ +; Test combined function index generation for ThinLTO via llvm-lto. +; RUN: llvm-as -function-summary %s -o %t.o +; RUN: llvm-as -function-summary %p/Inputs/thinlto.ll -o %t2.o +; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o +; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED +; RUN: not test -e %t3 + +; COMBINED: <MODULE_STRTAB_BLOCK +; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto.ll.tmp{{.*}}.o' +; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto.ll.tmp{{.*}}.o' +; COMBINED-NEXT: </MODULE_STRTAB_BLOCK +; COMBINED-NEXT: <FUNCTION_SUMMARY_BLOCK +; COMBINED-NEXT: <COMBINED_ENTRY +; COMBINED-NEXT: <COMBINED_ENTRY +; COMBINED-NEXT: </FUNCTION_SUMMARY_BLOCK +; COMBINED-NEXT: <VALUE_SYMTAB +; COMBINED-NEXT: <COMBINED_FNENTRY {{.*}} record string = '{{f|g}}' +; COMBINED-NEXT: <COMBINED_FNENTRY {{.*}} record string = '{{f|g}}' +; COMBINED-NEXT: </VALUE_SYMTAB + +define void @f() { +entry: + ret void +} diff --git a/test/tools/llvm-mc/basic.test b/test/tools/llvm-mc/basic.test new file mode 100644 index 000000000000..edac65257e55 --- /dev/null +++ b/test/tools/llvm-mc/basic.test @@ -0,0 +1,3 @@ +# RUN: not llvm-mc %t.blah -o %t2 2>&1 | FileCheck --check-prefix=ENOENT %s + +# ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory diff --git a/test/tools/llvm-mc/fatal_warnings.test b/test/tools/llvm-mc/fatal_warnings.test new file mode 100644 index 000000000000..e9405ada7a04 --- /dev/null +++ b/test/tools/llvm-mc/fatal_warnings.test @@ -0,0 +1,4 @@ +# RUN: not llvm-mc --fatal-warnings %s 2>&1 | FileCheck %s + +# CHECK: error: .warning directive invoked in source file +.warning diff --git a/test/tools/llvm-mc/line_end_with_space.test b/test/tools/llvm-mc/line_end_with_space.test index 2ce313990af0..673d05a68067 100644 --- a/test/tools/llvm-mc/line_end_with_space.test +++ b/test/tools/llvm-mc/line_end_with_space.test @@ -1,2 +1 @@ RUN: llvm-mc -disassemble %s -
\ No newline at end of file diff --git a/test/tools/llvm-mc/lit.local.cfg b/test/tools/llvm-mc/lit.local.cfg new file mode 100644 index 000000000000..a1bda0f1fdc8 --- /dev/null +++ b/test/tools/llvm-mc/lit.local.cfg @@ -0,0 +1,4 @@ +# Requires a non-empty default triple for these tests +if 'default_triple' not in config.available_features: + config.unsupported = True + diff --git a/test/tools/llvm-mc/no_warnings.test b/test/tools/llvm-mc/no_warnings.test new file mode 100644 index 000000000000..973dc271a581 --- /dev/null +++ b/test/tools/llvm-mc/no_warnings.test @@ -0,0 +1,4 @@ +# RUN: llvm-mc --no-warn %s 2>&1 | FileCheck %s + +# CHECK-NOT: warning: +.warning diff --git a/test/tools/llvm-nm/X86/IRobj.test b/test/tools/llvm-nm/X86/IRobj.test new file mode 100644 index 000000000000..e6fa517d00e8 --- /dev/null +++ b/test/tools/llvm-nm/X86/IRobj.test @@ -0,0 +1,11 @@ +# RUN: llvm-nm -format darwin %p/Inputs/test.IRobj-x86_64 | FileCheck %s + +# CHECK: ---------------- (LTO,RODATA) external _global_const +# CHECK: ---------------- (LTO,DATA) external _global_data +# CHECK: ---------------- (LTO,CODE) external _global_func +# CHECK: ---------------- (LTO,RODATA) private external _hidden_const +# CHECK: ---------------- (LTO,DATA) private external _hidden_data +# CHECK: ---------------- (LTO,CODE) private external _hidden_func +# CHECK: ---------------- (LTO,RODATA) non-external _static_const +# CHECK: ---------------- (LTO,DATA) non-external _static_data +# CHECK: ---------------- (LTO,CODE) non-external _static_func diff --git a/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 b/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 Binary files differnew file mode 100644 index 000000000000..2b59a1cfc63b --- /dev/null +++ b/test/tools/llvm-nm/X86/Inputs/hello.obj.macho-x86_64 diff --git a/test/tools/llvm-nm/X86/Inputs/test.IRobj-x86_64 b/test/tools/llvm-nm/X86/Inputs/test.IRobj-x86_64 Binary files differnew file mode 100644 index 000000000000..8bfa857fa7d1 --- /dev/null +++ b/test/tools/llvm-nm/X86/Inputs/test.IRobj-x86_64 diff --git a/test/tools/llvm-nm/X86/externalonly.test b/test/tools/llvm-nm/X86/externalonly.test new file mode 100644 index 000000000000..c37412987865 --- /dev/null +++ b/test/tools/llvm-nm/X86/externalonly.test @@ -0,0 +1,4 @@ +# RUN: llvm-nm -g %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK-NOT: EH_frame0 +# CHECK: _main diff --git a/test/tools/llvm-nm/X86/groupingflags.test b/test/tools/llvm-nm/X86/groupingflags.test new file mode 100644 index 000000000000..a1a258506e97 --- /dev/null +++ b/test/tools/llvm-nm/X86/groupingflags.test @@ -0,0 +1,5 @@ +# RUN: llvm-nm -gjp %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK: _main +# CHECK: _main.eh +# CHECK: _printf diff --git a/test/tools/llvm-nm/X86/posixMachO.test b/test/tools/llvm-nm/X86/posixMachO.test new file mode 100644 index 000000000000..a0d114237ce0 --- /dev/null +++ b/test/tools/llvm-nm/X86/posixMachO.test @@ -0,0 +1,7 @@ +# RUN: llvm-nm -P %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s + +# CHECK: EH_frame0 s 104 0 +# CHECK: L_.str s 59 0 +# CHECK: _main T 0 0 +# CHECK: _main.eh S 128 0 +# CHECK: _printf U 0 0 diff --git a/test/tools/llvm-nm/lit.local.cfg b/test/tools/llvm-nm/lit.local.cfg new file mode 100644 index 000000000000..c8625f4d9d24 --- /dev/null +++ b/test/tools/llvm-nm/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'X86' in config.root.targets: + config.unsupported = True diff --git a/test/tools/llvm-objdump/AArch64/elf-aarch64-mapping-symbols.test b/test/tools/llvm-objdump/AArch64/elf-aarch64-mapping-symbols.test new file mode 100644 index 000000000000..cb9560d74dfb --- /dev/null +++ b/test/tools/llvm-objdump/AArch64/elf-aarch64-mapping-symbols.test @@ -0,0 +1,30 @@ +# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t +# RUN: llvm-objdump -d %t | FileCheck %s + +.section .mysection,"ax",@progbits +.globl _start +_start: + adr x1,msg +msg: .asciz "Hello, world\n" +msgend: + +.section .myothersection,"ax",@progbits + adrp x1,mystr +mystr: + .asciz "blah" + .size mystr, 4 + +# CHECK: Disassembly of section .mysection: +# CHECK: _start: +# CHECK: 0: 21 00 00 10 adr x1, #4 +# CHECK: msg: +# CHECK: 4: 48 65 6c 6c .word +# CHECK: 8: 6f 2c 20 77 .word +# CHECK: c: 6f 72 6c 64 .word +# CHECK: 10: 0a 00 .short +# CHECK: Disassembly of section .myothersection: +# CHECK: $x.2: +# CHECK: 0: 01 00 00 90 adrp x1, #0 +# CHECK: mystr: +# CHECK: 4: 62 6c 61 68 .word +# CHECK: 8: 00 .byte diff --git a/test/tools/llvm-objdump/Inputs/eh_frame.macho-arm64 b/test/tools/llvm-objdump/Inputs/eh_frame.macho-arm64 Binary files differnew file mode 100644 index 000000000000..1c5413230d7a --- /dev/null +++ b/test/tools/llvm-objdump/Inputs/eh_frame.macho-arm64 diff --git a/test/tools/llvm-objdump/Inputs/libbogus1.a b/test/tools/llvm-objdump/Inputs/libbogus1.a new file mode 100644 index 000000000000..510c1455527d --- /dev/null +++ b/test/tools/llvm-objdump/Inputs/libbogus1.a @@ -0,0 +1,13 @@ +!<arch> +hello.c 1444941273 124 0 100644 10% ` +#include <stdio.h> +#include <stdlib.h> +int +main() +{ + printf("Hello World\n"); + return EXIT_SUCCESS; +} +foo.c 1444941645 124 0 100644 1% ` +void foo(void){} + diff --git a/test/tools/llvm-objdump/Inputs/libbogus2.a b/test/tools/llvm-objdump/Inputs/libbogus2.a new file mode 100644 index 000000000000..2ccb7f31c09d --- /dev/null +++ b/test/tools/llvm-objdump/Inputs/libbogus2.a @@ -0,0 +1,13 @@ +!<arch> +hello.c 1444941273 124 0 100644 102 ` +#include <stdio.h> +#include <stdlib.h> +int +main() +{ + printf("Hello World\n"); + return EXIT_SUCCESS; +} +foo.c 1444941645 124 0 100644 1% ` +void foo(void){} + diff --git a/test/tools/llvm-objdump/Inputs/libbogus3.a b/test/tools/llvm-objdump/Inputs/libbogus3.a new file mode 100644 index 000000000000..f15a7329f9f4 --- /dev/null +++ b/test/tools/llvm-objdump/Inputs/libbogus3.a @@ -0,0 +1,16 @@ +!<arch> +hello.c 1444941273 124 0 100644 102 ` +#include <stdio.h> +#include <stdlib.h> +int +main() +{ + printf("Hello World\n"); + return EXIT_SUCCESS; +} +foo.c 1444941645 124 0 100644 171 ` +void foo(void){} + +bar.c 1445026190 124 0 100644 17 ` +void foo(void){} + diff --git a/test/tools/llvm-objdump/Inputs/section-filter.obj b/test/tools/llvm-objdump/Inputs/section-filter.obj Binary files differnew file mode 100644 index 000000000000..7dc5dae26b79 --- /dev/null +++ b/test/tools/llvm-objdump/Inputs/section-filter.obj diff --git a/test/tools/llvm-objdump/X86/Inputs/disassemble-data.obj b/test/tools/llvm-objdump/X86/Inputs/disassemble-data.obj Binary files differnew file mode 100644 index 000000000000..6381120a1c83 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/disassemble-data.obj diff --git a/test/tools/llvm-objdump/X86/Inputs/disassemble.dll.coff-i386 b/test/tools/llvm-objdump/X86/Inputs/disassemble.dll.coff-i386 Binary files differnew file mode 100755 index 000000000000..c0fbc8803630 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/disassemble.dll.coff-i386 diff --git a/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 b/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 Binary files differnew file mode 100755 index 000000000000..0c38deb7cf0b --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/00000031.a b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/00000031.a Binary files differnew file mode 100644 index 000000000000..b784d8163f54 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/00000031.a diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0001.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0001.macho Binary files differnew file mode 100644 index 000000000000..d81f9f00f4a7 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0001.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0006.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0006.macho Binary files differnew file mode 100644 index 000000000000..13a4e9aea7fa --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0006.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0010.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0010.macho Binary files differnew file mode 100644 index 000000000000..4c7e78d93b62 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0010.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0040.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0040.macho Binary files differnew file mode 100644 index 000000000000..f0765a4ce51a --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0040.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0080.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0080.macho Binary files differnew file mode 100644 index 000000000000..53e3a97b4aa9 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0080.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0261.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0261.macho Binary files differnew file mode 100644 index 000000000000..a573da3b2fbc --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0261.macho diff --git a/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0337.macho b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0337.macho Binary files differnew file mode 100644 index 000000000000..cc438414f112 --- /dev/null +++ b/test/tools/llvm-objdump/X86/Inputs/malformed-machos/mem-crup-0337.macho diff --git a/test/tools/llvm-objdump/X86/coff-dis-internal.test b/test/tools/llvm-objdump/X86/coff-dis-internal.test new file mode 100644 index 000000000000..530dadc8142e --- /dev/null +++ b/test/tools/llvm-objdump/X86/coff-dis-internal.test @@ -0,0 +1,3 @@ +RUN: llvm-objdump -d %p/Inputs/internal.exe.coff-x86_64 | FileCheck %s + +CHECK: callq {{.*}} <foo> diff --git a/test/tools/llvm-objdump/X86/coff-disassemble-export.test b/test/tools/llvm-objdump/X86/coff-disassemble-export.test new file mode 100644 index 000000000000..2f0b211815cf --- /dev/null +++ b/test/tools/llvm-objdump/X86/coff-disassemble-export.test @@ -0,0 +1,8 @@ +// RUN: llvm-objdump -d %p/Inputs/disassemble.dll.coff-i386 | \ +// RUN: FileCheck %s + +// CHECK-LABEL: g: +// CHECK: calll 8 <f> + +// CHECK-LABEL: f: +// CHECK: calll -24 <g> diff --git a/test/tools/llvm-objdump/X86/disassemble-data.test b/test/tools/llvm-objdump/X86/disassemble-data.test new file mode 100644 index 000000000000..e9c4e7e1e5f2 --- /dev/null +++ b/test/tools/llvm-objdump/X86/disassemble-data.test @@ -0,0 +1,4 @@ +// This test checks that -D disassembles from a data section +// RUN: llvm-objdump -D %p/Inputs/disassemble-data.obj | FileCheck %s + +// CHECK: Disassembly of section .data:
\ No newline at end of file diff --git a/test/tools/llvm-objdump/X86/macho-symbol-table.test b/test/tools/llvm-objdump/X86/macho-symbol-table.test index 826d78af68b1..19c619e73d07 100644 --- a/test/tools/llvm-objdump/X86/macho-symbol-table.test +++ b/test/tools/llvm-objdump/X86/macho-symbol-table.test @@ -1,8 +1,8 @@ RUN: llvm-objdump -macho -t %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s CHECK: SYMBOL TABLE: -CHECK: 000000000000003b l F __TEXT,__cstring L_.str -CHECK: 0000000000000068 l F __TEXT,__eh_frame EH_frame0 +CHECK: 000000000000003b l __TEXT,__cstring L_.str +CHECK: 0000000000000068 l __TEXT,__eh_frame EH_frame0 CHECK: 0000000000000000 g F __TEXT,__text _main -CHECK: 0000000000000080 g F __TEXT,__eh_frame _main.eh +CHECK: 0000000000000080 g __TEXT,__eh_frame _main.eh CHECK: 0000000000000000 *UND* _printf diff --git a/test/tools/llvm-objdump/X86/malformed-machos.test b/test/tools/llvm-objdump/X86/malformed-machos.test new file mode 100644 index 000000000000..a47e43443c5d --- /dev/null +++ b/test/tools/llvm-objdump/X86/malformed-machos.test @@ -0,0 +1,41 @@ +// These test checks that llvm-objdump will not crash with malformed Mach-O +// files. So the check line is not all that important but the bug fixes to +// make sure llvm-objdump is robust is what matters. +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0001.macho \ +# RUN: | FileCheck -check-prefix=m0001 %s + +# m0001: (method_t extends past the end of the section) + +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0006.macho \ +# RUN: | FileCheck -check-prefix=m0006 %s + +# m0006: ivarLayout 0x8 + +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0006.macho \ +# RUN: | FileCheck -check-prefix=m0010 %s + +# m0010: 00000000000010e0 0x10e8 _OBJC_CLASS_ + +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0040.macho \ +# RUN: | FileCheck -check-prefix=m0040 %s + +# m0040: 00000000000010a0 0xf39 -[tiny_dylib init] + +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0080.macho \ +# RUN: | FileCheck -check-prefix=m0080 %s + +# m0080: data 0xf960000 (struct class_ro_t *) + +# RUN: llvm-objdump -macho -objc-meta-data \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0261.macho + +# RUN: llvm-objdump -macho -disassemble \ +# RUN: %p/Inputs/malformed-machos/mem-crup-0337.macho \ +# RUN: | FileCheck -check-prefix=m0337 %s + +# m0337: subq $16, %rsp diff --git a/test/tools/llvm-objdump/eh_frame-arm64.test b/test/tools/llvm-objdump/eh_frame-arm64.test new file mode 100644 index 000000000000..f25e035a266e --- /dev/null +++ b/test/tools/llvm-objdump/eh_frame-arm64.test @@ -0,0 +1,23 @@ +# RUN: llvm-objdump -unwind-info %p/Inputs/eh_frame.macho-arm64 2>/dev/null | FileCheck %s + +# CHECK: Contents of __eh_frame section: +# CHECK: CIE: +# CHECK: Length: 16 +# CHECK: CIE ID: 0 +# CHECK: Version: 1 +# CHECK: Augmentation String: zR +# CHECK: Code Alignment Factor: 1 +# CHECK: Data Alignment Factor: -8 +# CHECK: Return Address Register: 30 +# CHECK: Augmentation Data Length: 1 +# CHECK: FDE Address Pointer Encoding: 16 +# CHECK: Instructions: +# CHECK: 0c 1f 00 +# CHECK: FDE: +# CHECK: Length: 32 +# CHECK: CIE Offset: 0 +# CHECK: PC Begin: ffffffffffffffe4 +# CHECK: PC Range: 0000000000000020 +# CHECK: Augmentation Data Length: 0 +# CHECK: Instructions: +# CHECK: 48 0e 10 9e 01 9d 02 00 00 00 00 diff --git a/test/tools/llvm-objdump/malformed-archives.test b/test/tools/llvm-objdump/malformed-archives.test new file mode 100644 index 000000000000..e0f165d37ed7 --- /dev/null +++ b/test/tools/llvm-objdump/malformed-archives.test @@ -0,0 +1,20 @@ +// These test checks that llvm-objdump will not crash with malformed Archive +// files. So the check line is not all that important but the bug fixes to +// make sure llvm-objdump is robust is what matters. +# RUN: llvm-objdump -macho -archive-headers \ +# RUN: %p/Inputs/libbogus1.a \ +# RUN: 2>&1 | FileCheck -check-prefix=bogus1 %s + +# bogus1: Invalid data was encountered while parsing the file + +# RUN: not llvm-objdump -macho -archive-headers \ +# RUN: %p/Inputs/libbogus2.a \ +# RUN: 2>&1 | FileCheck -check-prefix=bogus2 %s + +# bogus2: LLVM ERROR: Invalid data was encountered while parsing the file + +# RUN: not llvm-objdump -macho -archive-headers \ +# RUN: %p/Inputs/libbogus3.a \ +# RUN: 2>&1 | FileCheck -check-prefix=bogus3 %s + +# bogus3: LLVM ERROR: Invalid data was encountered while parsing the file diff --git a/test/tools/llvm-objdump/section-filter.test b/test/tools/llvm-objdump/section-filter.test new file mode 100644 index 000000000000..9c7ab31b0d72 --- /dev/null +++ b/test/tools/llvm-objdump/section-filter.test @@ -0,0 +1,7 @@ +// This test checks that --section works correctly +// RUN: llvm-objdump -h %p/Inputs/section-filter.obj -j=.text \ +// RUN: --section=.bss | FileCheck %s + +# CHECK: .text +# CHECK-NOT: .data +# CHECK: .bss
\ No newline at end of file diff --git a/test/tools/llvm-pdbdump/regex-filter.test b/test/tools/llvm-pdbdump/regex-filter.test index 8b9eca63f585..cfc910e07171 100644 --- a/test/tools/llvm-pdbdump/regex-filter.test +++ b/test/tools/llvm-pdbdump/regex-filter.test @@ -10,6 +10,10 @@ ; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_WHOLE_CLASS %s ; RUN: llvm-pdbdump -symbols -globals -exclude-compilands="FilterTest.obj" \ ; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=EXCLUDE_COMPILAND %s +; RUN: llvm-pdbdump -types -include-types="FilterTestClass" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=INCLUDE_ONLY_TYPES %s +; RUN: llvm-pdbdump -types -symbols -globals -include-symbols="[[:<:]](IntGlobalVar|DoubleGlobalVar)[[:>:]]" \ +; RUN: %p/Inputs/FilterTest.pdb | FileCheck --check-prefix=INCLUDE_ONLY_VARS %s ; NO_FILTER: ---TYPES--- ; NO_FILTER: Enums: @@ -73,3 +77,19 @@ ; EXCLUDE_COMPILAND-NOT: __cdecl main ; EXCLUDE_COMPILAND: * Linker * ; EXCLUDE_COMPILAND: ---GLOBALS--- + +; Everything but types are displayed normally. But FilterTestClass is +; the only type that should be displayed. +; INCLUDE_ONLY_TYPES: ---TYPES--- +; INCLUDE_ONLY_TYPES-NOT: GlobalTypedef +; INCLUDE_ONLY_TYPES: class FilterTestClass + +; We should only see DoubleGlobalVar and IntGlobalVar. This means that even +; variables printed in class definitions should be filtered out. +; INCLUDE_ONLY_VARS: ---TYPES--- +; INCLUDE_ONLY_VARS: class FilterTestClass +; INCLUDE_ONLY_VARS-NOT: IntMemberVar +; INCLUDE_ONLY_VARS-NOT: IntDoubleVar +; INCLUDE_ONLY_VARS: ---GLOBALS--- +; INCLUDE_ONLY_VARS: DoubleGlobalVar +; INCLUDE_ONLY_VARS: IntGlobalVar diff --git a/test/tools/llvm-profdata/Inputs/basic.proftext b/test/tools/llvm-profdata/Inputs/basic.proftext new file mode 100644 index 000000000000..db934da7c07a --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/basic.proftext @@ -0,0 +1,19 @@ +foo +10 +2 +499500 +179900 + +main +16650 +4 +1 +1000 +1000000 +499500 + +foo2 +10 +2 +500500 +180100 diff --git a/test/tools/llvm-profdata/Inputs/c-general.profraw b/test/tools/llvm-profdata/Inputs/c-general.profraw Binary files differindex e8cef21de5f2..a4d94858a9e7 100644 --- a/test/tools/llvm-profdata/Inputs/c-general.profraw +++ b/test/tools/llvm-profdata/Inputs/c-general.profraw diff --git a/test/tools/llvm-profdata/Inputs/compat.profdata.v2 b/test/tools/llvm-profdata/Inputs/compat.profdata.v2 Binary files differnew file mode 100644 index 000000000000..969867584a99 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/compat.profdata.v2 diff --git a/test/tools/llvm-profdata/Inputs/gcc-sample-profile.gcov b/test/tools/llvm-profdata/Inputs/gcc-sample-profile.gcov Binary files differnew file mode 100644 index 000000000000..0099280af2f9 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/gcc-sample-profile.gcov diff --git a/test/tools/llvm-profdata/Inputs/inline-samples.afdo b/test/tools/llvm-profdata/Inputs/inline-samples.afdo new file mode 100644 index 000000000000..f8680d86fcb4 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/inline-samples.afdo @@ -0,0 +1,20 @@ +main:366846:0 + 2.1: 60401 + 4: 0 + 3: 0 + 0: 0 + 2.3: 60401 + 1: 0 + 2.3: _Z3fool:246044 + 1.2: 39280 + 1.4: 46871 + 1: 60401 + 1.3: _Z3bari:0 + 1.2: 0 + 1.1: 0 + 1.8: _Z3bari:0 + 1.2: 0 + 1.1: 0 + 1.7: _Z3bari:99492 + 1.2: 46732 + 1.1: 52760 diff --git a/test/tools/llvm-profdata/Inputs/overflow-instr.proftext b/test/tools/llvm-profdata/Inputs/overflow-instr.proftext new file mode 100644 index 000000000000..48d1db88bcdf --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/overflow-instr.proftext @@ -0,0 +1,6 @@ +overflow +1 +3 +18446744073709551615 +9223372036854775808 +18446744073709551615 diff --git a/test/tools/llvm-profdata/Inputs/overflow-sample.proftext b/test/tools/llvm-profdata/Inputs/overflow-sample.proftext new file mode 100644 index 000000000000..a5486bbd819c --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/overflow-sample.proftext @@ -0,0 +1,7 @@ +_Z3bari:18446744073709551615:1000 + 1: 18446744073709551615 +_Z3fooi:18446744073709551615:1000 + 1: 18446744073709551615 +main:1000:0 + 1: 500 _Z3bari:18446744073709551615 + 2: 500 _Z3fooi:18446744073709551615 diff --git a/test/tools/llvm-profdata/Inputs/sample-profile.proftext b/test/tools/llvm-profdata/Inputs/sample-profile.proftext index 9dc6d4310da9..54c821243afa 100644 --- a/test/tools/llvm-profdata/Inputs/sample-profile.proftext +++ b/test/tools/llvm-profdata/Inputs/sample-profile.proftext @@ -1,12 +1,12 @@ _Z3bari:20301:1437 -1: 1437 + 1: 1437 _Z3fooi:7711:610 -1: 610 + 1: 610 main:184019:0 -4: 534 -4.2: 534 -5: 1075 -5.1: 1075 -6: 2080 -7: 534 -9: 2064 _Z3bari:1471 _Z3fooi:631 + 4: 534 + 4.2: 534 + 5: 1075 + 5.1: 1075 + 6: 2080 + 7: 534 + 9: 2064 _Z3bari:1471 _Z3fooi:631 diff --git a/test/tools/llvm-profdata/Inputs/text-format-errors.text.bin b/test/tools/llvm-profdata/Inputs/text-format-errors.text.bin new file mode 100644 index 000000000000..9e2e3f5c2b83 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/text-format-errors.text.bin @@ -0,0 +1 @@ +ÿåбôÉ”¨
\ No newline at end of file diff --git a/test/tools/llvm-profdata/Inputs/vp-malform.proftext b/test/tools/llvm-profdata/Inputs/vp-malform.proftext new file mode 100644 index 000000000000..2db3096cecf1 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/vp-malform.proftext @@ -0,0 +1,42 @@ +foo +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +999000 +359800 + +foo2 +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1001000 +360200 + +main +# Func Hash: +16650 +# Num Counters: +4 +# Counter Values: +2 +2000 +2000000 +999000 +# NumValueKinds +1 +# Value Kind IPVK_IndirectCallTarget +0 +# NumSites +3 +# Values for each site +0 +2 +# !!!! Malformed Value/Count pair +foo+100 +foo2:1000 +1 +foo2:20000 diff --git a/test/tools/llvm-profdata/Inputs/vp-malform2.proftext b/test/tools/llvm-profdata/Inputs/vp-malform2.proftext new file mode 100644 index 000000000000..02ed5a968d80 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/vp-malform2.proftext @@ -0,0 +1,32 @@ +foo +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +999000 +359800 + +main +# Func Hash: +16650 +# Num Counters: +4 +# Counter Values: +2 +2000 +2000000 +999000 +# NumValueKinds +1 +# Value Kind IPVK_IndirectCallTarget +0 +# NumSites +3 +# Values for each site +0 +# !! Malformed value site, missing one value +2 +foo:100 +1 +foo2:20000 diff --git a/test/tools/llvm-profdata/Inputs/vp-truncate.proftext b/test/tools/llvm-profdata/Inputs/vp-truncate.proftext new file mode 100644 index 000000000000..98b4b572b65c --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/vp-truncate.proftext @@ -0,0 +1,36 @@ +foo +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +999000 +359800 + +foo2 +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1001000 +360200 + +main +# Func Hash: +16650 +# Num Counters: +4 +# Counter Values: +2 +2000 +2000000 +999000 +# NumValueKinds +1 +# Value Kind IPVK_IndirectCallTarget +0 +# NumSites +3 +# Values for each site +0 diff --git a/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata b/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata Binary files differnew file mode 100644 index 000000000000..4ed07660f654 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/weight-instr-bar.profdata diff --git a/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata b/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata Binary files differnew file mode 100644 index 000000000000..581ef39a55b2 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/weight-instr-foo.profdata diff --git a/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext b/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext new file mode 100644 index 000000000000..a910f745e6c7 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/weight-sample-bar.proftext @@ -0,0 +1,8 @@ +bar:1772037:35370 + 17: 35370 + 18: 35370 + 19: 7005 + 20: 29407 + 21: 12170 + 23: 18150 bar:19829 + 25: 36666 diff --git a/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext b/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext new file mode 100644 index 000000000000..155ec5d00315 --- /dev/null +++ b/test/tools/llvm-profdata/Inputs/weight-sample-foo.proftext @@ -0,0 +1,8 @@ +foo:1763288:35327 + 7: 35327 + 8: 35327 + 9: 6930 + 10: 29341 + 11: 11906 + 13: 18185 foo:19531 + 15: 36458 diff --git a/test/tools/llvm-profdata/c-general.test b/test/tools/llvm-profdata/c-general.test index 01435303d445..efa9bfa18d73 100644 --- a/test/tools/llvm-profdata/c-general.test +++ b/test/tools/llvm-profdata/c-general.test @@ -6,7 +6,7 @@ REGENERATE: $ SRC=path/to/llvm REGENERATE: $ CFE=$SRC/tools/clang REGENERATE: $ TESTDIR=$SRC/test/tools/llvm-profdata REGENERATE: $ CFE_TESTDIR=$CFE/test/Profile -REGENERATE: $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/test/Profile/c-general.c +REGENERATE: $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/c-general.c REGENERATE: $ LLVM_PROFILE_FILE=$TESTDIR/Inputs/c-general.profraw ./a.out RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - | FileCheck %s -check-prefix=CHECK @@ -14,11 +14,11 @@ RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function=switches | F SWITCHES-LABEL: Counters: SWITCHES-NEXT: switches: -SWITCHES-NEXT: Hash: 0x0000000000000013 +SWITCHES-NEXT: Hash: 0x2618e4f23f2e8daa SWITCHES-NEXT: Counters: 19 SWITCHES-NEXT: Function count: 1 SWITCHES-LABEL: Functions shown: 1 -CHECK-LABEL: Total functions: 11 +CHECK-LABEL: Total functions: 12 CHECK-NEXT: Maximum function count: 1 CHECK-NEXT: Maximum internal block count: 100 diff --git a/test/tools/llvm-profdata/compat.proftext b/test/tools/llvm-profdata/compat.proftext index 14da3374b5e9..139202d162e6 100644 --- a/test/tools/llvm-profdata/compat.proftext +++ b/test/tools/llvm-profdata/compat.proftext @@ -45,3 +45,23 @@ large_numbers # SUMMARY: Total functions: 3 # SUMMARY: Maximum function count: 2305843009213693952 # SUMMARY: Maximum internal block count: 1152921504606846976 + +# RUN: llvm-profdata show %S/Inputs/compat.profdata.v2 -all-functions --counts | FileCheck %s -check-prefix=FORMATV2 + +# FORMATV2: Counters: +# FORMATV2-NEXT: foo: +# FORMATV2-NEXT: Hash: 0x000000000000000a +# FORMATV2-NEXT: Counters: 2 +# FORMATV2-NEXT: Function count: 499500 +# FORMATV2-NEXT: Block counts: [179900] +# FORMATV2-NEXT: main: +# FORMATV2-NEXT: Hash: 0x000000000000410a +# FORMATV2-NEXT: Counters: 4 +# FORMATV2-NEXT: Function count: 1 +# FORMATV2-NEXT: Block counts: [1000, 1000000, 499500] +# FORMATV2-NEXT: Functions shown: 2 +# FORMATV2-NEXT: Total functions: 2 +# FORMATV2-NEXT: Maximum function count: 499500 +# FORMATV2-NEXT: Maximum internal block count: 1000000 + + diff --git a/test/tools/llvm-profdata/count-mismatch.proftext b/test/tools/llvm-profdata/count-mismatch.proftext index 1a2e73fbffdb..b42b11dbcf9d 100644 --- a/test/tools/llvm-profdata/count-mismatch.proftext +++ b/test/tools/llvm-profdata/count-mismatch.proftext @@ -14,7 +14,8 @@ foo # The hash matches, but we can't combine these because the number of # counters differs. -# MERGE_ERRS: count-mismatch.proftext: foo: Function count mismatch +# MERGE_ERRS: count-mismatch.proftext: foo: Function basic block count change detected (counter mismatch) +# MERGE_ERRS: Make sure that all profile data to be merged is generated from the same binary. foo 1024 3 diff --git a/test/tools/llvm-profdata/gcc-gcov-sample-profile.test b/test/tools/llvm-profdata/gcc-gcov-sample-profile.test new file mode 100644 index 000000000000..dbcc74e1284f --- /dev/null +++ b/test/tools/llvm-profdata/gcc-gcov-sample-profile.test @@ -0,0 +1,29 @@ +The input gcov file has been generated on a little endian machine. Expect +failures on big endian systems. + +XFAIL: powerpc64-, s390x, mips-, mips64-, sparc + +Tests for sample profiles encoded in GCC's gcov format. + +1- Show all functions. This profile has a single main() function with several + inlined callees. +RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov | FileCheck %s --check-prefix=SHOW1 +SHOW1: Function: main: 364084, 0, 6 sampled lines +SHOW1: 2.3: inlined callee: _Z3fool: 243786, 0, 3 sampled lines +SHOW1: 1.3: inlined callee: _Z3bari: 0, 0, 2 sampled lines +SHOW1: 1.7: inlined callee: _Z3bari: 98558, 0, 2 sampled lines +SHOW1: 1.8: inlined callee: _Z3bari: 0, 0, 2 sampled lines + +2- Convert the profile to text encoding and check that they are both + identical. +RUN: llvm-profdata merge --sample %p/Inputs/gcc-sample-profile.gcov --text -o - | llvm-profdata show --sample - -o %t-text +RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov -o %t-gcov +RUN: diff %t-text %t-gcov + +4- Merge the gcov and text encodings of the profile and check that the + counters have doubled. +RUN: llvm-profdata merge --sample --text %p/Inputs/gcc-sample-profile.gcov -o %t-gcov +RUN: llvm-profdata merge --sample --text %p/Inputs/gcc-sample-profile.gcov %t-gcov -o - | FileCheck %s --check-prefix=MERGE1 +MERGE1: main:728168:0 +MERGE1: 2.3: 120298 +MERGE1: 2.3: _Z3fool:487572 diff --git a/test/tools/llvm-profdata/inline-samples.test b/test/tools/llvm-profdata/inline-samples.test new file mode 100644 index 000000000000..421f002da9f9 --- /dev/null +++ b/test/tools/llvm-profdata/inline-samples.test @@ -0,0 +1,30 @@ +Tests for conversion between text and binary encoded sample profiles. + +1- Encode the original profile into binary form. All the tests below will use + the binary profile. +RUN: llvm-profdata merge --sample %p/Inputs/inline-samples.afdo -o %t.profbin + +2- Show all functions. This profile has a single main() function with several + inlined callees. +RUN: llvm-profdata show --sample %t.profbin | FileCheck %s --check-prefix=SHOW1 +SHOW1: Function: main: 366846, 0, 6 sampled lines +SHOW1: 2.3: inlined callee: _Z3fool: 246044, 0, 3 sampled lines +SHOW1: 1.3: inlined callee: _Z3bari: 0, 0, 2 sampled lines +SHOW1: 1.7: inlined callee: _Z3bari: 99492, 0, 2 sampled lines +SHOW1: 1.2: 46732 +SHOW1: 1.8: inlined callee: _Z3bari: 0, 0, 2 sampled lines + +3- Convert the binary profile to text encoding and check that they are both + identical. +RUN: llvm-profdata merge --sample %t.profbin --text -o - | llvm-profdata show --sample - -o %t-bintext +RUN: llvm-profdata show --sample %p/Inputs/inline-samples.afdo -o %t-text +RUN: diff %t-bintext %t-text + +4- Merge the binary and text encodings of the profile and check that the + counters have doubled. +RUN: llvm-profdata merge --sample --text %t.profbin %p/Inputs/inline-samples.afdo -o - | FileCheck %s --check-prefix=MERGE1 +MERGE1: main:733692:0 +MERGE1: 2.3: 120802 +MERGE1: 2.3: _Z3fool:492088 +MERGE1: 1.7: _Z3bari:198984 +MERGE1: 1.1: 105520 diff --git a/test/tools/llvm-profdata/overflow-instr.test b/test/tools/llvm-profdata/overflow-instr.test new file mode 100644 index 000000000000..5b9a94af9b29 --- /dev/null +++ b/test/tools/llvm-profdata/overflow-instr.test @@ -0,0 +1,17 @@ +Tests for overflow when merging instrumented profiles. + +1- Merge profile having maximum counts with itself and verify overflow detected and saturation occurred +RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW +RUN: llvm-profdata show -instr %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW +MERGE_OVERFLOW: {{.*}}: overflow: Counter overflow +SHOW_OVERFLOW: Total functions: 1 +SHOW_OVERFLOW-NEXT: Maximum function count: 18446744073709551615 +SHOW_OVERFLOW-NEXT: Maximum internal block count: 18446744073709551615 + +2- Merge profile having maximum counts by itself and verify no overflow +RUN: llvm-profdata merge -instr %p/Inputs/overflow-instr.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_NO_OVERFLOW -allow-empty +RUN: llvm-profdata show -instr %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW +MERGE_NO_OVERFLOW-NOT: {{.*}}: overflow: Counter overflow +SHOW_NO_OVERFLOW: Total functions: 1 +SHOW_NO_OVERFLOW-NEXT: Maximum function count: 18446744073709551615 +SHOW_NO_OVERFLOW-NEXT: Maximum internal block count: 18446744073709551615 diff --git a/test/tools/llvm-profdata/overflow-sample.test b/test/tools/llvm-profdata/overflow-sample.test new file mode 100644 index 000000000000..cd6268db2ab9 --- /dev/null +++ b/test/tools/llvm-profdata/overflow-sample.test @@ -0,0 +1,43 @@ +Tests for overflow when merging sampled profiles. + +1- Merge profile having maximum counts with itself and verify overflow detected +RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW +RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW +MERGE_OVERFLOW: {{.*}}: main: Counter overflow +SHOW_OVERFLOW: Function: main: 2000, 0, 2 sampled lines +SHOW_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_OVERFLOW-NEXT: 1: 1000, calls: _Z3bari:18446744073709551615 +SHOW_OVERFLOW-NEXT: 2: 1000, calls: _Z3fooi:18446744073709551615 +SHOW_OVERFLOW-NEXT: } +SHOW_OVERFLOW-NEXT: No inlined callsites in this function +SHOW_OVERFLOW-NEXT: Function: _Z3fooi: 18446744073709551615, 2000, 1 sampled lines +SHOW_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_OVERFLOW-NEXT: 1: 18446744073709551615 +SHOW_OVERFLOW-NEXT: } +SHOW_OVERFLOW-NEXT: No inlined callsites in this function +SHOW_OVERFLOW-NEXT: Function: _Z3bari: 18446744073709551615, 2000, 1 sampled lines +SHOW_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_OVERFLOW-NEXT: 1: 18446744073709551615 +SHOW_OVERFLOW-NEXT: } +SHOW_OVERFLOW-NEXT: No inlined callsites in this function + +2- Merge profile having maximum counts by itself and verify no overflow +RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -allow-empty -check-prefix=MERGE_NO_OVERFLOW +RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW +MERGE_NO_OVERFLOW-NOT: {{.*}}: main: Counter overflow +SHOW_NO_OVERFLOW: Function: main: 1000, 0, 2 sampled lines +SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_NO_OVERFLOW-NEXT: 1: 500, calls: _Z3bari:18446744073709551615 +SHOW_NO_OVERFLOW-NEXT: 2: 500, calls: _Z3fooi:18446744073709551615 +SHOW_NO_OVERFLOW-NEXT: } +SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function +SHOW_NO_OVERFLOW-NEXT: Function: _Z3fooi: 18446744073709551615, 1000, 1 sampled lines +SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_NO_OVERFLOW-NEXT: 1: 18446744073709551615 +SHOW_NO_OVERFLOW-NEXT: } +SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function +SHOW_NO_OVERFLOW-NEXT: Function: _Z3bari: 18446744073709551615, 1000, 1 sampled lines +SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body { +SHOW_NO_OVERFLOW-NEXT: 1: 18446744073709551615 +SHOW_NO_OVERFLOW-NEXT: } +SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function diff --git a/test/tools/llvm-profdata/overflow.proftext b/test/tools/llvm-profdata/overflow.proftext deleted file mode 100644 index cbf3bf161823..000000000000 --- a/test/tools/llvm-profdata/overflow.proftext +++ /dev/null @@ -1,12 +0,0 @@ -# RUN: llvm-profdata merge %s -o %t.out 2>&1 | FileCheck %s -# CHECK: overflow.proftext: overflow: Counter overflow - -overflow -1 -1 -9223372036854775808 - -overflow -1 -1 -9223372036854775808 diff --git a/test/tools/llvm-profdata/raw-32-bits-be.test b/test/tools/llvm-profdata/raw-32-bits-be.test index 86ac56d39f26..d20c36022fa6 100644 --- a/test/tools/llvm-profdata/raw-32-bits-be.test +++ b/test/tools/llvm-profdata/raw-32-bits-be.test @@ -1,27 +1,36 @@ RUN: printf '\377lprofR\201' > %t -RUN: printf '\0\0\0\0\0\0\0\1' >> %t +RUN: printf '\0\0\0\0\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\3' >> %t RUN: printf '\0\0\0\0\0\0\0\6' >> %t RUN: printf '\0\0\0\0\1\0\0\0' >> %t RUN: printf '\0\0\0\0\2\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\3' >> %t RUN: printf '\0\0\0\1' >> %t RUN: printf '\0\0\0\0\0\0\0\1' >> %t RUN: printf '\2\0\0\0' >> %t RUN: printf '\1\0\0\0' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\3' >> %t RUN: printf '\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\2' >> %t RUN: printf '\2\0\0\03' >> %t RUN: printf '\1\0\0\10' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\0\0\0\0\023' >> %t RUN: printf '\0\0\0\0\0\0\0\067' >> %t RUN: printf '\0\0\0\0\0\0\0\101' >> %t -RUN: printf 'foobar' >> %t +RUN: printf 'foobar\0\0' >> %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s diff --git a/test/tools/llvm-profdata/raw-32-bits-le.test b/test/tools/llvm-profdata/raw-32-bits-le.test index 9325e7eb0f52..1bd81a87fbac 100644 --- a/test/tools/llvm-profdata/raw-32-bits-le.test +++ b/test/tools/llvm-profdata/raw-32-bits-le.test @@ -1,27 +1,36 @@ RUN: printf '\201Rforpl\377' > %t -RUN: printf '\1\0\0\0\0\0\0\0' >> %t +RUN: printf '\2\0\0\0\0\0\0\0' >> %t RUN: printf '\2\0\0\0\0\0\0\0' >> %t RUN: printf '\3\0\0\0\0\0\0\0' >> %t RUN: printf '\6\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\1\0\0\0\0' >> %t RUN: printf '\0\0\0\2\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\3\0\0\0' >> %t RUN: printf '\1\0\0\0' >> %t RUN: printf '\1\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\2' >> %t RUN: printf '\0\0\0\1' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\3\0\0\0' >> %t RUN: printf '\2\0\0\0' >> %t RUN: printf '\02\0\0\0\0\0\0\0' >> %t RUN: printf '\03\0\0\2' >> %t RUN: printf '\10\0\0\1' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\023\0\0\0\0\0\0\0' >> %t RUN: printf '\067\0\0\0\0\0\0\0' >> %t RUN: printf '\101\0\0\0\0\0\0\0' >> %t -RUN: printf 'foobar' >> %t +RUN: printf 'foobar\0\0' >> %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s diff --git a/test/tools/llvm-profdata/raw-64-bits-be.test b/test/tools/llvm-profdata/raw-64-bits-be.test index b97d8b5dac6d..902cedd476ab 100644 --- a/test/tools/llvm-profdata/raw-64-bits-be.test +++ b/test/tools/llvm-profdata/raw-64-bits-be.test @@ -1,27 +1,36 @@ RUN: printf '\377lprofr\201' > %t -RUN: printf '\0\0\0\0\0\0\0\1' >> %t +RUN: printf '\0\0\0\0\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\3' >> %t RUN: printf '\0\0\0\0\0\0\0\6' >> %t RUN: printf '\0\0\0\1\0\4\0\0' >> %t RUN: printf '\0\0\0\2\0\4\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\3' >> %t RUN: printf '\0\0\0\1' >> %t RUN: printf '\0\0\0\0\0\0\0\1' >> %t RUN: printf '\0\0\0\2\0\4\0\0' >> %t RUN: printf '\0\0\0\1\0\4\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\3' >> %t RUN: printf '\0\0\0\2' >> %t RUN: printf '\0\0\0\0\0\0\0\02' >> %t RUN: printf '\0\0\0\2\0\4\0\03' >> %t RUN: printf '\0\0\0\1\0\4\0\10' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\0\0\0\0\0\023' >> %t RUN: printf '\0\0\0\0\0\0\0\067' >> %t RUN: printf '\0\0\0\0\0\0\0\101' >> %t -RUN: printf 'foobar' >> %t +RUN: printf 'foobar\0\0' >> %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s diff --git a/test/tools/llvm-profdata/raw-64-bits-le.test b/test/tools/llvm-profdata/raw-64-bits-le.test index 0e6853811ec4..d2f410a6bb95 100644 --- a/test/tools/llvm-profdata/raw-64-bits-le.test +++ b/test/tools/llvm-profdata/raw-64-bits-le.test @@ -1,27 +1,36 @@ RUN: printf '\201rforpl\377' > %t -RUN: printf '\1\0\0\0\0\0\0\0' >> %t +RUN: printf '\2\0\0\0\0\0\0\0' >> %t RUN: printf '\2\0\0\0\0\0\0\0' >> %t RUN: printf '\3\0\0\0\0\0\0\0' >> %t RUN: printf '\6\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\4\0\1\0\0\0' >> %t RUN: printf '\0\0\4\0\2\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\3\0\0\0' >> %t RUN: printf '\1\0\0\0' >> %t RUN: printf '\1\0\0\0\0\0\0\0' >> %t RUN: printf '\0\0\4\0\2\0\0\0' >> %t RUN: printf '\0\0\4\0\1\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\03\0\0\0' >> %t RUN: printf '\02\0\0\0' >> %t RUN: printf '\02\0\0\0\0\0\0\0' >> %t RUN: printf '\03\0\4\0\2\0\0\0' >> %t RUN: printf '\10\0\4\0\1\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t +RUN: printf '\0\0\0\0\0\0\0\0' >> %t RUN: printf '\023\0\0\0\0\0\0\0' >> %t RUN: printf '\067\0\0\0\0\0\0\0' >> %t RUN: printf '\101\0\0\0\0\0\0\0' >> %t -RUN: printf 'foobar' >> %t +RUN: printf 'foobar\0\0' >> %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s diff --git a/test/tools/llvm-profdata/raw-magic-but-no-header.test b/test/tools/llvm-profdata/raw-magic-but-no-header.test index b2a697042b0a..76894faa183c 100644 --- a/test/tools/llvm-profdata/raw-magic-but-no-header.test +++ b/test/tools/llvm-profdata/raw-magic-but-no-header.test @@ -3,4 +3,4 @@ RUN: not llvm-profdata show %t 2>&1 | FileCheck %s RUN: printf '\377lprofr\201' > %t RUN: not llvm-profdata show %t 2>&1 | FileCheck %s -CHECK: error: {{.+}}: Invalid profile data (file header is corrupt) +CHECK: error: {{.+}}: Invalid instrumentation profile data (file header is corrupt) diff --git a/test/tools/llvm-profdata/raw-two-profiles.test b/test/tools/llvm-profdata/raw-two-profiles.test index be78793215ed..09eb121adf3f 100644 --- a/test/tools/llvm-profdata/raw-two-profiles.test +++ b/test/tools/llvm-profdata/raw-two-profiles.test @@ -1,48 +1,51 @@ RUN: printf '\201rforpl\377' > %t-foo.profraw -RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw +RUN: printf '\2\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\3\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\0\0\4\0\1\0\0\0' >> %t-foo.profraw RUN: printf '\0\0\4\0\2\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\3\0\0\0' >> %t-foo.profraw RUN: printf '\1\0\0\0' >> %t-foo.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\0\0\4\0\2\0\0\0' >> %t-foo.profraw RUN: printf '\0\0\4\0\1\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\023\0\0\0\0\0\0\0' >> %t-foo.profraw -RUN: printf 'foo' >> %t-foo.profraw +RUN: printf 'foo\0\0\0\0\0' >> %t-foo.profraw RUN: printf '\201rforpl\377' > %t-bar.profraw -RUN: printf '\1\0\0\0\0\0\0\0' >> %t-bar.profraw +RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\3\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\3\0\0\0' >> %t-bar.profraw RUN: printf '\2\0\0\0' >> %t-bar.profraw RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw +RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\067\0\0\0\0\0\0\0' >> %t-bar.profraw RUN: printf '\101\0\0\0\0\0\0\0' >> %t-bar.profraw -RUN: printf 'bar' >> %t-bar.profraw - -Versions of the profiles that are padded to eight byte alignment. -RUN: cat %t-foo.profraw > %t-foo-padded.profraw -RUN: printf '\0\0\0\0\0' >> %t-foo-padded.profraw -RUN: cat %t-bar.profraw > %t-bar-padded.profraw -RUN: printf '\0\0\0\0\0' >> %t-bar-padded.profraw - -RUN: cat %t-foo-padded.profraw %t-bar.profraw > %t-pad-between.profraw -RUN: cat %t-foo-padded.profraw %t-bar-padded.profraw > %t-pad.profraw +RUN: printf 'bar\0\0\0\0\0' >> %t-bar.profraw -RUN: llvm-profdata show %t-pad-between.profraw -all-functions -counts | FileCheck %s +RUN: cat %t-foo.profraw %t-bar.profraw > %t-pad.profraw RUN: llvm-profdata show %t-pad.profraw -all-functions -counts | FileCheck %s CHECK: Counters: diff --git a/test/tools/llvm-profdata/sample-profile-basic.test b/test/tools/llvm-profdata/sample-profile-basic.test index 0651c513e965..5116b98f3335 100644 --- a/test/tools/llvm-profdata/sample-profile-basic.test +++ b/test/tools/llvm-profdata/sample-profile-basic.test @@ -3,15 +3,15 @@ Basic tests for sample profiles. 1- Show all functions RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1 SHOW1: Function: main: 184019, 0, 7 sampled lines -SHOW1: line offset: 9, discriminator: 0, number of samples: 2064, calls: _Z3fooi:631 _Z3bari:1471 +SHOW1: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471 SHOW1: Function: _Z3fooi: 7711, 610, 1 sampled lines SHOW1: Function: _Z3bari: 20301, 1437, 1 sampled lines -SHOW1: line offset: 1, discriminator: 0, number of samples: 1437 +SHOW1: 1: 1437 2- Show only bar RUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2 SHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines -SHOW2: line offset: 1, discriminator: 0, number of samples: 1437 +SHOW2: 1: 1437 SHOW2-NOT: Function: main: 184019, 0, 7 sampled lines SHOW2-NOT: Function: _Z3fooi: 7711, 610, 1 sampled lines @@ -28,3 +28,7 @@ RUN: llvm-profdata merge --sample --text %p/Inputs/sample-profile.proftext %t-bi MERGE1: main:368038:0 MERGE1: 9: 4128 _Z3fooi:1262 _Z3bari:2942 MERGE1: _Z3fooi:15422:1220 + +5- Detect invalid text encoding (e.g. instrumentation profile text format). +RUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT +BADTEXT: error: {{.+}}: Unrecognized sample profile encoding format diff --git a/test/tools/llvm-profdata/text-dump.test b/test/tools/llvm-profdata/text-dump.test new file mode 100644 index 000000000000..94a78d9dbac3 --- /dev/null +++ b/test/tools/llvm-profdata/text-dump.test @@ -0,0 +1,21 @@ +Basic tests for testing text dump functions. + +RUN: llvm-profdata show --all-functions -counts --text %p/Inputs/basic.proftext > %t-basic.proftext1 +RUN: llvm-profdata merge -o %t-basic.proftext2 --text %p/Inputs/basic.proftext + +RUN: llvm-profdata merge -binary -o %t-basic.profdata1 %t-basic.proftext1 +RUN: llvm-profdata merge -o %t-basic.profdata2 %t-basic.proftext2 + +RUN: llvm-profdata show --all-functions -counts %t-basic.profdata1 > %t-basic.dump3 +RUN: llvm-profdata show --all-functions -counts %t-basic.profdata2 > %t-basic.dump4 + +RUN: llvm-profdata merge -text -o %t-basic.proftext5 %t-basic.profdata1 +RUN: llvm-profdata merge -text -o %t-basic.proftext6 %t-basic.profdata2 + +RUN: diff %t-basic.dump3 %t-basic.dump4 +RUN: diff %t-basic.proftext5 %t-basic.proftext6 + +RUN: not llvm-profdata merge -gcc -o %t-basic-profdata3 %t-basic.proftext2 2>&1 | FileCheck %s --check-prefix=UNKNOWN +UNKNOWN: Unknown + + diff --git a/test/tools/llvm-profdata/text-format-errors.test b/test/tools/llvm-profdata/text-format-errors.test index 01513e4fcb9e..05de2e38af1f 100644 --- a/test/tools/llvm-profdata/text-format-errors.test +++ b/test/tools/llvm-profdata/text-format-errors.test @@ -1,10 +1,29 @@ +Tests for instrumentation profile bad encoding. + +1- Detect invalid count RUN: not llvm-profdata show %p/Inputs/invalid-count-later.proftext 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER -RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.profdata -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER -INVALID-COUNT-LATER: error: {{.*}}invalid-count-later.proftext: Malformed profile data +RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER +INVALID-COUNT-LATER: error: {{.*}}invalid-count-later.proftext: Malformed instrumentation profile data +2- Detect bad hash RUN: not llvm-profdata show %p/Inputs/bad-hash.proftext 2>&1 | FileCheck %s --check-prefix=BAD-HASH RUN: not llvm-profdata merge %p/Inputs/bad-hash.proftext %p/Inputs/bad-hash.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=BAD-HASH -BAD-HASH: error: {{.*}}bad-hash.proftext: Malformed profile data +BAD-HASH: error: {{.*}}bad-hash.proftext: Malformed instrumentation profile data +3- Detect no counts RUN: not llvm-profdata show %p/Inputs/no-counts.proftext 2>&1 | FileCheck %s --check-prefix=NO-COUNTS -NO-COUNTS: error: {{.*}}no-counts.proftext: Malformed profile data +NO-COUNTS: error: {{.*}}no-counts.proftext: Malformed instrumentation profile data + +4- Detect binary input +RUN: not llvm-profdata show %p/Inputs/text-format-errors.text.bin 2>&1 | FileCheck %s --check-prefix=BINARY +BINARY: error: {{.+}}: Unrecognized instrumentation profile encoding format +BINARY: Perhaps you forgot to use the -sample option? + +5- Detect malformed value profile data +RUN: not llvm-profdata show %p/Inputs/vp-malform.proftext 2>&1 | FileCheck %s --check-prefix=VP +RUN: not llvm-profdata show %p/Inputs/vp-malform2.proftext 2>&1 | FileCheck %s --check-prefix=VP +VP: Malformed instrumentation profile data + +6- Detect truncated value profile data +RUN: not llvm-profdata show %p/Inputs/vp-truncate.proftext 2>&1 | FileCheck %s --check-prefix=VPTRUNC +VPTRUNC: Truncated profile data diff --git a/test/tools/llvm-profdata/value-prof.proftext b/test/tools/llvm-profdata/value-prof.proftext new file mode 100644 index 000000000000..ca2b1f822097 --- /dev/null +++ b/test/tools/llvm-profdata/value-prof.proftext @@ -0,0 +1,57 @@ +# RUN: llvm-profdata show -ic-targets -all-functions %s | FileCheck %s --check-prefix=IC +# RUN: llvm-profdata show -ic-targets -counts -text -all-functions %s | FileCheck %s --check-prefix=ICTEXT +# RUN: llvm-profdata merge -o %t.profdata %s +# RUN: llvm-profdata show -ic-targets -all-functions %t.profdata | FileCheck %s --check-prefix=IC + +foo +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +999000 +359800 + +foo2 +# Func Hash: +10 +# Num Counters: +2 +# Counter Values: +1001000 +360200 + +main +# Func Hash: +16650 +# Num Counters: +4 +# Counter Values: +2 +2000 +2000000 +999000 +# NumValueKinds +1 +# Value Kind IPVK_IndirectCallTarget +0 +# NumSites +3 +# Values for each site +0 +2 +foo:100 +foo2:1000 +1 +foo2:20000 + +#IC: Indirect Call Site Count: 3 +#IC-NEXT: Indirect Target Results: +#IC-NEXT: [ 1, foo, 100 ] +#IC-NEXT: [ 1, foo2, 1000 ] +#IC-NEXT: [ 2, foo2, 20000 ] + +#ICTEXT: foo:100 +#ICTEXT-NEXT: foo2:1000 +#ICTEXT-NEXT: 1 +#ICTEXT-NEXT: foo2:20000 diff --git a/test/tools/llvm-profdata/weight-instr.test b/test/tools/llvm-profdata/weight-instr.test new file mode 100644 index 000000000000..7294cf3b01f0 --- /dev/null +++ b/test/tools/llvm-profdata/weight-instr.test @@ -0,0 +1,69 @@ +Tests for weighted merge of instrumented profiles. + +1- Merge the foo and bar profiles with unity weight and verify the combined output +RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata -weighted-input=1,%p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT +RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=1X_1X_WEIGHT +1X_1X_WEIGHT: Counters: +1X_1X_WEIGHT-NEXT: usage: +1X_1X_WEIGHT-NEXT: Hash: 0x0000000000000000 +1X_1X_WEIGHT-NEXT: Counters: 1 +1X_1X_WEIGHT-NEXT: Function count: 0 +1X_1X_WEIGHT-NEXT: foo: +1X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a +1X_1X_WEIGHT-NEXT: Counters: 3 +1X_1X_WEIGHT-NEXT: Function count: 866988873 +1X_1X_WEIGHT-NEXT: bar: +1X_1X_WEIGHT-NEXT: Hash: 0x000000000000028a +1X_1X_WEIGHT-NEXT: Counters: 3 +1X_1X_WEIGHT-NEXT: Function count: 866988873 +1X_1X_WEIGHT-NEXT: main: +1X_1X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248 +1X_1X_WEIGHT-NEXT: Counters: 60 +1X_1X_WEIGHT-NEXT: Function count: 2 +1X_1X_WEIGHT-NEXT: Functions shown: 4 +1X_1X_WEIGHT-NEXT: Total functions: 4 +1X_1X_WEIGHT-NEXT: Maximum function count: 866988873 +1X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296 + +2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output +RUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata show -instr -all-functions %t | FileCheck %s -check-prefix=3X_5X_WEIGHT +3X_5X_WEIGHT: Counters: +3X_5X_WEIGHT-NEXT: usage: +3X_5X_WEIGHT-NEXT: Hash: 0x0000000000000000 +3X_5X_WEIGHT-NEXT: Counters: 1 +3X_5X_WEIGHT-NEXT: Function count: 0 +3X_5X_WEIGHT-NEXT: foo: +3X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a +3X_5X_WEIGHT-NEXT: Counters: 3 +3X_5X_WEIGHT-NEXT: Function count: 4334944365 +3X_5X_WEIGHT-NEXT: bar: +3X_5X_WEIGHT-NEXT: Hash: 0x000000000000028a +3X_5X_WEIGHT-NEXT: Counters: 3 +3X_5X_WEIGHT-NEXT: Function count: 2600966619 +3X_5X_WEIGHT-NEXT: main: +3X_5X_WEIGHT-NEXT: Hash: 0x7d31c47ea98f8248 +3X_5X_WEIGHT-NEXT: Counters: 60 +3X_5X_WEIGHT-NEXT: Function count: 8 +3X_5X_WEIGHT-NEXT: Functions shown: 4 +3X_5X_WEIGHT-NEXT: Total functions: 4 +3X_5X_WEIGHT-NEXT: Maximum function count: 4334944365 +3X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480 + +3- Bad merge: invalid weight +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=-5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +INVALID_WEIGHT: error: Input weight must be a positive integer. + +4- Bad merge: input path does not exist +RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/does-not-exist.profdata -weighted-input=2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_INPUT +INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: {{[Nn]}}o such file or directory + +5- No inputs +RUN: not llvm-profdata merge -instr -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT +NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help diff --git a/test/tools/llvm-profdata/weight-sample.test b/test/tools/llvm-profdata/weight-sample.test new file mode 100644 index 000000000000..7b22c5f88f1f --- /dev/null +++ b/test/tools/llvm-profdata/weight-sample.test @@ -0,0 +1,56 @@ +Tests for weighted merge of sample profiles. + +1- Merge the foo and bar profiles with unity weight and verify the combined output +RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext -weighted-input=1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT +RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT +1X_1X_WEIGHT: foo:1763288:35327 +1X_1X_WEIGHT-NEXT: 7: 35327 +1X_1X_WEIGHT-NEXT: 8: 35327 +1X_1X_WEIGHT-NEXT: 9: 6930 +1X_1X_WEIGHT-NEXT: 10: 29341 +1X_1X_WEIGHT-NEXT: 11: 11906 +1X_1X_WEIGHT-NEXT: 13: 18185 foo:19531 +1X_1X_WEIGHT-NEXT: 15: 36458 +1X_1X_WEIGHT-NEXT: bar:1772037:35370 +1X_1X_WEIGHT-NEXT: 17: 35370 +1X_1X_WEIGHT-NEXT: 18: 35370 +1X_1X_WEIGHT-NEXT: 19: 7005 +1X_1X_WEIGHT-NEXT: 20: 29407 +1X_1X_WEIGHT-NEXT: 21: 12170 +1X_1X_WEIGHT-NEXT: 23: 18150 bar:19829 +1X_1X_WEIGHT-NEXT: 25: 36666 + +2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output +RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT +3X_5X_WEIGHT: foo:8816440:176635 +3X_5X_WEIGHT-NEXT: 7: 176635 +3X_5X_WEIGHT-NEXT: 8: 176635 +3X_5X_WEIGHT-NEXT: 9: 34650 +3X_5X_WEIGHT-NEXT: 10: 146705 +3X_5X_WEIGHT-NEXT: 11: 59530 +3X_5X_WEIGHT-NEXT: 13: 90925 foo:97655 +3X_5X_WEIGHT-NEXT: 15: 182290 +3X_5X_WEIGHT-NEXT: bar:5316111:106110 +3X_5X_WEIGHT-NEXT: 17: 106110 +3X_5X_WEIGHT-NEXT: 18: 106110 +3X_5X_WEIGHT-NEXT: 19: 21015 +3X_5X_WEIGHT-NEXT: 20: 88221 +3X_5X_WEIGHT-NEXT: 21: 36510 +3X_5X_WEIGHT-NEXT: 23: 54450 bar:59487 +3X_5X_WEIGHT-NEXT: 25: 109998 + +3- Bad merge: invalid weight +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=-5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +INVALID_WEIGHT: error: Input weight must be a positive integer. + +4- Bad merge: input path does not exist +RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/does-not-exist.proftext -weighted-input=2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_INPUT +INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.proftext: {{[Nn]}}o such file or directory + +5- No inputs +RUN: not llvm-profdata merge -sample -o %t.out 2>&1 | FileCheck %s -check-prefix=NO_INPUT +NO_INPUT: {{.*}}: No input files specified. See llvm-profdata{{(\.EXE|\.exe)?}} merge -help diff --git a/test/tools/llvm-readobj/ARM/attribute-4.s b/test/tools/llvm-readobj/ARM/attribute-4.s index dd0a4a6d6a73..2c27785410ed 100644 --- a/test/tools/llvm-readobj/ARM/attribute-4.s +++ b/test/tools/llvm-readobj/ARM/attribute-4.s @@ -15,6 +15,13 @@ @CHECK-OBJ-NEXT: TagName: FP_arch @CHECK-OBJ-NEXT: Description: VFPv3-D16 +.eabi_attribute Tag_Advanced_SIMD_arch, 4 +@CHECK: .eabi_attribute 12, 4 +@CHECK-OBJ: Tag: 12 +@CHECK-OBJ-NEXT: Value: 4 +@CHECK-OBJ-NEXT: TagName: Advanced_SIMD_arch +@CHECK-OBJ-NEXT: Description: ARMv8.1-a NEON + .eabi_attribute Tag_PCS_config, 4 @CHECK: .eabi_attribute 13, 4 @CHECK-OBJ: Tag: 13 diff --git a/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-i386 b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-i386 Binary files differnew file mode 100644 index 000000000000..c222a899ba71 --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-i386 diff --git a/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc Binary files differnew file mode 100644 index 000000000000..fd337f343e00 --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc diff --git a/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc64 b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc64 Binary files differnew file mode 100644 index 000000000000..25ce5c71b38b --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-ppc64 diff --git a/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-x86_64 b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-x86_64 Binary files differnew file mode 100644 index 000000000000..612e7b2112ff --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/gnuhash.so.elf-x86_64 diff --git a/test/tools/llvm-readobj/Inputs/mips-rld-map-rel.elf-mipsel b/test/tools/llvm-readobj/Inputs/mips-rld-map-rel.elf-mipsel Binary files differnew file mode 100755 index 000000000000..a8e396c2ec36 --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/mips-rld-map-rel.elf-mipsel diff --git a/test/tools/llvm-readobj/Inputs/trivial.elf-amdhsa-kaveri b/test/tools/llvm-readobj/Inputs/trivial.elf-amdhsa-kaveri Binary files differnew file mode 100755 index 000000000000..9566ed5c0f14 --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/trivial.elf-amdhsa-kaveri diff --git a/test/tools/llvm-readobj/Inputs/verdef.elf-x86-64 b/test/tools/llvm-readobj/Inputs/verdef.elf-x86-64 Binary files differnew file mode 100755 index 000000000000..4b907694e800 --- /dev/null +++ b/test/tools/llvm-readobj/Inputs/verdef.elf-x86-64 diff --git a/test/tools/llvm-readobj/amdgpu-elf-defs.test b/test/tools/llvm-readobj/amdgpu-elf-defs.test new file mode 100644 index 000000000000..9a576e8158f9 --- /dev/null +++ b/test/tools/llvm-readobj/amdgpu-elf-defs.test @@ -0,0 +1,28 @@ +RUN: llvm-readobj -program-headers -sections -symbols -file-headers \ +RUN: %p/Inputs/trivial.elf-amdhsa-kaveri | FileCheck %s + +CHECK: ElfHeader { +CHECK: Ident { +CHECK: Class: 64-bit (0x2) +CHECK: DataEncoding: LittleEndian (0x1) +CHECK: Machine: EM_AMDGPU (0xE0) + + +CHECK: Section { +CHECK: Name: .text +CHECK: Type: SHT_PROGBITS (0x1) +CHECK: Flags [ (0xC00007 +CHECK: SHF_ALLOC (0x2) +CHECK: SHF_AMDGPU_HSA_AGENT (0x800000) +CHECK: SHF_AMDGPU_HSA_CODE (0x400000) +CHECK: SHF_EXECINSTR (0x4) +CHECK: SHF_WRITE (0x1) + +CHECK: Symbol { +CHECK: Name: hello_world +CHECK: Value: 0x0 +CHECK: Binding: Local (0x0) +CHECK: Type: AMDGPU_HSA_KERNEL (0xA) + +CHECK: ProgramHeader { +CHECK: Type: PT_AMDGPU_HSA_LOAD_CODE_AGENT (0x60000003) diff --git a/test/tools/llvm-readobj/basic.test b/test/tools/llvm-readobj/basic.test new file mode 100644 index 000000000000..fc6349bcfbf4 --- /dev/null +++ b/test/tools/llvm-readobj/basic.test @@ -0,0 +1,2 @@ +RUN: not llvm-readobj %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s +ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory diff --git a/test/tools/llvm-readobj/codeview-linetables.test b/test/tools/llvm-readobj/codeview-linetables.test index d124e6e2d454..880b6d52f095 100644 --- a/test/tools/llvm-readobj/codeview-linetables.test +++ b/test/tools/llvm-readobj/codeview-linetables.test @@ -50,7 +50,7 @@ MFUN32: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF2 MFUN32-NEXT: PayloadSize: 0x30 -MFUN32: FunctionName: _x +MFUN32: LinkageName: _x MFUN32-NEXT: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF5 @@ -69,7 +69,7 @@ MFUN32: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF2 MFUN32-NEXT: PayloadSize: 0x30 -MFUN32: FunctionName: _y +MFUN32: LinkageName: _y MFUN32-NEXT: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF5 @@ -88,7 +88,7 @@ MFUN32: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF2 MFUN32-NEXT: PayloadSize: 0x40 -MFUN32: FunctionName: _f +MFUN32: LinkageName: _f MFUN32-NEXT: ] MFUN32-NEXT: Subsection [ MFUN32-NEXT: Type: 0xF4 @@ -103,7 +103,7 @@ MFUN32-NEXT: Type: 0xF1 MFUN32-NEXT: PayloadSize: 0x8 MFUN32: ] MFUN32-NEXT: FunctionLineTable [ -MFUN32-NEXT: FunctionName: _x +MFUN32-NEXT: LinkageName: _x MFUN32-NEXT: Flags: 0x0 MFUN32-NEXT: CodeSize: 0xA MFUN32-NEXT: FilenameSegment [ @@ -114,7 +114,7 @@ MFUN32-NEXT: +0x8: 5 MFUN32-NEXT: ] MFUN32-NEXT: ] MFUN32-NEXT: FunctionLineTable [ -MFUN32-NEXT: FunctionName: _y +MFUN32-NEXT: LinkageName: _y MFUN32-NEXT: Flags: 0x0 MFUN32-NEXT: CodeSize: 0xA MFUN32-NEXT: FilenameSegment [ @@ -125,7 +125,7 @@ MFUN32-NEXT: +0x8: 9 MFUN32-NEXT: ] MFUN32-NEXT: ] MFUN32-NEXT: FunctionLineTable [ -MFUN32-NEXT: FunctionName: _f +MFUN32-NEXT: LinkageName: _f MFUN32-NEXT: Flags: 0x0 MFUN32-NEXT: CodeSize: 0x14 MFUN32-NEXT: FilenameSegment [ @@ -158,7 +158,7 @@ MFUN64: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF2 MFUN64-NEXT: PayloadSize: 0x30 -MFUN64: FunctionName: x +MFUN64: LinkageName: x MFUN64-NEXT: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF1 @@ -173,7 +173,7 @@ MFUN64: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF2 MFUN64-NEXT: PayloadSize: 0x30 -MFUN64: FunctionName: y +MFUN64: LinkageName: y MFUN64-NEXT: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF1 @@ -188,7 +188,7 @@ MFUN64: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF2 MFUN64-NEXT: PayloadSize: 0x40 -MFUN64: FunctionName: f +MFUN64: LinkageName: f MFUN64-NEXT: ] MFUN64-NEXT: Subsection [ MFUN64-NEXT: Type: 0xF4 @@ -203,7 +203,7 @@ MFUN64-NEXT: Type: 0xF1 MFUN64-NEXT: PayloadSize: 0x8 MFUN64: ] MFUN64-NEXT: FunctionLineTable [ -MFUN64-NEXT: FunctionName: x +MFUN64-NEXT: LinkageName: x MFUN64-NEXT: Flags: 0x0 MFUN64-NEXT: CodeSize: 0xE MFUN64-NEXT: FilenameSegment [ @@ -214,7 +214,7 @@ MFUN64-NEXT: +0x9: 5 MFUN64-NEXT: ] MFUN64-NEXT: ] MFUN64-NEXT: FunctionLineTable [ -MFUN64-NEXT: FunctionName: y +MFUN64-NEXT: LinkageName: y MFUN64-NEXT: Flags: 0x0 MFUN64-NEXT: CodeSize: 0xE MFUN64-NEXT: FilenameSegment [ @@ -225,7 +225,7 @@ MFUN64-NEXT: +0x9: 9 MFUN64-NEXT: ] MFUN64-NEXT: ] MFUN64-NEXT: FunctionLineTable [ -MFUN64-NEXT: FunctionName: f +MFUN64-NEXT: LinkageName: f MFUN64-NEXT: Flags: 0x0 MFUN64-NEXT: CodeSize: 0x18 MFUN64-NEXT: FilenameSegment [ @@ -286,7 +286,7 @@ MFILE32: ] MFILE32-NEXT: Subsection [ MFILE32-NEXT: Type: 0xF2 MFILE32-NEXT: PayloadSize: 0x64 -MFILE32: FunctionName: _f +MFILE32: LinkageName: _f MFILE32-NEXT: ] MFILE32-NEXT: Subsection [ MFILE32-NEXT: Type: 0xF4 @@ -301,7 +301,7 @@ MFILE32-NEXT: Type: 0xF1 MFILE32-NEXT: PayloadSize: 0x8 MFILE32: ] MFILE32-NEXT: FunctionLineTable [ -MFILE32-NEXT: FunctionName: _f +MFILE32-NEXT: LinkageName: _f MFILE32-NEXT: Flags: 0x0 MFILE32-NEXT: CodeSize: 0x14 MFILE32-NEXT: FilenameSegment [ @@ -343,7 +343,7 @@ MFILE64: ] MFILE64-NEXT: Subsection [ MFILE64-NEXT: Type: 0xF2 MFILE64-NEXT: PayloadSize: 0x64 -MFILE64: FunctionName: f +MFILE64: LinkageName: f MFILE64-NEXT: ] MFILE64-NEXT: Subsection [ MFILE64-NEXT: Type: 0xF4 @@ -358,7 +358,7 @@ MFILE64-NEXT: Type: 0xF1 MFILE64-NEXT: PayloadSize: 0x8 MFILE64: ] MFILE64-NEXT: FunctionLineTable [ -MFILE64-NEXT: FunctionName: f +MFILE64-NEXT: LinkageName: f MFILE64-NEXT: Flags: 0x0 MFILE64-NEXT: CodeSize: 0x18 MFILE64-NEXT: FilenameSegment [ @@ -406,7 +406,7 @@ MCOMDAT-NEXT: Section: ?f@@YAHXZ MCOMDAT-NEXT: CodeSize: 0x7 MCOMDAT-NEXT: } MCOMDAT: FunctionLineTable [ -MCOMDAT-NEXT: FunctionName: ?f@@YAHXZ +MCOMDAT-NEXT: LinkageName: ?f@@YAHXZ MCOMDAT-NEXT: Flags: 0x0 MCOMDAT-NEXT: CodeSize: 0x7 MCOMDAT-NEXT: FilenameSegment [ @@ -422,7 +422,7 @@ MCOMDAT-NEXT: Section: ?g@@YAHXZ MCOMDAT-NEXT: CodeSize: 0x7 MCOMDAT-NEXT: } MCOMDAT: FunctionLineTable [ -MCOMDAT-NEXT: FunctionName: ?g@@YAHXZ +MCOMDAT-NEXT: LinkageName: ?g@@YAHXZ MCOMDAT-NEXT: Flags: 0x0 MCOMDAT-NEXT: CodeSize: 0x7 MCOMDAT-NEXT: FilenameSegment [ diff --git a/test/tools/llvm-readobj/elf-gnuhash.test b/test/tools/llvm-readobj/elf-gnuhash.test new file mode 100644 index 000000000000..8642a4dc9d7b --- /dev/null +++ b/test/tools/llvm-readobj/elf-gnuhash.test @@ -0,0 +1,63 @@ +// Check dumping of the GNU Hash section +// The input was generated using the following: +// $ llvm-mc -filetype=obj -triple=i386-pc-linux -o example-i386.o example.s +// $ llvm-mc -filetype=obj -triple=x86_64-pc-linux -o example-x86_64.o example.s +// $ llvm-mc -filetype=obj -triple=powerpc-pc-linux -o example-ppc.o example.s +// $ llvm-mc -filetype=obj -triple=powerpc64-pc-linux -o example-ppc64.o example.s +// $ ld -shared -m elf_i386 -hash-style=gnu -o gnuhash.so.elf-i386 example-i386.o +// $ ld -shared -m elf_x86_64 -hash-style=gnu -o gnuhash.so.elf-x86_64 example-x86_64.o +// $ ld -shared -m elf32ppc -hash-style=gnu -o gnuhash.so.elf-ppc example-ppc.o +// $ ld -shared -m elf64ppc -hash-style=gnu -o gnuhash.so.elf-ppc64 example-ppc64.o +// $ cat example.s +// .globl foo +// foo: + +RUN: llvm-readobj -gnu-hash-table %p/Inputs/gnuhash.so.elf-i386 | FileCheck %s -check-prefix I386 +RUN: llvm-readobj -gnu-hash-table %p/Inputs/gnuhash.so.elf-x86_64 | FileCheck %s -check-prefix X86_64 +RUN: llvm-readobj -gnu-hash-table %p/Inputs/gnuhash.so.elf-ppc | FileCheck %s -check-prefix PPC +RUN: llvm-readobj -gnu-hash-table %p/Inputs/gnuhash.so.elf-ppc64 | FileCheck %s -check-prefix PPC64 + +I386: Arch: i386 +I386: GnuHashTable { +I386-NEXT: Num Buckets: 3 +I386-NEXT: First Hashed Symbol Index: 1 +I386-NEXT: Num Mask Words: 1 +I386-NEXT: Shift Count: 5 +I386-NEXT: Bloom Filter: [0x39004608] +I386-NEXT: Buckets: [1, 4, 0] +I386-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9] +I386-NEXT: } + +X86_64: Arch: x86_64 +X86_64: GnuHashTable { +X86_64-NEXT: Num Buckets: 3 +X86_64-NEXT: First Hashed Symbol Index: 1 +X86_64-NEXT: Num Mask Words: 1 +X86_64-NEXT: Shift Count: 6 +X86_64-NEXT: Bloom Filter: [0x800000001204288] +X86_64-NEXT: Buckets: [1, 4, 0] +X86_64-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9] +X86_64-NEXT: } + +PPC: Arch: powerpc +PPC: GnuHashTable { +PPC-NEXT: Num Buckets: 3 +PPC-NEXT: First Hashed Symbol Index: 1 +PPC-NEXT: Num Mask Words: 1 +PPC-NEXT: Shift Count: 5 +PPC-NEXT: Bloom Filter: [0x3D00460A] +PPC-NEXT: Buckets: [1, 5, 0] +PPC-NEXT: Values: [0xEEBEC3A, 0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9] +PPC-NEXT: } + +PPC64: Arch: powerpc64 +PPC64: GnuHashTable { +PPC64-NEXT: Num Buckets: 3 +PPC64-NEXT: First Hashed Symbol Index: 1 +PPC64-NEXT: Num Mask Words: 1 +PPC64-NEXT: Shift Count: 6 +PPC64-NEXT: Bloom Filter: [0x800000001204288] +PPC64-NEXT: Buckets: [1, 4, 0] +PPC64-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9] +PPC64-NEXT: } + diff --git a/test/tools/llvm-readobj/elf-versioninfo.test b/test/tools/llvm-readobj/elf-versioninfo.test new file mode 100644 index 000000000000..e8113e4b2fed --- /dev/null +++ b/test/tools/llvm-readobj/elf-versioninfo.test @@ -0,0 +1,81 @@ +// Test that llvm-readobj dumps version info tags correctly. + +RUN: llvm-readobj -dynamic-table -V %p/Inputs/verdef.elf-x86-64 | FileCheck %s + +CHECK: 0x000000006FFFFFF0 VERSYM 0x24C +CHECK: 0x000000006FFFFFFC VERDEF 0x25C +CHECK: 0x000000006FFFFFFD VERDEFNUM 3 + +CHECK: Version symbols { +CHECK-NEXT: Section Name: .gnu.version (20) +CHECK-NEXT: Address: 0x24C +CHECK-NEXT: Offset: 0x24C +CHECK-NEXT: Link: 1 +CHECK-NEXT: Symbols [ +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 0 +CHECK-NEXT: Name: @ +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 1 +CHECK-NEXT: Name: _end@ +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 1 +CHECK-NEXT: Name: _edata@ +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 3 +CHECK-NEXT: Name: goo@@VERSION2 +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 1 +CHECK-NEXT: Name: __bss_start@ +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 2 +CHECK-NEXT: Name: foo@@VERSION1 +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 2 +CHECK-NEXT: Name: VERSION1@@VERSION1 +CHECK-NEXT: } +CHECK-NEXT: Symbol { +CHECK-NEXT: Version: 3 +CHECK-NEXT: Name: VERSION2@@VERSION2 +CHECK-NEXT: } +CHECK-NEXT: ] +CHECK-NEXT: } + +CHECK: Version definition { +CHECK-NEXT: Section Name: .gnu.version_d (70) +CHECK-NEXT: Address: 0x25C +CHECK-NEXT: Offset: 0x25C +CHECK-NEXT: Link: 2 +CHECK-NEXT: Entries [ +CHECK-NEXT: Entry { +CHECK-NEXT: Offset: 0x0 +CHECK-NEXT: Rev: 1 +CHECK-NEXT: Flags: 1 +CHECK-NEXT: Index: 1 +CHECK-NEXT: Cnt: 1 +CHECK-NEXT: Name: blah +CHECK-NEXT: } +CHECK-NEXT: Entry { +CHECK-NEXT: Offset: 0x1C +CHECK-NEXT: Rev: 1 +CHECK-NEXT: Flags: 0 +CHECK-NEXT: Index: 2 +CHECK-NEXT: Cnt: 1 +CHECK-NEXT: Name: VERSION1 +CHECK-NEXT: } +CHECK-NEXT: Entry { +CHECK-NEXT: Offset: 0x38 +CHECK-NEXT: Rev: 1 +CHECK-NEXT: Flags: 0 +CHECK-NEXT: Index: 3 +CHECK-NEXT: Cnt: 2 +CHECK-NEXT: Name: VERSION2 +CHECK-NEXT: } +CHECK-NEXT: ] +CHECK-NEXT: } diff --git a/test/tools/llvm-readobj/file-headers.test b/test/tools/llvm-readobj/file-headers.test index fd030ef0b56e..2d67089d6118 100644 --- a/test/tools/llvm-readobj/file-headers.test +++ b/test/tools/llvm-readobj/file-headers.test @@ -330,16 +330,8 @@ COFF-UNKNOWN-NEXT: Characteristics [ (0x0) COFF-UNKNOWN-NEXT: ] COFF-UNKNOWN-NEXT: } -COFF-IMPORTLIB: Format: COFF-<unknown arch> -COFF-IMPORTLIB-NEXT: Arch: unknown -COFF-IMPORTLIB-NEXT: AddressSize: 32bit -COFF-IMPORTLIB-NEXT: ImageFileHeader { -COFF-IMPORTLIB-NEXT: Machine: IMAGE_FILE_MACHINE_UNKNOWN (0x0) -COFF-IMPORTLIB-NEXT: SectionCount: 0 -COFF-IMPORTLIB-NEXT: TimeDateStamp: 1970-09-09 19:52:32 (0x14C0000) -COFF-IMPORTLIB-NEXT: PointerToSymbolTable: 0x0 -COFF-IMPORTLIB-NEXT: SymbolCount: 0 -COFF-IMPORTLIB-NEXT: OptionalHeaderSize: 0 -COFF-IMPORTLIB-NEXT: Characteristics [ (0x0) -COFF-IMPORTLIB-NEXT: ] -COFF-IMPORTLIB-NEXT: } +COFF-IMPORTLIB: Format: COFF-import-file +COFF-IMPORTLIB-NEXT: Type: code +COFF-IMPORTLIB-NEXT: Name type: noprefix +COFF-IMPORTLIB-NEXT: Symbol: __imp__func +COFF-IMPORTLIB-NEXT: Symbol: _func diff --git a/test/tools/llvm-readobj/mips-rld-map-rel.test b/test/tools/llvm-readobj/mips-rld-map-rel.test new file mode 100644 index 000000000000..adde78784d63 --- /dev/null +++ b/test/tools/llvm-readobj/mips-rld-map-rel.test @@ -0,0 +1,24 @@ +# Check DT_MIPS_RLD_MAP_REL .dynamic section tag reading + +RUN: llvm-readobj -dynamic-table %p/Inputs/mips-rld-map-rel.elf-mipsel | \ +RUN: FileCheck %s + +CHECK: DynamicSection [ (16 entries) +CHECK-NEXT: Tag Type Name/Value +CHECK-NEXT: 0x00000004 HASH 0x220 +CHECK-NEXT: 0x00000005 STRTAB 0x2FC +CHECK-NEXT: 0x00000006 SYMTAB 0x25C +CHECK-NEXT: 0x0000000A STRSZ 72 (bytes) +CHECK-NEXT: 0x0000000B SYMENT 16 (bytes) +CHECK-NEXT: 0x70000035 MIPS_RLD_MAP_REL 0x101E0 +CHECK-NEXT: 0x00000015 DEBUG 0x0 +CHECK-NEXT: 0x00000003 PLTGOT 0x10390 +CHECK-NEXT: 0x70000001 MIPS_RLD_VERSION 1 +CHECK-NEXT: 0x70000005 MIPS_FLAGS NOTPOT +CHECK-NEXT: 0x70000006 MIPS_BASE_ADDRESS 0x0 +CHECK-NEXT: 0x7000000A MIPS_LOCAL_GOTNO 2 +CHECK-NEXT: 0x70000011 MIPS_SYMTABNO 10 +CHECK-NEXT: 0x70000012 MIPS_UNREFEXTNO 15 +CHECK-NEXT: 0x70000013 MIPS_GOTSYM 0xA +CHECK-NEXT: 0x00000000 NULL 0x0 +CHECK-NEXT: ] diff --git a/test/tools/llvm-readobj/sections-ext.test b/test/tools/llvm-readobj/sections-ext.test index 19b7aa0516d1..70ae0f22a0e4 100644 --- a/test/tools/llvm-readobj/sections-ext.test +++ b/test/tools/llvm-readobj/sections-ext.test @@ -223,6 +223,7 @@ MACHO-X86-64-NEXT: SomeInstructions (0x4) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: Relocations [ MACHO-X86-64-NEXT: 0xE 1 2 1 X86_64_RELOC_BRANCH 0 _SomeOtherFunction MACHO-X86-64-NEXT: 0x9 1 2 1 X86_64_RELOC_BRANCH 0 _puts @@ -260,6 +261,7 @@ MACHO-X86-64-NEXT: Attributes [ (0x0) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: Relocations [ MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Symbols [ @@ -514,6 +516,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x24 @@ -587,6 +590,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x20 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x14 @@ -639,6 +643,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Symbols [ @@ -672,6 +677,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x1 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Symbols [ @@ -695,6 +701,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x2 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x0 diff --git a/test/tools/llvm-readobj/sections.test b/test/tools/llvm-readobj/sections.test index fe734d77e34b..54654e7070ef 100644 --- a/test/tools/llvm-readobj/sections.test +++ b/test/tools/llvm-readobj/sections.test @@ -172,6 +172,7 @@ MACHO-X86-64-NEXT: SomeInstructions (0x4) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: } MACHO-X86-64-NEXT: Section { MACHO-X86-64-NEXT: Index: 1 @@ -188,6 +189,7 @@ MACHO-X86-64-NEXT: Attributes [ (0x0) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: } MACHO-X86-64-NEXT:] @@ -296,6 +298,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 1 @@ -314,6 +317,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x20 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 2 @@ -330,6 +334,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 3 @@ -346,6 +351,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x1 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 4 @@ -362,6 +368,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x2 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: ] diff --git a/test/tools/llvm-size/basic.test b/test/tools/llvm-size/basic.test new file mode 100644 index 000000000000..8b2d66eef3ce --- /dev/null +++ b/test/tools/llvm-size/basic.test @@ -0,0 +1,2 @@ +RUN: llvm-size %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s +ENOENT: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: {{.*}}.blah: {{[Nn]}}o such file or directory diff --git a/test/tools/llvm-split/alias.ll b/test/tools/llvm-split/alias.ll new file mode 100644 index 000000000000..18e0e7f12d69 --- /dev/null +++ b/test/tools/llvm-split/alias.ll @@ -0,0 +1,19 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; CHECK0-DAG: @afoo = alias [2 x i8*], [2 x i8*]* @foo +; CHECK1-DAG: @afoo = external global [2 x i8*] +@afoo = alias [2 x i8*], [2 x i8*]* @foo + +; CHECK0-DAG: declare void @abar() +; CHECK1-DAG: @abar = alias void (), void ()* @bar +@abar = alias void (), void ()* @bar + +@foo = global [2 x i8*] [i8* bitcast (void ()* @bar to i8*), i8* bitcast (void ()* @abar to i8*)] + +define void @bar() { + store [2 x i8*] zeroinitializer, [2 x i8*]* @foo + store [2 x i8*] zeroinitializer, [2 x i8*]* @afoo + ret void +} diff --git a/test/tools/llvm-split/comdat.ll b/test/tools/llvm-split/comdat.ll new file mode 100644 index 000000000000..45faf4bfe26e --- /dev/null +++ b/test/tools/llvm-split/comdat.ll @@ -0,0 +1,19 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +$foo = comdat any + +; CHECK0: define void @foo() +; CHECK1: declare void @foo() +define void @foo() comdat { + call void @bar() + ret void +} + +; CHECK0: define void @bar() +; CHECK1: declare void @bar() +define void @bar() comdat($foo) { + call void @foo() + ret void +} diff --git a/test/tools/llvm-split/function.ll b/test/tools/llvm-split/function.ll new file mode 100644 index 000000000000..37272dbbcee2 --- /dev/null +++ b/test/tools/llvm-split/function.ll @@ -0,0 +1,17 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; CHECK0: define void @foo() +; CHECK1: declare void @foo() +define void @foo() { + call void @bar() + ret void +} + +; CHECK0: declare void @bar() +; CHECK1: define void @bar() +define void @bar() { + call void @foo() + ret void +} diff --git a/test/tools/llvm-split/global.ll b/test/tools/llvm-split/global.ll new file mode 100644 index 000000000000..6d2425691e10 --- /dev/null +++ b/test/tools/llvm-split/global.ll @@ -0,0 +1,11 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; CHECK0: @foo = global i8* bitcast +; CHECK1: @foo = external global i8* +@foo = global i8* bitcast (i8** @bar to i8*) + +; CHECK0: @bar = external global i8* +; CHECK1: @bar = global i8* bitcast +@bar = global i8* bitcast (i8** @foo to i8*) diff --git a/test/tools/llvm-split/internal.ll b/test/tools/llvm-split/internal.ll new file mode 100644 index 000000000000..ce4272c5f0dd --- /dev/null +++ b/test/tools/llvm-split/internal.ll @@ -0,0 +1,17 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; CHECK0: define hidden void @foo() +; CHECK1: declare hidden void @foo() +define internal void @foo() { + call void @bar() + ret void +} + +; CHECK0: declare void @bar() +; CHECK1: define void @bar() +define void @bar() { + call void @foo() + ret void +} diff --git a/test/tools/llvm-split/unnamed.ll b/test/tools/llvm-split/unnamed.ll new file mode 100644 index 000000000000..fd24b4ca92bb --- /dev/null +++ b/test/tools/llvm-split/unnamed.ll @@ -0,0 +1,31 @@ +; RUN: llvm-split -o %t %s +; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s +; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s + +; CHECK0: declare hidden void @__llvmsplit_unnamed() +; CHECK1: define hidden void @__llvmsplit_unnamed() +define internal void @0() { + ; CHECK1: call void @foo() + call void @foo() + ret void +} + +; CHECK0: declare hidden void @__llvmsplit_unnamed.1() +; CHECK1: define hidden void @__llvmsplit_unnamed.1() +define internal void @1() { + ; CHECK1: call void @foo() + ; CHECK1: call void @foo() + call void @foo() + call void @foo() + ret void +} + +; CHECK0: define void @foo() +; CHECK1: declare void @foo() +define void @foo() { + ; CHECK0: call void @__llvmsplit_unnamed.1() + ; CHECK0: call void @__llvmsplit_unnamed() + call void @1() + call void @0() + ret void +} diff --git a/test/tools/llvm-symbolizer/Inputs/addr.exe b/test/tools/llvm-symbolizer/Inputs/addr.exe Binary files differnew file mode 100755 index 000000000000..38d88b65741e --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/addr.exe diff --git a/test/tools/llvm-symbolizer/Inputs/addr.inp b/test/tools/llvm-symbolizer/Inputs/addr.inp new file mode 100644 index 000000000000..4de096479dae --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/addr.inp @@ -0,0 +1 @@ +0x40054d diff --git a/test/tools/llvm-symbolizer/Inputs/coff-dwarf.cpp b/test/tools/llvm-symbolizer/Inputs/coff-dwarf.cpp new file mode 100644 index 000000000000..3a832a9fcff2 --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/coff-dwarf.cpp @@ -0,0 +1,19 @@ +// To generate the corresponding EXE, run: +// clang-cl -MD -O2 -gdwarf -c coff-dwarf.cpp && lld-link -debug coff-dwarf.obj + +extern "C" int puts(const char *str); + +void __declspec(noinline) foo() { + puts("foo1"); + puts("foo2"); +} + +// LLVM should inline this into main. +static void bar() { + foo(); +} + +int main() { + bar(); + return 0; +} diff --git a/test/tools/llvm-symbolizer/Inputs/coff-dwarf.exe b/test/tools/llvm-symbolizer/Inputs/coff-dwarf.exe Binary files differnew file mode 100644 index 000000000000..018053b979b9 --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/coff-dwarf.exe diff --git a/test/tools/llvm-symbolizer/Inputs/coff-exports.cpp b/test/tools/llvm-symbolizer/Inputs/coff-exports.cpp new file mode 100644 index 000000000000..23b44b329022 --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/coff-exports.cpp @@ -0,0 +1,20 @@ +// To generate the corresponding EXE, run: +// clang-cl -MD -c coff-exports.cpp && lld-link /MANIFEST:NO coff-exports.obj + +#define EXPORT __declspec(dllexport) + +extern "C" int puts(const char *str); + +EXPORT void __declspec(noinline) foo() { + puts("foo1"); + puts("foo2"); +} + +void bar() { + foo(); +} + +EXPORT int main() { + bar(); + return 0; +} diff --git a/test/tools/llvm-symbolizer/Inputs/coff-exports.exe b/test/tools/llvm-symbolizer/Inputs/coff-exports.exe Binary files differnew file mode 100644 index 000000000000..939205e3f82e --- /dev/null +++ b/test/tools/llvm-symbolizer/Inputs/coff-exports.exe diff --git a/test/tools/llvm-symbolizer/coff-dwarf.test b/test/tools/llvm-symbolizer/coff-dwarf.test new file mode 100644 index 000000000000..043c175a8d3e --- /dev/null +++ b/test/tools/llvm-symbolizer/coff-dwarf.test @@ -0,0 +1,16 @@ +RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ +RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \ +RUN: | FileCheck %s + +This test relies on UnDecorateSymbolName, which is Windows-only. +REQUIRES: system-windows + +ADDR: 0x5009 +ADDR: 0x5038 + +CHECK: foo(void) +CHECK: coff-dwarf.cpp:7 +CHECK: bar(void) +CHECK: coff-dwarf.cpp:13 +CHECK: main +CHECK: coff-dwarf.cpp:17 diff --git a/test/tools/llvm-symbolizer/coff-exports.test b/test/tools/llvm-symbolizer/coff-exports.test new file mode 100644 index 000000000000..cad1935a03f9 --- /dev/null +++ b/test/tools/llvm-symbolizer/coff-exports.test @@ -0,0 +1,20 @@ +RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ +RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \ +RUN: | FileCheck %s + +This test relies on UnDecorateSymbolName, which is Windows-only. +REQUIRES: system-windows + +ADDR: 0x500A +ADDR: 0x5038 +ADDR: 0x504B + +We get the expected stack trace, except 'foo' appears for the 'bar' frame +because 'bar' isn't in the export table. + +CHECK: foo(void) +CHECK: ??:0:0 +CHECK: foo(void) +CHECK: ??:0:0 +CHECK: main +CHECK: ??:0:0 diff --git a/test/tools/llvm-symbolizer/pdb/Inputs/test.cpp b/test/tools/llvm-symbolizer/pdb/Inputs/test.cpp index f1f98af41907..e317ed33589e 100644 --- a/test/tools/llvm-symbolizer/pdb/Inputs/test.cpp +++ b/test/tools/llvm-symbolizer/pdb/Inputs/test.cpp @@ -16,3 +16,10 @@ int main() { NS::Foo f; f.bar(); } + +extern "C" { +void __cdecl foo_cdecl() {} +void __stdcall foo_stdcall() {} +void __fastcall foo_fastcall() {} +void __vectorcall foo_vectorcall() {} +} diff --git a/test/tools/llvm-symbolizer/pdb/Inputs/test.exe b/test/tools/llvm-symbolizer/pdb/Inputs/test.exe Binary files differindex 80fb34bb6dcb..a4f148e67c2f 100644 --- a/test/tools/llvm-symbolizer/pdb/Inputs/test.exe +++ b/test/tools/llvm-symbolizer/pdb/Inputs/test.exe diff --git a/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input b/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input deleted file mode 100644 index affda60449b2..000000000000 --- a/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input +++ /dev/null @@ -1,4 +0,0 @@ -0x401030 -0x401040 -0x401060 -0x500000 diff --git a/test/tools/llvm-symbolizer/pdb/Inputs/test.pdb b/test/tools/llvm-symbolizer/pdb/Inputs/test.pdb Binary files differindex 974e565e87f4..d26d33a862d8 100644 --- a/test/tools/llvm-symbolizer/pdb/Inputs/test.pdb +++ b/test/tools/llvm-symbolizer/pdb/Inputs/test.pdb diff --git a/test/tools/llvm-symbolizer/pdb/pdb.test b/test/tools/llvm-symbolizer/pdb/pdb.test index b5d0f15fbcb8..fd058fbbee3b 100644 --- a/test/tools/llvm-symbolizer/pdb/pdb.test +++ b/test/tools/llvm-symbolizer/pdb/pdb.test @@ -1,18 +1,45 @@ -RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < "%p/Inputs/test.exe.input" | \
-RUN: FileCheck %s --check-prefix=CHECK
-RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false < \
-RUN: "%p/Inputs/test.exe.input" | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
-
-CHECK: foo(void)
-CHECK-NEXT: test.cpp:10
-CHECK: _main
-CHECK-NEXT: test.cpp:13:0
-CHECK: NS::Foo::bar(void)
-CHECK-NEXT: test.cpp:6:0
-
-CHECK-NO-DEMANGLE: foo
-CHECK-NO-DEMANGLE-NEXT: test.cpp:10
-CHECK-NO-DEMANGLE: _main
-CHECK-LINKAGE-NAME-NEXT: test.cpp:13:0
-CHECK-NO-DEMANGLE: bar
-CHECK-LINKAGE-NAME-NEXT: test.cpp:6:0
+RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ +RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" \ +RUN: | FileCheck %s --check-prefix=CHECK +RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ +RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false \ +RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE + +Subtract ImageBase from all the offsets and run the test again with +--relative-address. + +RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ +RUN: | %python -c 'import sys;print "\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin])' \ +RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \ +RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE + +ADDR: 0x401000 +ADDR: 0x401010 +ADDR: 0x401070 +ADDR: 0x401030 +ADDR: 0x401040 +ADDR: 0x401050 +ADDR: 0x401060 +ADDR: 0x500000 + +CHECK: foo(void) +CHECK-NEXT: test.cpp:10 +CHECK: main +CHECK-NEXT: test.cpp:13:0 +CHECK: NS::Foo::bar(void) +CHECK-NEXT: test.cpp:6:0 +CHECK: {{^foo_cdecl$}} +CHECK: {{^foo_stdcall$}} +CHECK: {{^foo_fastcall$}} +CHECK: {{^foo_vectorcall$}} + +CHECK-NO-DEMANGLE: ?foo@@YAXXZ +CHECK-NO-DEMANGLE-NEXT: test.cpp:10 +CHECK-NO-DEMANGLE: _main +CHECK-NO-DEMANGLE-NEXT: test.cpp:13 +CHECK-NO-DEMANGLE: ?bar@Foo@NS@@QAEXXZ +CHECK-NO-DEMANGLE-NEXT: test.cpp:6 +CHECK-NO-DEMANGLE: _foo_cdecl +CHECK-NO-DEMANGLE: _foo_stdcall@0 +CHECK-NO-DEMANGLE: @foo_fastcall@0 +CHECK-NO-DEMANGLE: foo_vectorcall@@0 diff --git a/test/tools/llvm-symbolizer/sym.test b/test/tools/llvm-symbolizer/sym.test new file mode 100644 index 000000000000..01a6692222e7 --- /dev/null +++ b/test/tools/llvm-symbolizer/sym.test @@ -0,0 +1,30 @@ +#Source: +##include <stdio.h> +#static inline int inctwo (int *a) { +# printf ("%d\n",(*a)++); +# return (*a)++; +#} +#static inline int inc (int *a) { +# printf ("%d\n",inctwo(a)); +# return (*a)++; +#} +# +# +#int main () { +# int x = 1; +# return inc(&x); +#} +# +#Build as : clang -g -O2 addr.c + +RUN: llvm-symbolizer -print-address -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck %s +RUN: llvm-symbolizer -inlining -print-address -pretty-print -obj=%p/Inputs/addr.exe < %p/Inputs/addr.inp | FileCheck --check-prefix="PRETTY" %s + +#CHECK: 0x40054d +#CHECK: main +#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:14:0 +# +#PRETTY: {{[0x]+}}40054d: inctwo at {{[/\]+}}tmp{{[/\]+}}x.c:3:3 +#PRETTY: (inlined by) inc at {{[/\]+}}tmp{{[/\]+}}x.c:7:0 +#PRETTY (inlined by) main at {{[/\]+}}tmp{{[/\]+}}x.c:14:0 + diff --git a/test/tools/lto/opt-level.ll b/test/tools/lto/opt-level.ll index 013a1f408821..7bce0c606c4c 100644 --- a/test/tools/lto/opt-level.ll +++ b/test/tools/lto/opt-level.ll @@ -1,8 +1,9 @@ ; RUN: llvm-as %s -o %t.o -; RUN: env DYLD_LIBRARY_PATH=%llvmshlibdir %ld64 -arch x86_64 -dylib -mllvm -O0 -o %t.dylib %t.o +; RUN: %ld64 -lto_library %llvmshlibdir/libLTO.dylib -arch x86_64 -dylib -mllvm -O0 -o %t.dylib %t.o ; RUN: llvm-nm -no-llvm-bc %t.dylib | FileCheck --check-prefix=CHECK-O0 %s -; RUN: env DYLD_LIBRARY_PATH=%llvmshlibdir %ld64 -arch x86_64 -dylib -mllvm -O2 -o %t.dylib %t.o +; RUN: %ld64 -lto_library %llvmshlibdir/libLTO.dylib -arch x86_64 -dylib -mllvm -O2 -o %t.dylib %t.o ; RUN: llvm-nm -no-llvm-bc %t.dylib | FileCheck --check-prefix=CHECK-O2 %s +; REQUIRES: X86 target triple = "x86_64-apple-macosx10.8.0" diff --git a/test/tools/sancov/Inputs/blacklist.txt b/test/tools/sancov/Inputs/blacklist.txt new file mode 100644 index 000000000000..b782960652bb --- /dev/null +++ b/test/tools/sancov/Inputs/blacklist.txt @@ -0,0 +1 @@ +fun:bar* diff --git a/test/tools/sancov/Inputs/foo.cpp b/test/tools/sancov/Inputs/foo.cpp new file mode 100644 index 000000000000..71b35b32392d --- /dev/null +++ b/test/tools/sancov/Inputs/foo.cpp @@ -0,0 +1,5 @@ +#include <stdio.h> +#include <string> + +__attribute__((noinline)) +void foo() { printf("foo\n"); } diff --git a/test/tools/sancov/Inputs/test-linux_x86_64 b/test/tools/sancov/Inputs/test-linux_x86_64 Binary files differnew file mode 100755 index 000000000000..2d141b693b2e --- /dev/null +++ b/test/tools/sancov/Inputs/test-linux_x86_64 diff --git a/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov b/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov Binary files differnew file mode 100644 index 000000000000..a1c7f7b6cc38 --- /dev/null +++ b/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov diff --git a/test/tools/sancov/Inputs/test-linux_x86_64.sancov b/test/tools/sancov/Inputs/test-linux_x86_64.sancov Binary files differnew file mode 100644 index 000000000000..e5ed81ed906e --- /dev/null +++ b/test/tools/sancov/Inputs/test-linux_x86_64.sancov diff --git a/test/tools/sancov/Inputs/test.cpp b/test/tools/sancov/Inputs/test.cpp new file mode 100644 index 000000000000..5690409a2781 --- /dev/null +++ b/test/tools/sancov/Inputs/test.cpp @@ -0,0 +1,19 @@ +// compile & generate coverage data using: +// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp foo.cpp +// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.*.sancov test-linux_x86_64.sancov +// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.*.sancov test-linux_x86_64-1.sancov + +#include <stdio.h> +#include <string> + +void foo(); + +__attribute__((noinline)) +std::string bar(std::string str) { printf("bar\n"); return str; } + +int main(int argc, char **argv) { + if (argc == 2) + foo(); + bar("str"); + printf("main\n"); +} diff --git a/test/tools/sancov/blacklist.test b/test/tools/sancov/blacklist.test new file mode 100644 index 000000000000..c07f5cdd109e --- /dev/null +++ b/test/tools/sancov/blacklist.test @@ -0,0 +1,5 @@ +REQUIRES: x86_64-linux +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -covered-functions -blacklist %p/Inputs/blacklist.txt %p/Inputs/test-linux_x86_64.sancov | FileCheck %s + +CHECK-NOT: Inputs{{[/\\]}}test.cpp:12 bar(std::string) +CHECK: Inputs{{[/\\]}}test.cpp:14 main diff --git a/test/tools/sancov/covered_functions.test b/test/tools/sancov/covered_functions.test new file mode 100644 index 000000000000..5e0696bf8615 --- /dev/null +++ b/test/tools/sancov/covered_functions.test @@ -0,0 +1,13 @@ +REQUIRES: x86_64-linux +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -covered-functions %p/Inputs/test-linux_x86_64.sancov | FileCheck %s +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -covered-functions -strip_path_prefix=Inputs/ %p/Inputs/test-linux_x86_64.sancov | FileCheck --check-prefix=STRIP_PATH %s +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -demangle=0 -covered-functions %p/Inputs/test-linux_x86_64.sancov | FileCheck --check-prefix=NO_DEMANGLE %s + +CHECK: Inputs{{[/\\]}}test.cpp:12 bar(std::string) +CHECK: Inputs{{[/\\]}}test.cpp:14 main + +STRIP_PATH: {{^}}test.cpp:12 bar(std::string) +STRIP_PATH: {{^}}test.cpp:14 main + +NO_DEMANGLE: test.cpp:12 _Z3barSs +NO_DEMANGLE: test.cpp:14 main diff --git a/test/tools/sancov/not_covered_functions.test b/test/tools/sancov/not_covered_functions.test new file mode 100644 index 000000000000..8bcbac7f7b1b --- /dev/null +++ b/test/tools/sancov/not_covered_functions.test @@ -0,0 +1,8 @@ +REQUIRES: x86_64-linux +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -not-covered-functions %p/Inputs/test-linux_x86_64.sancov | FileCheck %s +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -not-covered-functions %p/Inputs/test-linux_x86_64-1.sancov | FileCheck --check-prefix=CHECK1 --allow-empty %s + +CHECK: Inputs{{[/\\]}}foo.cpp:5 foo() +CHECK-NOT: {{.*__sanitizer.*}} +CHECK1-NOT: {{.+}} + diff --git a/test/tools/sancov/print.test b/test/tools/sancov/print.test new file mode 100644 index 000000000000..c67bbaa842a8 --- /dev/null +++ b/test/tools/sancov/print.test @@ -0,0 +1,11 @@ +REQUIRES: x86_64-linux +RUN: sancov -obj %p/Inputs/test-linux_x86_64 -print %p/Inputs/test-linux_x86_64.sancov | FileCheck %s + +CHECK: 0x4dbe2b +CHECK: 0x4dbf72 +CHECK: 0x4dbfec +CHECK: 0x4dc033 +CHECK: 0x4dc06a +CHECK: 0x4dc09d +CHECK: 0x4dc0d0 + |
