[clang] [llvm] [HLSL][SPIR-V] Implement vk::push_constant (PR #166793)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 07:58:45 PST 2025


================
@@ -845,6 +846,17 @@ Type *SPIRVEmitIntrinsics::deduceElementTypeHelper(
       } else {
         llvm_unreachable("Unknown handle type for spv_resource_getpointer.");
       }
+    } else if (II &&
+               II->getIntrinsicID() == Intrinsic::spv_pushconstant_getpointer) {
+      auto *GV = cast<GlobalVariable>(II->getOperand(0));
+      auto *HandleType = cast<TargetExtType>(GV->getValueType());
+      if (HandleType->getTargetExtName() == "spirv.PushConstant") {
+        for (User *U : II->users()) {
+          Ty = cast<Instruction>(U)->getAccessType();
+          if (Ty)
+            break;
+        }
----------------
s-perron wrote:

Why do you look at the users? Can't you get the type from target type as we do for a vulkan buffer?

My concern is that the first uses will be a load of an integer at the start of the puch constant block. LLVM-opt will remove the GEP because it is not needed in llvm-ir. The second use will be a gep to access a float in the second position. Then that will generate an access chain on an int.

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


More information about the llvm-commits mailing list