Skip to content

Commit abb62b6

Browse files
authored
[HLSL] Codegen for indexing of sub-arrays of multi-dimensional resource arrays (#154248)
Adds support for accessing sub-arrays from fixed-size multi-dimensional global resource arrays. Enables indexing into globally scoped, fixed-size resource arrays that have multiple dimensions when the result is a smaller resource array. For example: ``` RWBuffer<float> GlobalArray[4][2]; void main() { RWBuffer<float> SubArray[2] = GlobalArray[3]; ... } ``` The initialization logic is handled during codegen when the ArraySubscriptExpr AST node is processed. When a global resource array is indexed and the result type is a sub-array of the larger array, a local array of the resource type is created and all elements in the array are initialized with a constructor call for the corresponding resource record type and binding. Closes #145426
1 parent 772cb84 commit abb62b6

File tree

3 files changed

+283
-34
lines changed

3 files changed

+283
-34
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 112 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CodeGenModule.h"
1919
#include "TargetInfo.h"
2020
#include "clang/AST/ASTContext.h"
21+
#include "clang/AST/Attrs.inc"
2122
#include "clang/AST/Decl.h"
2223
#include "clang/AST/RecursiveASTVisitor.h"
2324
#include "clang/AST/Type.h"
@@ -36,6 +37,7 @@
3637
#include "llvm/Support/Alignment.h"
3738
#include "llvm/Support/ErrorHandling.h"
3839
#include "llvm/Support/FormatVariadic.h"
40+
#include <cstdint>
3941

4042
using namespace clang;
4143
using namespace CodeGen;
@@ -190,6 +192,70 @@ static void createResourceCtorArgs(CodeGenModule &CGM, CXXConstructorDecl *CD,
190192
Args.add(RValue::get(NameStr), AST.getPointerType(AST.CharTy.withConst()));
191193
}
192194

195+
// Initializes local resource array variable. For multi-dimensional arrays it
196+
// calls itself recursively to initialize its sub-arrays. The Index used in the
197+
// resource constructor calls will begin at StartIndex and will be incremented
198+
// for each array element. The last used resource Index is returned to the
199+
// caller.
200+
static Value *initializeLocalResourceArray(
201+
CodeGenFunction &CGF, AggValueSlot &ValueSlot,
202+
const ConstantArrayType *ArrayTy, CXXConstructorDecl *CD,
203+
llvm::Value *Range, llvm::Value *StartIndex, StringRef ResourceName,
204+
HLSLResourceBindingAttr *RBA, HLSLVkBindingAttr *VkBinding,
205+
ArrayRef<llvm::Value *> PrevGEPIndices, SourceLocation ArraySubsExprLoc) {
206+
207+
llvm::IntegerType *IntTy = CGF.CGM.IntTy;
208+
llvm::Value *Index = StartIndex;
209+
llvm::Value *One = llvm::ConstantInt::get(IntTy, 1);
210+
const uint64_t ArraySize = ArrayTy->getSExtSize();
211+
QualType ElemType = ArrayTy->getElementType();
212+
Address TmpArrayAddr = ValueSlot.getAddress();
213+
214+
// Add additional index to the getelementptr call indices.
215+
// This index will be updated for each array element in the loops below.
216+
SmallVector<llvm::Value *> GEPIndices(PrevGEPIndices);
217+
GEPIndices.push_back(llvm::ConstantInt::get(IntTy, 0));
218+
219+
// For array of arrays, recursively initialize the sub-arrays.
220+
if (ElemType->isArrayType()) {
221+
const ConstantArrayType *SubArrayTy = cast<ConstantArrayType>(ElemType);
222+
for (uint64_t I = 0; I < ArraySize; I++) {
223+
if (I > 0) {
224+
Index = CGF.Builder.CreateAdd(Index, One);
225+
GEPIndices.back() = llvm::ConstantInt::get(IntTy, I);
226+
}
227+
Index = initializeLocalResourceArray(
228+
CGF, ValueSlot, SubArrayTy, CD, Range, Index, ResourceName, RBA,
229+
VkBinding, GEPIndices, ArraySubsExprLoc);
230+
}
231+
return Index;
232+
}
233+
234+
// For array of resources, initialize each resource in the array.
235+
llvm::Type *Ty = CGF.ConvertTypeForMem(ElemType);
236+
CharUnits ElemSize = CD->getASTContext().getTypeSizeInChars(ElemType);
237+
CharUnits Align =
238+
TmpArrayAddr.getAlignment().alignmentOfArrayElement(ElemSize);
239+
240+
for (uint64_t I = 0; I < ArraySize; I++) {
241+
if (I > 0) {
242+
Index = CGF.Builder.CreateAdd(Index, One);
243+
GEPIndices.back() = llvm::ConstantInt::get(IntTy, I);
244+
}
245+
Address ThisAddress =
246+
CGF.Builder.CreateGEP(TmpArrayAddr, GEPIndices, Ty, Align);
247+
llvm::Value *ThisPtr = CGF.getAsNaturalPointerTo(ThisAddress, ElemType);
248+
249+
CallArgList Args;
250+
createResourceCtorArgs(CGF.CGM, CD, ThisPtr, Range, Index, ResourceName,
251+
RBA, VkBinding, Args);
252+
CGF.EmitCXXConstructorCall(CD, Ctor_Complete, false, false, ThisAddress,
253+
Args, ValueSlot.mayOverlap(), ArraySubsExprLoc,
254+
ValueSlot.isSanitizerChecked());
255+
}
256+
return Index;
257+
}
258+
193259
} // namespace
194260

