This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Use metadata to make identifying embedded objects easier
ClosedPublic

Authored by jhuber6 on Jul 1 2022, 7:55 PM.

Details

Summary

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.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 1 2022, 7:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 7:55 PM
jhuber6 requested review of this revision.Jul 1 2022, 7:55 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 1 2022, 7:55 PM

Generally makes sense, some notes though

clang/test/Frontend/embed-object.ll
17

shouldn't it be objects?

The metadata should be defined somewhere (lang ref?)

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
371

Handle nullptr

jhuber6 updated this revision to Diff 442926.Jul 7 2022, 8:14 AM

Updating to use objects and adding documentation.

This revision is now accepted and ready to land.Jul 7 2022, 9:04 AM
This revision was landed with ongoing or failed builds.Jul 7 2022, 9:21 AM
This revision was automatically updated to reflect the committed changes.