diff options
author | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2022-04-08 23:56:07 -0400 |
---|---|---|
committer | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2022-04-13 10:47:16 -0400 |
commit | 0424b5115cffad73a0f6e68affed603a7ed9a692 (patch) | |
tree | b56c890234e87faa29bb8c859f855bcd9376def6 /clang/lib/Sema/SemaCUDA.cpp | |
parent | 8c74169990c0b179fa9a0c82f8d6ca35889b9ec4 (diff) | |
download | llvm-0424b5115cffad73a0f6e68affed603a7ed9a692.zip llvm-0424b5115cffad73a0f6e68affed603a7ed9a692.tar.gz llvm-0424b5115cffad73a0f6e68affed603a7ed9a692.tar.bz2 |
[CUDA][HIP] Fix host used external kernel in archive
For -fgpu-rdc, a host function may call an external kernel
which is defined in an archive of bitcode. Since this external
kernel is only referenced in host function, the device
bitcode does not contain reference to this external
kernel, then the linker will not try to resolve this external
kernel in the archive.
To fix this issue, host-used external kernels and device
variables are tracked. A global array containing pointers
to these external kernels and variables is emitted which
serves as an artificial references to the external kernels
and variables used by host.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D123441
Diffstat (limited to 'clang/lib/Sema/SemaCUDA.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index b0af130..18f9dd7 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -819,8 +819,13 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee) { } }(); - if (DiagKind == SemaDiagnosticBuilder::K_Nop) + if (DiagKind == SemaDiagnosticBuilder::K_Nop) { + // For -fgpu-rdc, keep track of external kernels used by host functions. + if (LangOpts.CUDAIsDevice && LangOpts.GPURelocatableDeviceCode && + Callee->hasAttr<CUDAGlobalAttr>() && !Callee->isDefined()) + getASTContext().CUDAExternalDeviceDeclODRUsedByHost.insert(Callee); return true; + } // Avoid emitting this error twice for the same location. Using a hashtable // like this is unfortunate, but because we must continue parsing as normal |