[clang] [llvm] [HLSL] Add load overload with status (PR #166449)

Helena Kotas via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 11:13:15 PST 2025


================
@@ -404,6 +353,50 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
         RetTy, CGM.getHLSLRuntime().getCreateResourceGetPointerIntrinsic(),
         ArrayRef<Value *>{HandleOp, IndexOp});
   }
+  case Builtin::BI__builtin_hlsl_resource_load_with_status: {
+    Value *HandleOp = EmitScalarExpr(E->getArg(0));
+    Value *IndexOp = EmitScalarExpr(E->getArg(1));
+
+    // Get the *address* of the status argument to write to it by reference
+    LValue StatusLVal = EmitLValue(E->getArg(2));
+    Address StatusAddr = StatusLVal.getAddress();
+
+    QualType HandleTy = E->getArg(0)->getType();
+    const HLSLAttributedResourceType *RT =
+        HandleTy->getAs<HLSLAttributedResourceType>();
+    assert(RT && "Expected a resource type as first parameter");
----------------
hekota wrote:

Nit - this has already been verified in SemaHLSL.cpp:3015 and we don't seem to assert that the first arg is a handle in the other cases.

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


More information about the llvm-commits mailing list