[llvm-objdump] Add support for dumping embedded offloading data
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 2 Jun 2022 18:25:49 +0000 (14:25 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Sat, 2 Jul 2022 01:13:28 +0000 (21:13 -0400)
commitd2d8b0aa4f80752722321d1e74e2d98761caaa61
tree26061396a9dc76e670ca849cb307bae58d9e2053
parent228c8f9cc0b2bf615706567f121a422b1b0e7f83
[llvm-objdump] Add support for dumping embedded offloading data

In Clang/LLVM we are moving towards a new binary format to store many
embedded object files to create a fatbinary. This patch adds support for
dumping these embedded images in the `llvm-objdump` tool. This will
allow users to query information about what is stored inside the binary.
This has very similar functionality to the `cuobjdump` tool for thoe familiar
with the Nvidia utilities. The proposed use is as follows:
```
$ clang input.c -fopenmp --offload-arch=sm_70 --offload-arch=sm_52 -c
$ llvm-objdump -O input.o

input.o:        file format elf64-x86-64

OFFLOADIND IMAGE [0]:
kind            cubin
arch            sm_52
triple          nvptx64-nvidia-cuda
producer        openmp

OFFLOADIND IMAGE [1]:
kind            cubin
arch            sm_70
triple          nvptx64-nvidia-cuda
producer        openmp
```

This will be expanded further once we start embedding more information
into these offloading images. Right now we are planning on adding
flags and entries for debug level, optimization, LTO usage, target
features, among others.

This patch only supports printing these sections, later we will want to
support dumping files the user may be interested in via another flag. I
am unsure if this should go here in `llvm-objdump` or `llvm-objcopy`.

Reviewed By: MaskRay, tra, jhenderson, JonChesterfield

Differential Revision: https://reviews.llvm.org/D126904
llvm/test/tools/llvm-objdump/Offloading/Inputs/binary.yaml [new file with mode: 0644]
llvm/test/tools/llvm-objdump/Offloading/Inputs/malformed.yaml [new file with mode: 0644]
llvm/test/tools/llvm-objdump/Offloading/binary.test [new file with mode: 0644]
llvm/test/tools/llvm-objdump/Offloading/content-failure.test [new file with mode: 0644]
llvm/test/tools/llvm-objdump/Offloading/failure.test [new file with mode: 0644]
llvm/test/tools/llvm-objdump/Offloading/warning.test [new file with mode: 0644]
llvm/tools/llvm-objdump/CMakeLists.txt
llvm/tools/llvm-objdump/ObjdumpOpts.td
llvm/tools/llvm-objdump/OffloadDump.cpp [new file with mode: 0644]
llvm/tools/llvm-objdump/OffloadDump.h [new file with mode: 0644]
llvm/tools/llvm-objdump/llvm-objdump.cpp