[all-commits] [llvm/llvm-project] ed801a: [Clang] Use metadata to make identifying embedded ...

Joseph Huber via All-commits all-commits at lists.llvm.org
Thu Jul 7 09:20:58 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ed801ad5e5fef76c4303d04fd8de21662b428bee
      https://github.com/llvm/llvm-project/commit/ed801ad5e5fef76c4303d04fd8de21662b428bee
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M clang/test/Frontend/embed-object.c
    M clang/test/Frontend/embed-object.ll
    M clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/Transforms/Utils/ModuleUtils.h
    M llvm/lib/Transforms/Utils/ModuleUtils.cpp

  Log Message:
  -----------
  [Clang] Use metadata to make identifying embedded objects easier

Currently we use the `embedBufferInModule` function to store binary
strings containing device offloading data inside the host object to
create a fatbinary. In the case of LTO, we need to extract this object
from the LLVM-IR. This patch adds a metadata node for the embedded
objects containing the embedded pointers and the sections they were
stored at. This should create a cleaner interface for identifying these
values.

In the future it may be worthwhile to also encode an `ID` in the
metadata corresponding to the object's special section type if relevant.
This would allow us to extract the data from an object file and LLVM-IR
using the same ID.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D129033


  Commit: 1d2ce4da8414de8775c134eb1c7e2c9436b443df
      https://github.com/llvm/llvm-project/commit/1d2ce4da8414de8775c134eb1c7e2c9436b443df
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M llvm/docs/Extensions.rst
    M llvm/include/llvm/BinaryFormat/ELF.h
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    M llvm/lib/MC/MCParser/ELFAsmParser.cpp
    M llvm/lib/MC/MCSectionELF.cpp
    M llvm/lib/Object/ELF.cpp
    M llvm/lib/ObjectYAML/ELFYAML.cpp
    M llvm/test/CodeGen/X86/offload_sections.ll
    M llvm/test/MC/AsmParser/llvm_section_types.s
    A llvm/test/ObjectYAML/ELF/sht-offloading.yaml

  Log Message:
  -----------
  [Object] Add ELF section type for offloading objects

Currently we use the `.llvm.offloading` section to store device-side
objects inside the host, creating a fat binary. The contents of these
sections is currently determined by the name of the section while it
should ideally be determined by its type. This patch adds the new
`SHT_LLVM_OFFLOADING` section type to the ELF section types. Which
should make it easier to identify this specific data format.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D129052


  Commit: 82a0adf0f78d5be8a727d9537627e2a6f7e8e105
      https://github.com/llvm/llvm-project/commit/82a0adf0f78d5be8a727d9537627e2a6f7e8e105
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M llvm/test/tools/llvm-objdump/Offloading/binary.test
    M llvm/test/tools/llvm-objdump/Offloading/content-failure.test
    M llvm/test/tools/llvm-objdump/Offloading/failure.test
    A llvm/test/tools/llvm-objdump/Offloading/non-elf.test
    M llvm/test/tools/llvm-objdump/Offloading/warning.test
    M llvm/tools/llvm-objdump/OffloadDump.cpp

  Log Message:
  -----------
  [llvm-objdump] Update offload dumping to use SHT_LLVM_OFFLOADING

In order to be more in-line with ELF semantics, a previous patch added
support for a new ELF section type to indicate if a section contains
offloading data. This allows us to now check using this rather than
checking the section name directly. This patch updates the logic to
check the type now instead.

I chose to make this emit a warning if the input is not an ELF-object
file. I could have made the logic fall-back to the section name, but
this offloading in LLVM is currently not supported on any other targets
so it's probably best to emit a warning until we improve support.

Depends on D129052

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D129053


  Commit: 41fba3c107a5bc99065f3bf8b9f5b9d52eab2d98
      https://github.com/llvm/llvm-project/commit/41fba3c107a5bc99065f3bf8b9f5b9d52eab2d98
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M clang/test/Frontend/embed-object.c
    M clang/test/Frontend/embed-object.ll
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/IR/FixedMetadataKinds.def
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    M llvm/lib/Target/TargetLoweringObjectFile.cpp
    M llvm/lib/Transforms/Utils/ModuleUtils.cpp
    A llvm/test/CodeGen/X86/coff-exclude.ll
    A llvm/test/CodeGen/X86/elf-exclude.ll
    M llvm/test/CodeGen/X86/offload_sections.ll

  Log Message:
  -----------
  [Metadata] Add 'exclude' metadata to add the exclude flags on globals

This patchs adds a new metadata kind `exclude` which implies that the
global variable should be given the necessary flags during code
generation to not be included in the final executable. This is done
using the ``SHF_EXCLUDE`` flag on ELF for example. This should make it
easier to specify this flag on a variable without needing to explicitly
check the section name in the target backend.

Depends on D129053 D129052

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D129151


Compare: https://github.com/llvm/llvm-project/compare/23f56132da4f...41fba3c107a5


More information about the All-commits mailing list