This is an archive of the discontinued LLVM Phabricator instance.

[LinkerWrapper] Support linking vendor bitcode late
ClosedPublic

Authored by jhuber6 on Jun 8 2023, 6:36 AM.

Details

Summary

The GPU vendors currently provide bitcode files for their device
runtime. These files need to be handled specially as they are not built
to be linked in with a standard llvm-link call or through LTO linking.
This patch adds an alternative to use the existing clang handling of
these libraries that does the necessary magic to make this work.

We do this by causing the LTO backend to emit bitcode before running the
backend. We then pass this through to clang which uses the existing
support which has been fixed to support this by D152391. The backend
will then be run with the merged module.

This patch adds the --builtin-bitcode=<triple>=file.bc to specify a single
file, or just --clang-backend to let the toolchain handle its defaults
(currently nothing for NVPTX and the ROCm device libs for AMDGPU). This may have
a performance impact due to running the optimizations again, we could
potentially disable optimizations in LTO and only do the linking if this is an
issue.

This should allow us to resolve issues when relying on the linker-wrapper to
do a late linking that may depend on vendor libraries.

Depends on D152391

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 8 2023, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 6:36 AM
Herald added a subscriber: tpr. · View Herald Transcript
jhuber6 requested review of this revision.Jun 8 2023, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 6:36 AM
JonChesterfield accepted this revision.Jun 13 2023, 12:14 PM

This LG, the complicated stuff is in the previous patch. Thanks

This revision is now accepted and ready to land.Jun 13 2023, 12:14 PM
This revision was automatically updated to reflect the committed changes.