[clang] [llvm] [clang][SPIR-V] Implement -fspv-preserve-interface (PR #196404)

Diego Novillo via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 6 10:36:24 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;
----------------
dnovillo wrote:

Thanks. It was just force of habit.

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


More information about the cfe-commits mailing list