[Clang] Use metadata to make identifying embedded objects easier
authorJoseph Huber <jhuber6@vols.utk.edu>
Sat, 2 Jul 2022 02:40:41 +0000 (22:40 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 7 Jul 2022 16:20:25 +0000 (12:20 -0400)
commited801ad5e5fef76c4303d04fd8de21662b428bee
tree9daa0dffbac3382407b4d3def3621d4c42b979d9
parent23f56132da4f14973f6c0d3465d94db2df6b2146
[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
clang/test/Frontend/embed-object.c
clang/test/Frontend/embed-object.ll
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
llvm/docs/LangRef.rst
llvm/include/llvm/Transforms/Utils/ModuleUtils.h
llvm/lib/Transforms/Utils/ModuleUtils.cpp