[clang] [llvm] [Clang][SYCL] Compile device code once per IGCA target (PR #239010)
Srividya Sundaram via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 9 18:06:11 PST 2026
================
@@ -1480,16 +1595,20 @@ getDeviceInput(const ArgList &Args) {
if (!Binary.getBinary())
continue;
- SmallVector<OffloadFile::TargetID> CompatibleTargets = {Binary};
+ // A generic member can still be linked into any compatible image; other
+ // members only into images with the same "code".
+ ImageID Target = GetImageID(Binary);
+ bool IsGeneric = Target.first.second == "generic";
+ SmallVector<ImageID> CompatibleTargets = {Target};
for (const auto &[ID, Input] : InputFiles)
- if (OffloadFile::TargetID(Binary) != ID &&
- object::areTargetsCompatible(Binary, ID))
+ if (Target != ID && (IsGeneric || Target.second == ID.second) &&
+ object::areTargetsCompatible(Target.first, ID.first))
----------------
srividya-sundaram wrote:
Yes, the archive member is extracted, since both GPUs map to igca_30r.
But device images are grouped by the same arch and code, and the codes differ here, so the library's device code is linked separately from the application's:
```
clang-linker-wrapper app.o libl.a
|-- arch=igca_30r, code=xe-mtl-h,xe-mtl-u
| app.o --> clang --sycl-link --> clang-sycl-linker --> ocloc -device xe-mtl-h,xe-mtl-u --> offload binary 1
|-- arch=igca_30r, code=xe-mtl-u
| lib.o --> clang --sycl-link --> clang-sycl-linker --> ocloc -device xe-mtl-u --> offload binary 2
|
--> offload binary 1 + offload binary 2 merged into one offload binary --> one wrapper object
```
https://github.com/llvm/llvm-project/pull/239010
More information about the cfe-commits
mailing list