195261
llvm::Type *
@@ -796,16 +862,14 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
796862
ArraySubsExpr->getType()->isHLSLResourceRecordArray() &&
797863
"expected resource array subscript expression");
798864

799-
// let clang codegen handle local resource array subscripts
800-
const VarDecl *ArrayDecl = dyn_cast<VarDecl>(getArrayDecl(ArraySubsExpr));
865+
// Let clang codegen handle local resource array subscripts,
866+
// or when the subscript references on opaque expression (as part of
867+
// ArrayInitLoopExpr AST node).
868+
const VarDecl *ArrayDecl =
869+
dyn_cast_or_null<VarDecl>(getArrayDecl(ArraySubsExpr));
801870
if (!ArrayDecl || !ArrayDecl->hasGlobalStorage())
802871
return std::nullopt;
803872

804-
if (ArraySubsExpr->getType()->isArrayType())
805-
// FIXME: this is not yet implemented (llvm/llvm-project#145426)
806-
llvm_unreachable(
807-
"indexing of sub-arrays of multidimensional arrays not supported yet");
808-
809873
// get the resource array type
810874
ASTContext &AST = ArrayDecl->getASTContext();
811875
const Type *ResArrayTy = ArrayDecl->getType().getTypePtr();
@@ -826,26 +890,30 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
826890
CGM.IntTy, AST.getConstantArrayElementCount(ArrayTy));
827891
SubIndex = CGF.Builder.CreateMul(SubIndex, Multiplier);
828892
}
829-
830893
Index = Index ? CGF.Builder.CreateAdd(Index, SubIndex) : SubIndex;
831894
ASE = dyn_cast<ArraySubscriptExpr>(ASE->getBase()->IgnoreParenImpCasts());
832895
}
833896

834-
// find binding info for the resource array (for implicit binding
835-
// an HLSLResourceBindingAttr should have been added by SemaHLSL)
836-
QualType ResourceTy = ArraySubsExpr->getType();
897+
// Find binding info for the resource array. For implicit binding
898+
// an HLSLResourceBindingAttr should have been added by SemaHLSL.
837899
HLSLVkBindingAttr *VkBinding = ArrayDecl->getAttr<HLSLVkBindingAttr>();
838900
HLSLResourceBindingAttr *RBA = ArrayDecl->getAttr<HLSLResourceBindingAttr>();
839901
assert((VkBinding || RBA) && "resource array must have a binding attribute");
840902

841-
// lookup the resource class constructor based on the resource type and
842-
// binding
903+
// Find the individual resource type.
904+
QualType ResultTy = ArraySubsExpr->getType();
905+
QualType ResourceTy =
906+
ResultTy->isArrayType() ? AST.getBaseElementType(ResultTy) : ResultTy;
907+
908+
// Lookup the resource class constructor based on the resource type and
909+
// binding.
843910
CXXConstructorDecl *CD = findResourceConstructorDecl(
844911
AST, ResourceTy, VkBinding || RBA->hasRegisterSlot());
845912

