[clang] counter var3 (PR #162291)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 16:13:41 PDT 2025


================
@@ -352,6 +352,19 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
     SmallVector<Value *> Args{OrderID, SpaceOp, RangeOp, IndexOp, Name};
     return Builder.CreateIntrinsic(HandleTy, IntrinsicID, Args);
   }
+  case Builtin::BI__builtin_hlsl_resource_counterhandlefromimplicitbinding: {
+    llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());
+    Value *MainHandle = EmitScalarExpr(E->getArg(0));
+    if (CGM.getTriple().isSPIRV()) {
----------------
hekota wrote:

`HandleTy` is used only for the SPIR-V case and the conversion can be moved inside the `if` statement. Also, consider early exit for the DXIL case:
```
if (!CGM.getTriple().isSPIRV())
  return MainHandle;
```

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


More information about the cfe-commits mailing list