[clang] [llvm] [HLSL][SPIR-V] Implement vk::ext_builtin_input attribute (PR #138530)

Nathan Gauër via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 08:54:11 PDT 2025


================
@@ -5759,9 +5761,18 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
       getCUDARuntime().internalizeDeviceSideVar(D, Linkage);
     }
     getCUDARuntime().handleVarRegistration(D, *GV);
+  } else if (LangOpts.HLSL &&
+             GetGlobalVarAddressSpace(D) == LangAS::hlsl_input) {
+    // HLSL Input variables are considered to be set by the driver/pipeline, but
+    // only visible to a single thread/wave.
+    GV->setExternallyInitialized(true);
----------------
Keenuts wrote:

I initially did this, but I found it less clear: it was not clear reading the top level function what property was changed by sub-functions, and other languages did it at the top level, so it felt confusing.
I prefer to only keep the metadata generation in the CGHLSLRuntime function.

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


More information about the cfe-commits mailing list