846-
// create a temporary variable for the resource class instance (we need to
847-
// return an LValue)
848-
RawAddress TmpVar = CGF.CreateMemTemp(ResourceTy);
913+
// Create a temporary variable for the result, which is either going
914+
// to be a single resource instance or a local array of resources (we need to
915+
// return an LValue).
916+
RawAddress TmpVar = CGF.CreateMemTemp(ResultTy);
849917
if (CGF.EmitLifetimeStart(TmpVar.getPointer()))
850918
CGF.pushFullExprCleanup<CodeGenFunction::CallLifetimeEnd>(
851919
NormalEHLifetimeMarker, TmpVar);
@@ -854,26 +922,36 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
854922
TmpVar, Qualifiers(), AggValueSlot::IsDestructed_t(true),
855923
AggValueSlot::DoesNotNeedGCBarriers, AggValueSlot::IsAliased_t(false),
856924
AggValueSlot::DoesNotOverlap);
925+
Address TmpVarAddress = ValueSlot.getAddress();
857926

858-
Address ThisAddress = ValueSlot.getAddress();
859-
llvm::Value *ThisPtr = CGF.getAsNaturalPointerTo(
860-
ThisAddress, CD->getThisType()->getPointeeType());
861-
862-
// get total array size (= range size)
927+
// Calculate total array size (= range size).
863928
llvm::Value *Range =
864929
llvm::ConstantInt::get(CGM.IntTy, getTotalArraySize(AST, ResArrayTy));
865930

