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.
As this is a new output format, we probably want to use the FileCheck options --match-full-lines --strict-whitespace --implicit-check-not={{.}} to ensure the entire output (including indentation etc) is checked-for and there is nothing additional being printed that shouldn't be.
As there's only one check pattern used in the file, drop the --check-prefix argument and just use CHECK:, CHECK-NEXT: etc.
Using pre-canned binaries is less than ideal. Can you use yaml2obj to generate the test inputs at runtime? This will make them less opaque and easier to maintain long-term. Depending on the section's complexity, it probably makes sense to add support for it to yaml2obj explicitly, so that it's easy to specify kind/arch/triple/producer etc in dedicated fields.