]> granicus.if.org Git - llvm/commitdiff
[llvm-readobj][test] Add baseline tests for FreeBSD/AMD/AMDGPU note printing
authorJordan Rupprecht <rupprecht@google.com>
Wed, 7 Aug 2019 22:21:49 +0000 (22:21 +0000)
committerJordan Rupprecht <rupprecht@google.com>
Wed, 7 Aug 2019 22:21:49 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368221 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-readobj/note-amd.s [new file with mode: 0644]
test/tools/llvm-readobj/note-amdgpu.test [new file with mode: 0644]
test/tools/llvm-readobj/note-freebsd.s [new file with mode: 0644]

diff --git a/test/tools/llvm-readobj/note-amd.s b/test/tools/llvm-readobj/note-amd.s
new file mode 100644 (file)
index 0000000..ddf86ad
--- /dev/null
@@ -0,0 +1,108 @@
+// REQUIRES: x86-registered-target
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
+
+// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+// GNU:      Displaying notes found
+// GNU-NEXT:   Owner                Data size        Description
+// GNU-NEXT:   AMD                  0x00000000       NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// GNU-NEXT:     HSA Metadata:
+// GNU-NEXT: {{^ +$}}
+// GNU-EMPTY:
+// GNU-NEXT:   AMD                  0x00000000       NT_AMD_AMDGPU_ISA (ISA Version)
+// GNU-NEXT:     ISA Version:
+// GNU-NEXT: {{^ +$}}
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT:   Owner                Data size        Description
+// GNU-NEXT:   AMD                  0x0000000a       NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// GNU-NEXT:     HSA Metadata:
+// GNU-NEXT:     meta_blah
+// GNU-EMPTY:
+// GNU-NEXT:   AMD                  0x00000009       NT_AMD_AMDGPU_ISA (ISA Version)
+// GNU-NEXT:     ISA Version:
+// GNU-NEXT:     isa_blah
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT:   Owner                Data size        Description
+// GNU-NEXT:   AMD                  0x00000000       NT_AMD_AMDGPU_PAL_METADATA (PAL Metadata)
+
+// LLVM:      Notes [
+// LLVM-NEXT:   NoteSection {
+// LLVM-NEXT:     Offset:
+// LLVM-NEXT:     Size:
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: AMD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// LLVM-NEXT:       HSA Metadata:
+// LLVM-NEXT:     }
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: AMD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_AMD_AMDGPU_ISA (ISA Version)
+// LLVM-NEXT:       ISA Version:
+// LLVM-NEXT:     }
+// LLVM-NEXT:   }
+// LLVM-NEXT:   NoteSection {
+// LLVM-NEXT:     Offset:
+// LLVM-NEXT:     Size:
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: AMD
+// LLVM-NEXT:       Data size: 0xA
+// LLVM-NEXT:       Type: NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// LLVM-NEXT:       HSA Metadata: meta_blah
+// LLVM-NEXT:     }
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: AMD
+// LLVM-NEXT:       Data size: 0x9
+// LLVM-NEXT:       Type: NT_AMD_AMDGPU_ISA (ISA Version)
+// LLVM-NEXT:       ISA Version: isa_blah
+// LLVM-NEXT:     }
+// LLVM-NEXT:   }
+// LLVM-NEXT:   NoteSection {
+// LLVM-NEXT:     Offset:
+// LLVM-NEXT:     Size:
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: AMD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_AMD_AMDGPU_PAL_METADATA (PAL Metadata)
+// LLVM-NEXT:     }
+// LLVM-NEXT:   }
+// LLVM-NEXT: ]
+
+.section ".note.no.desc", "a"
+       .align 4
+       .long 4 /* namesz */
+       .long 0 /* descsz */
+       .long 10 /* type = NT_AMD_AMDGPU_HSA_METADATA */
+       .asciz "AMD"
+       .long 4 /* namesz */
+       .long 0 /* descsz */
+       .long 11 /* type = NT_AMD_AMDGPU_ISA */
+       .asciz "AMD"
+.section ".note.desc", "a"
+       .align 4
+       .long 4 /* namesz */
+       .long end.meta - begin.meta /* descsz */
+       .long 10 /* type = NT_AMD_AMDGPU_HSA_METADATA */
+       .asciz "AMD"
+begin.meta:
+       .asciz "meta_blah"
+end.meta:
+       .align 4
+       .long 4 /* namesz */
+       .long end.isa - begin.isa /* descsz */
+       .long 11 /* type = NT_AMD_AMDGPU_ISA */
+       .asciz "AMD"
+begin.isa:
+       .asciz "isa_blah"
+end.isa:
+       .align 4
+.section ".note.other", "a"
+       .align 4
+       .long 4 /* namesz */
+       .long 0 /* descsz */
+       .long 12 /* type = NT_AMD_AMDGPU_PAL_METADATA */
+       .asciz "AMD"
diff --git a/test/tools/llvm-readobj/note-amdgpu.test b/test/tools/llvm-readobj/note-amdgpu.test
new file mode 100644 (file)
index 0000000..51440dd
--- /dev/null
@@ -0,0 +1,85 @@
+# RUN: yaml2obj %s > %t.o
+# RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+# GNU:      Displaying notes found
+# GNU-NEXT:   Owner                Data size        Description
+# GNU-NEXT:   AMDGPU               0x000000e6       NT_AMDGPU_METADATA (AMDGPU Metadata)
+# GNU-NEXT:     AMDGPU Metadata:
+# GNU-NEXT:         ---
+# GNU-NEXT: amdhsa.kernels:
+# GNU-NEXT:   - .group_segment_fixed_size: 2
+# GNU-NEXT:     .kernarg_segment_align: 4
+# GNU-NEXT:     .kernarg_segment_size: 1
+# GNU-NEXT:     .max_flat_workgroup_size: 8
+# GNU-NEXT:     .name:           foo
+# GNU-NEXT:     .private_segment_fixed_size: 3
+# GNU-NEXT:     .sgpr_count:     6
+# GNU-NEXT:     .symbol:         foo
+# GNU-NEXT:     .vgpr_count:     7
+# GNU-NEXT:     .wavefront_size: 5
+# GNU-NEXT: amdhsa.version:
+# GNU-NEXT:   - 1
+# GNU-NEXT:   - 0
+# GNU-NEXT: ...
+
+# LLVM:      Notes [
+# LLVM-NEXT:   NoteSection {
+# LLVM-NEXT:     Offset:
+# LLVM-NEXT:     Size:
+# LLVM-NEXT:     Note {
+# LLVM-NEXT:       Owner: AMDGPU
+# LLVM-NEXT:       Data size: 0xE6
+# LLVM-NEXT:       Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
+# LLVM-NEXT:       AMDGPU Metadata: ---
+# LLVM-NEXT: amdhsa.kernels:
+# LLVM-NEXT:   - .group_segment_fixed_size: 2
+# LLVM-NEXT:     .kernarg_segment_align: 4
+# LLVM-NEXT:     .kernarg_segment_size: 1
+# LLVM-NEXT:     .max_flat_workgroup_size: 8
+# LLVM-NEXT:     .name:           foo
+# LLVM-NEXT:     .private_segment_fixed_size: 3
+# LLVM-NEXT:     .sgpr_count:     6
+# LLVM-NEXT:     .symbol:         foo
+# LLVM-NEXT:     .vgpr_count:     7
+# LLVM-NEXT:     .wavefront_size: 5
+# LLVM-NEXT: amdhsa.version:
+# LLVM-NEXT:   - 1
+# LLVM-NEXT:   - 0
+# LLVM-NEXT: ...
+# LLVM-EMPTY:
+# LLVM-NEXT:     }
+# LLVM-NEXT:   }
+# LLVM-NEXT: ]
+
+## Use yaml2obj instead of llvm-mc for more test portability. This was
+## generated by grabbing section data from an object built via:
+# $ llvm-mc -filetype=obj -triple amdgcn-amd-amdhsa -mattr=+code-object-v3 %s -o %t.o
+## On input:
+# .amdgpu_metadata
+#   amdhsa.version:
+#     - 1
+#     - 0
+#   amdhsa.kernels:
+#     - .name:   foo
+#       .symbol: foo
+#       .kernarg_segment_size: 1
+#       .group_segment_fixed_size: 2
+#       .private_segment_fixed_size: 3
+#       .kernarg_segment_align: 4
+#       .wavefront_size: 5
+#       .sgpr_count: 6
+#       .vgpr_count: 7
+#       .max_flat_workgroup_size: 8
+# .end_amdgpu_metadata
+
+--- !ELF
+FileHeader:
+  Class:         ELFCLASS64
+  Data:          ELFDATA2LSB
+  Type:          ET_REL
+  Machine:       EM_X86_64
+Sections:
+  - Name:        .note.foo
+    Type:        SHT_NOTE
+    Content:     07000000E600000020000000414D44475055000082AE616D646873612E6B65726E656C73918AB92E67726F75705F7365676D656E745F66697865645F73697A6502B62E6B65726E6172675F7365676D656E745F616C69676E04B52E6B65726E6172675F7365676D656E745F73697A6501B82E6D61785F666C61745F776F726B67726F75705F73697A6508A52E6E616D65A3666F6FBB2E707269766174655F7365676D656E745F66697865645F73697A6503AB2E736770725F636F756E7406A72E73796D626F6CA3666F6FAB2E766770725F636F756E7407AF2E7761766566726F6E745F73697A6505AE616D646873612E76657273696F6E9201000000
diff --git a/test/tools/llvm-readobj/note-freebsd.s b/test/tools/llvm-readobj/note-freebsd.s
new file mode 100644 (file)
index 0000000..9549ca4
--- /dev/null
@@ -0,0 +1,58 @@
+// REQUIRES: x86-registered-target
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
+
+// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+// GNU:      Displaying notes found
+// GNU-NEXT:   Owner                Data size        Description
+// GNU-NEXT:   FreeBSD              0x00000000       NT_THRMISC (thrmisc structure)
+// GNU-EMPTY:
+// GNU-NEXT:   FreeBSD              0x00000000       NT_PROCSTAT_PROC (proc data)
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT:   Owner                Data size        Description
+// GNU-NEXT:   FreeBSD              0x00000000       NT_PROCSTAT_FILES (files data)
+
+// LLVM:      Notes [
+// LLVM-NEXT:   NoteSection {
+// LLVM-NEXT:     Offset:
+// LLVM-NEXT:     Size:
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: FreeBSD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_THRMISC (thrmisc structure)
+// LLVM-NEXT:     }
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: FreeBSD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_PROCSTAT_PROC (proc data)
+// LLVM-NEXT:     }
+// LLVM-NEXT:   }
+// LLVM-NEXT:   NoteSection {
+// LLVM-NEXT:     Offset: 0x68
+// LLVM-NEXT:     Size: 0x14
+// LLVM-NEXT:     Note {
+// LLVM-NEXT:       Owner: FreeBSD
+// LLVM-NEXT:       Data size: 0x0
+// LLVM-NEXT:       Type: NT_PROCSTAT_FILES (files data)
+// LLVM-NEXT:     }
+// LLVM-NEXT:   }
+// LLVM-NEXT: ]
+
+.section ".note.foo", "a"
+       .align 4
+       .long 8 /* namesz */
+       .long 0 /* descsz */
+       .long 7 /* type = NT_FREEBSD_THRMISC */
+       .asciz "FreeBSD"
+       .long 8 /* namesz */
+       .long 0 /* descsz */
+       .long 8 /* type = NT_FREEBSD_PROC */
+       .asciz "FreeBSD"
+.section ".note.bar", "a"
+       .align 4
+       .long 8 /* namesz */
+       .long 0 /* descsz */
+       .long 9 /* type = NT_FREEBSD_FILES */
+       .asciz "FreeBSD"