866-
// assemble the constructor parameters
867-
CallArgList Args;
868-
createResourceCtorArgs(CGM, CD, ThisPtr, Range, Index, ArrayDecl->getName(),
869-
RBA, VkBinding, Args);
870-
871-
// call the constructor
872-
CGF.EmitCXXConstructorCall(CD, Ctor_Complete, false, false, ThisAddress, Args,
873-
ValueSlot.mayOverlap(),
874-
ArraySubsExpr->getExprLoc(),
875-
ValueSlot.isSanitizerChecked());
876-
877-
return CGF.MakeAddrLValue(TmpVar, ArraySubsExpr->getType(),
878-
AlignmentSource::Decl);
931+
// If the result of the subscript operation is a single resource, call the
932+
// constructor.
933+
if (ResultTy == ResourceTy) {
934+
QualType ThisType = CD->getThisType()->getPointeeType();
935+
llvm::Value *ThisPtr = CGF.getAsNaturalPointerTo(TmpVarAddress, ThisType);
936+
937+
// Assemble the constructor parameters.
938+
CallArgList Args;
939+
createResourceCtorArgs(CGM, CD, ThisPtr, Range, Index, ArrayDecl->getName(),
940+
RBA, VkBinding, Args);
941+
// Call the constructor.
942+
CGF.EmitCXXConstructorCall(CD, Ctor_Complete, false, false, TmpVarAddress,
943+
Args, ValueSlot.mayOverlap(),
944+
ArraySubsExpr->getExprLoc(),
945+
ValueSlot.isSanitizerChecked());
946+
} else {
947+
// The result of the subscript operation is a local resource array which
948+
// needs to be initialized.
949+
const ConstantArrayType *ArrayTy =
950+
cast<ConstantArrayType>(ResultTy.getTypePtr());
951+
initializeLocalResourceArray(CGF, ValueSlot, ArrayTy, CD, Range, Index,
952+
ArrayDecl->getName(), RBA, VkBinding,
953+
{llvm::ConstantInt::get(CGM.IntTy, 0)},
954+
ArraySubsExpr->getExprLoc());
955+
}
956+
return CGF.MakeAddrLValue(TmpVar, ResultTy, AlignmentSource::Decl);
879957
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -finclude-default-header \
2+
// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
3+
4+
// CHECK: @[[BufA:.*]] = private unnamed_addr constant [2 x i8] c"A\00", align 1
5+
6+
RWBuffer<float> A[5][4][3][2] : register(u10, space2);
7+
RWStructuredBuffer<float> Out;
8+
9+
// CHECK: define {{.*}} float @_Z3fooA3_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([3 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %Arr)
10+
// CHECK-NEXT: entry:
11+
float foo(RWBuffer<float> Arr[3][2]) {
12+
// CHECK-NEXT: %[[Arr_1_Ptr:.*]] = getelementptr inbounds [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %Arr, i32 0, i32 1
13+
// CHECK-NEXT: %[[Arr_1_0_Ptr:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %[[Arr_1_Ptr]], i32 0, i32 0
14+
// CHECK-NEXT: %[[BufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl8RWBufferIfEixEj(ptr {{.*}} %[[Arr_1_0_Ptr]], i32 noundef 0)
15+
// CHECK-NEXT: %[[Value:.*]] = load float, ptr %[[BufPtr]], align 4
16+
// CHECK-NEXT: ret float %[[Value]]
17+
return Arr[1][0][0];
18+
}
19+
20+
// NOTE:
21+
// - _ZN4hlsl8RWBufferIfEC1EjjijPKc is the constructor call for explicit binding
22+
// (has "jjij" in the mangled name) and the arguments are (register, space, range_size, index, name).
23+
// - _ZN4hlsl8RWBufferIfEixEj is the subscript operator for RWBuffer<float>
24+
25+
// CHECK: define internal void @_Z4mainj(i32 noundef %GI)
26+
// CHECK-NEXT: entry:
27+
// CHECK-NEXT: %[[GI_alloca:.*]] = alloca i32, align 4
28+
// CHECK-NEXT: %Sub = alloca [3 x [2 x %"class.hlsl::RWBuffer"]], align 4
29+
// CHECK-NEXT: %[[Tmp0:.*]] = alloca [3 x [2 x %"class.hlsl::RWBuffer"]], align 4
30+
// CHECK-NEXT: %a = alloca float, align 4
31+
// CHECK-NEXT: %b = alloca float, align 4
32+
// CHECK-NEXT: %[[Tmp1:.*]] = alloca [3 x [2 x %"class.hlsl::RWBuffer"]], align 4
33+
// CHECK-NEXT: %[[Tmp2:.*]] = alloca [3 x [2 x %"class.hlsl::RWBuffer"]], align 4
34+
// CHECK-NEXT: store i32 %GI, ptr %[[GI_alloca]], align 4
35+
[numthreads(4,1,1)]
36+
void main(uint GI : SV_GroupThreadID) {
37+
// Codegen for "A[4][1]" - create local array [[Tmp0]] of size 3 x 2 and initialize
38+
// each element by a call to the resource constructor
39+
// The resource index for A[4][1][0][0] is 102 = 4 * (4 * 3 * 2) + 1 * (3 * 2)
40+
// (index in the resource array as if it was flattened)
41+
// CHECK-NEXT: %[[Ptr_Tmp0_0_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 0, i32 0
42+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_0_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 102, ptr noundef @[[BufA]])
43+
// CHECK-NEXT: %[[Ptr_Tmp0_0_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 0, i32 1
44+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_0_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 103, ptr noundef @[[BufA]])
45+
// CHECK-NEXT: %[[Ptr_Tmp0_1_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 1, i32 0
46+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_1_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 104, ptr noundef @[[BufA]])
47+
// CHECK-NEXT: %[[Ptr_Tmp0_1_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 1, i32 1
48+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_1_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 105, ptr noundef @[[BufA]])
49+
// CHECK-NEXT: %[[Ptr_Tmp0_2_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 2, i32 0
50+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_2_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 106, ptr noundef @[[BufA]])
51+
// CHECK-NEXT: %[[Ptr_Tmp0_2_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %tmp, i32 0, i32 2, i32 1
52+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp0_2_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef 107, ptr noundef @[[BufA]])
53+
// After this Tmp0 values are copied to %Sub using the standard array loop initializaion
54+
// (generated from ArrayInitLoopExpr AST node)
55+
RWBuffer<float> Sub[3][2] = A[4][1];
56+
57+
// CHECK: %[[Ptr_Sub_2:.*]] = getelementptr inbounds [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %Sub, i32 0, i32 2
58+
// CHECK: %[[Ptr_Sub_2_1:.*]] = getelementptr inbounds [2 x %"class.hlsl::RWBuffer"], ptr %[[Ptr_Sub_2]], i32 0, i32 1
59+
// CHECK-NEXT: %[[BufPtr:.*]] = call {{.*}} ptr @_ZN4hlsl8RWBufferIfEixEj(ptr {{.*}} %[[Ptr_Sub_2_1]], i32 noundef 0)
60+
// CHECK-NEXT: %[[Sub_2_1_0_Value:.*]] = load float, ptr %[[BufPtr]], align 4
61+
// CHECK-NEXT: store float %[[Sub_2_1_0_Value]], ptr %a, align 4
62+
float a = Sub[2][1][0];
63+
64+
// Codegen for "foo(A[2][GI])" - create local array [[Tmp2]] of size 3 x 2 and initialize
65+
// each element by a call to the resource constructor with dynamic index, and then
66+
// copy-in the array as an argument of "foo"
67+
68+
// Calculate the resource index for A[2][GI][0][0] (index in the resource array as if it was flattened)
69+
// The index is 2 * (4 * 3 * 2) + GI * (3 * 2) = 48 + GI * 6
70+
// CHECK: %[[GI:.*]] = load i32, ptr %[[GI_alloca]], align 4
71+
// CHECK-NEXT: %[[Index_A_2_GI_Tmp:.*]] = mul i32 %[[GI]], 6
72+
// CHECK-NEXT: %[[Index_A_2_GI_0_0:.*]] = add i32 %[[Index_A_2_GI_Tmp]], 48
73+
74+
// A[2][GI][0][0]
75+
// CHECK-NEXT: %[[Ptr_Tmp2_0_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 0, i32 0
76+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_0_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_0_0]], ptr noundef @[[BufA]])
77+
78+
// A[2][GI][0][1]
79+
// CHECK-NEXT: %[[Index_A_2_GI_0_1:.*]] = add i32 %[[Index_A_2_GI_0_0]], 1
80+
// CHECK-NEXT: %[[Ptr_Tmp2_0_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 0, i32 1
81+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_0_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_0_1]], ptr noundef @[[BufA]])
82+
83+
// A[2][GI][1][0]
84+
// CHECK-NEXT: %[[Index_A_2_GI_1_0:.*]] = add i32 %[[Index_A_2_GI_0_1]], 1
85+
// CHECK-NEXT: %[[Ptr_Tmp2_1_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 1, i32 0
86+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_1_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_1_0]], ptr noundef @[[BufA]])
87+
88+
// A[2][GI][1][1]
89+
// CHECK-NEXT: %[[Index_A_2_GI_1_1:.*]] = add i32 %[[Index_A_2_GI_1_0]], 1
90+
// CHECK-NEXT: %[[Ptr_Tmp2_1_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 1, i32 1
91+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_1_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_1_1]], ptr noundef @[[BufA]])
92+
93+
// A[2][GI][2][0]
94+
// CHECK-NEXT: %[[Index_A_2_GI_2_0:.*]] = add i32 %[[Index_A_2_GI_1_1]], 1
95+
// CHECK-NEXT: %[[Ptr_Tmp2_2_0:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 2, i32 0
96+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_2_0]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_2_0]], ptr noundef @[[BufA]])
97+
98+
// A[2][GI][2][1]
99+
// CHECK-NEXT: %[[Index_A_2_GI_2_1:.*]] = add i32 %[[Index_A_2_GI_2_0]], 1
100+
// CHECK-NEXT: %[[Ptr_Tmp2_2_1:.*]] = getelementptr [3 x [2 x %"class.hlsl::RWBuffer"]], ptr %[[Tmp2]], i32 0, i32 2, i32 1
101+
// CHECK-NEXT: call void @_ZN4hlsl8RWBufferIfEC1EjjijPKc(ptr {{.*}} %[[Ptr_Tmp2_2_1]], i32 noundef 10, i32 noundef 2, i32 noundef 120, i32 noundef %[[Index_A_2_GI_2_1]], ptr noundef @[[BufA]])
102+
103+
// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %[[Tmp1]], ptr align 4 %[[Tmp2]], i32 24, i1 false)
104+
// CHECK-NEXT: %[[FooReturned:.*]] = call {{.*}} float @_Z3fooA3_A2_N4hlsl8RWBufferIfEE(ptr noundef byval([3 x [2 x %"class.hlsl::RWBuffer"]]) align 4 %[[Tmp1]])
105+
// CHECK-NEXT: store float %[[FooReturned]], ptr %b, align 4
106+
float b = foo(A[2][GI]);
107+
108+
Out[0] = a + b;
109+
}

0 commit comments

Comments
 (0)