[clang] [llvm] [clang][SPIR-V] Implement -fspv-preserve-interface (PR #196404)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 12:48:22 PDT 2026
================
@@ -596,6 +597,21 @@ void CGHLSLRuntime::finishCodeGen() {
M.setModuleFlag(llvm::Module::ModFlagBehavior::Error, "dx.nativelowprec",
1);
+ if (LangOpts.HLSLSpvPreserveInterface && T.isSPIRV()) {
+ // Runs before optimization. Keeps Input/Output globals from GlobalDCE.
+ const ASTContext &Ctx = CGM.getContext();
+ unsigned InputAS = Ctx.getTargetAddressSpace(LangAS::hlsl_input);
+ unsigned OutputAS = Ctx.getTargetAddressSpace(LangAS::hlsl_output);
+ SmallVector<GlobalValue *, 8> InterfaceVars;
----------------
bogner wrote:
Probably better to use the heuristic for the size of the SmallVector unless we have a good reason for 8 specifically.
```suggestion
SmallVector<GlobalValue *> InterfaceVars;
```
https://github.com/llvm/llvm-project/pull/196404
More information about the cfe-commits
mailing list