[clang] [HLSL] Codegen for indexing of sub-arrays of multi-dimensional resource arrays (PR #154248)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 27 10:22:15 PDT 2025
================
@@ -860,26 +929,35 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
TmpVar, Qualifiers(), AggValueSlot::IsDestructed_t(true),
AggValueSlot::DoesNotNeedGCBarriers, AggValueSlot::IsAliased_t(false),
AggValueSlot::DoesNotOverlap);
-
- Address ThisAddress = ValueSlot.getAddress();
- llvm::Value *ThisPtr = CGF.getAsNaturalPointerTo(
- ThisAddress, CD->getThisType()->getPointeeType());
+ Address TmpVarAddress = ValueSlot.getAddress();
// get total array size (= range size)
llvm::Value *Range =
llvm::ConstantInt::get(CGM.IntTy, getTotalArraySize(AST, ResArrayTy));
- // assemble the constructor parameters
- CallArgList Args;
- createResourceCtorArgs(CGM, CD, ThisPtr, Range, Index, ArrayDecl->getName(),
- RBA, VkBinding, Args);
-
- // call the constructor
- CGF.EmitCXXConstructorCall(CD, Ctor_Complete, false, false, ThisAddress, Args,
- ValueSlot.mayOverlap(),
- ArraySubsExpr->getExprLoc(),
- ValueSlot.isSanitizerChecked());
-
- return CGF.MakeAddrLValue(TmpVar, ArraySubsExpr->getType(),
- AlignmentSource::Decl);
+ // if the result of the subscript operation is a single resource - call the
+ // constructor
+ if (ResultTy == ResourceTy) {
+ QualType ThisType = CD->getThisType()->getPointeeType();
+ llvm::Value *ThisPtr = CGF.getAsNaturalPointerTo(TmpVarAddress, ThisType);
+
+ // assemble the constructor parameters
----------------
llvm-beanz wrote:
```suggestion
// Assemble the constructor parameters.
```
https://github.com/llvm/llvm-project/pull/154248
More information about the cfe-commits
mailing list