[clang] [HLSL] Change default linkage of HLSL functions and groupshared variables (v2) (PR #95331)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 16:10:26 PDT 2024
================
@@ -664,11 +664,25 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
if (PrevVar->getStorageClass() == SC_Static)
return LinkageInfo::internal();
}
+
+ if (Context.getLangOpts().HLSL &&
+ Var->hasAttr<HLSLGroupSharedAddressSpaceAttr>())
+ return LinkageInfo::internal();
+
} else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
// - a data member of an anonymous union.
const VarDecl *VD = IFD->getVarDecl();
assert(VD && "Expected a VarDecl in this IndirectFieldDecl!");
return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
+
+ } else if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
+ // HLSL: Functions that are not exported library functions have internal
+ // linkage by default. That includes shader entry point functions, which
+ // will be wrapped by an external linkage function with unmangled C-style
+ // name during CodeGen.
----------------
llvm-beanz wrote:
I don't think this is the behavior we want. It isn't just an issue for library functions, this also becomes an issue when we think about multi-translation unit building (DXC's lib_6_x profile). We really do want to match C++'s rules for external functions.
What we need to do differently is when targeting a known specific profile we can skip emitting unused declarations.
https://github.com/llvm/llvm-project/pull/95331
More information about the cfe-commits
mailing list