[clang-offload-bundler] Make Bundle Entry ID backward compatible
authorSaiyedul Islam <Saiyedul.Islam@amd.com>
Mon, 26 Jul 2021 16:39:41 +0000 (22:09 +0530)
committerSaiyedul Islam <Saiyedul.Islam@amd.com>
Wed, 8 Sep 2021 10:36:12 +0000 (16:06 +0530)
commit98380762c3b734c23d206182605ab9e035c93caa
tree2d9734d2f4c4399c3ae2235060c6ba474efc6419
parent7fb66d4035960b3c2797eae73d79b8478ff0348e
[clang-offload-bundler] Make Bundle Entry ID backward compatible

Earlier BundleEntryID used to be <OffloadKind>-<Triple>-<GPUArch>.
This used to work because the clang-offload-bundler didn't need
GPUArch explicitly for any bundling/unbundling action. With
unbundleArchive it needs GPUArch to ensure compatibility between
device specific code objects. D93525 enforced triples to have
separators for all 4 components irrespective of number of
components, like "amdgcn-amd-amdhsa--". It was required to
to correctly parse a possible 4th environment component or a GPU.
But, this condition is breaking backward compatibility with
archive libraries compiled with compilers older than D93525.

This patch allows triples to have any number of components with
and without extra separator for empty environment field. Thus,
both the following bundle entry IDs are same:
openmp-amdgcn-amd-amdhsa--gfx906
openmp-amdgcn-amd-amdhsa-gfx906

Reviewed By: yaxunl, grokos

Differential Revision: https://reviews.llvm.org/D106809
clang/docs/ClangOffloadBundler.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang-offload-bundler.c
clang/test/Driver/hip-rdc-device-only.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp