[llvm-branch-commits] [llvm] [DirectX] Lower `llvm.dx.resource.handlefromheap` intrinsic (PR #216459)

Deric C. via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 20 10:59:57 PDT 2026


================
@@ -433,6 +433,48 @@ class OpLowerer {
     return lowerToBindAndAnnotateHandle(F);
   }
 
+  bool lowerHandleFromHeap(Function &F) {
+    IRBuilder<> &IRB = OpBuilder.getIRB();
+    Type *Int1Ty = IRB.getInt1Ty();
+
+    return replaceFunction(F, [&](CallInst *CI) -> Error {
+      IRB.SetInsertPoint(CI);
+
+      auto *It = DRM.find(CI);
+      assert(It != DRM.end() && "Resource not in map?");
+      dxil::ResourceInfo &RI = *It;
+      dxil::ResourceTypeInfo &RTI = DRTM[RI.getHandleTy()];
+
+      Value *IndexOp = CI->getArgOperand(0);
+      Value *IsSamplerHeap = CI->getArgOperand(1);
----------------
Icohedron wrote:

[SUGGESTION] Do we need to have `IsSamplerHeap` forwarded from the intrinsic? Perhaps we can just check the resource itself and set the boolean here.
Otherwise, we should at least have an assert or an error when `IsSamplerHeap` is true and does not match the actual heap being used.

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


More information about the llvm-branch-commits mailing list