This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Support linking archive of bundled bitcode
ClosedPublic

Authored by yaxunl on Feb 17 2022, 9:49 AM.

Details

Summary

HIP programs compiled with -c -fgpu-rdc generate clang-offload-bundler
bundles which contain bitcode for different GPU's.

Such files can be archived to an archive file which can be linked with
HIP programs with -fgpu-rdc.

This patch adds suppor of linking archive of bundled bitcode.

When an archive of bundled bitcode is passed to clang by -l, for each
GPU specified through --offload-arch, clang extracts bitcode from
the archive and creates a new archive for that GPU and pass it
to lld.

Diff Detail

Event Timeline

yaxunl requested review of this revision.Feb 17 2022, 9:49 AM
yaxunl created this revision.
tra accepted this revision.Feb 17 2022, 10:06 AM

LGTM.

clang/test/Driver/hip-link-bundle-archive.hip
3

Is this file necessary? clang -### should not need the file to be present in order to print out command lines.

This revision is now accepted and ready to land.Feb 17 2022, 10:06 AM
yaxunl marked an inline comment as done.Feb 17 2022, 10:33 AM
yaxunl added inline comments.
clang/test/Driver/hip-link-bundle-archive.hip
3

You are right. Will remove it when committing.

yaxunl marked an inline comment as done.Feb 18 2022, 5:40 AM
yaxunl added inline comments.
clang/test/Driver/hip-link-bundle-archive.hip
3

Sorry, AddStaticDeviceLibsLinking needs to determine the real path of the library by looking up multiple -L options, therefore it requires the file to exist.

I forgot to delete the file when testing, so I thought the test passes without creating the file. After I delete it, the test fails. Therefore I have to add back the touch command.

This revision was landed with ongoing or failed builds.Feb 19 2022, 4:14 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2022, 4:14 PM