diff options
author | Helena Kotas <hekotas@microsoft.com> | 2024-08-16 10:32:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-16 10:32:10 -0700 |
commit | db279c72f2fea755c8e66cc1f0a69954764e9284 (patch) | |
tree | 0e4fa7c813f79e4c20c3373b58569f74dc867369 /llvm/lib/Target/DirectX/DirectXTargetMachine.cpp | |
parent | fbef911dc3ed5ab2c857736de9e68bec4c578410 (diff) | |
download | llvm-db279c72f2fea755c8e66cc1f0a69954764e9284.zip llvm-db279c72f2fea755c8e66cc1f0a69954764e9284.tar.gz llvm-db279c72f2fea755c8e66cc1f0a69954764e9284.tar.bz2 |
[HLSL] Change default linkage of HLSL functions to internal (#95331)
An HLSL function has internal linkage by default unless it is:
1. shader entry point function
2. marked with the `export` keyword
(https://github.com/llvm/llvm-project/issues/92812)
3. patch constant function (not implemented yet)
This PR adds a link-time pass `DXILFinalizeLinkage` that updates the
linkage of functions to make sure only shader entry points and exported
functions are visible from the module (have _program linkage_). All
other functions will be updated to have internal linkage.
Related spec update: microsoft/hlsl-specs#295
Fixes #llvm/llvm-project#92071
Diffstat (limited to 'llvm/lib/Target/DirectX/DirectXTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/DirectX/DirectXTargetMachine.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp index 92bd69b..2c2b86e 100644 --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp +++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp @@ -48,6 +48,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTarget() { initializeDXILTranslateMetadataPass(*PR); initializeDXILResourceMDWrapperPass(*PR); initializeShaderFlagsAnalysisWrapperPass(*PR); + initializeDXILFinalizeLinkageLegacyPass(*PR); } class DXILTargetObjectFile : public TargetLoweringObjectFile { @@ -79,6 +80,7 @@ public: void addCodeGenPrepare() override { addPass(createDXILIntrinsicExpansionLegacyPass()); addPass(createDXILOpLoweringLegacyPass()); + addPass(createDXILFinalizeLinkageLegacyPass()); addPass(createDXILTranslateMetadataPass()); addPass(createDXILPrepareModulePass()); } |