diff options
author | Steven Perron <stevenperron@google.com> | 2025-06-16 16:44:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-16 16:44:55 -0400 |
commit | a027eb4472ee8fa504c98bef655cac8c8bfe333a (patch) | |
tree | 834a81f56e819d9462e13e5b38db3e547c92da1b /clang/lib/CodeGen | |
parent | 34be09ad731d631d7b950a334cfe25673ebe5519 (diff) | |
download | llvm-a027eb4472ee8fa504c98bef655cac8c8bfe333a.zip llvm-a027eb4472ee8fa504c98bef655cac8c8bfe333a.tar.gz llvm-a027eb4472ee8fa504c98bef655cac8c8bfe333a.tar.bz2 |
[HLSL] Use hidden visibility for external linkage. (#140292)
Implements
https://github.com/llvm/wg-hlsl/blob/main/proposals/0026-symbol-visibility.md.
The change is to stop using the `hlsl.export` attribute. Instead,
symbols with "program linkage" in HLSL will have export linkage with
default visibility, and symbols with "external linkage" in HLSL will
have export linkage with hidden visibility.
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGHLSLRuntime.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 |
3 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index 571ff53..585411b 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -471,14 +471,6 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, } } -void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD, - llvm::Function *Fn) { - if (FD->isInExportDeclContext()) { - const StringRef ExportAttrKindStr = "hlsl.export"; - Fn->addFnAttr(ExportAttrKindStr); - } -} - static void gatherFunctions(SmallVectorImpl<Function *> &Fns, llvm::Module &M, bool CtorOrDtor) { const auto *GV = diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 13d0633..70a0979 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1267,7 +1267,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (FD->hasAttr<HLSLShaderAttr>()) { CGM.getHLSLRuntime().emitEntryFunction(FD, Fn); } - CGM.getHLSLRuntime().setHLSLFunctionAttributes(FD, Fn); } EmitFunctionProlog(*CurFnInfo, CurFn, Args); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c036902..06c0e1f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1666,6 +1666,11 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, return; } + if (Context.getLangOpts().HLSL && !D->isInExportDeclContext()) { + GV->setVisibility(llvm::GlobalValue::HiddenVisibility); + return; + } + if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass()) { // Reject incompatible dlllstorage and visibility annotations. if (!LV.isVisibilityExplicit()) |