[clang] [clang][SYCL] Emit non-exported device symbols with internal/linkonce_odr linkage (PR #215437)
Yury Plyakhin via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 17:00:13 PDT 2026
================
@@ -6821,6 +6821,19 @@ CodeGenModule::getLLVMLinkageForDeclarator(const DeclaratorDecl *D,
if (Linkage == GVA_AvailableExternally)
return llvm::GlobalValue::AvailableExternallyLinkage;
+ // SYCL device symbols that are not part of the module interface (i.e. not
+ // SYCL kernels and not marked with [[clang::sycl_external]]) are not
+ // externally visible. In RDC mode they are emitted with linkonce_odr linkage
+ // so equivalent definitions can be deduplicated across translation units.
+ // In non-RDC mode the whole device program lives in a single translation
+ // unit, so they are given internal linkage to enable more aggressive
+ // optimization.
+ if (getLangOpts().SYCLIsDevice && !D->hasAttr<SYCLKernelAttr>() &&
+ !D->hasAttr<SYCLExternalAttr>())
----------------
YuriPlyakhin wrote:
thanks, I was thinking about it. I mark this comment as unresolved. I will resolve it by defining `__CLANG_RDC__`
https://github.com/llvm/llvm-project/pull/215437
More information about the cfe-commits
mailing list