[clang] [HLSL] Change default linkage of HLSL functions and groupshared variables (v2) (PR #95331)

Xiang Li via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 10:25:23 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.
+    if (Context.getLangOpts().HLSL && !(FD->isInExportDeclContext())) {
----------------
python3kgae wrote:

What will happen for an exported function in non-library profile shader?

https://github.com/llvm/llvm-project/pull/95331


More information about the cfe-commits mailing list