Skip to content

Commit 63c465b

Browse files
committed
[HLSL] Constant buffer layout struct update
- create structs with public fields instead of classes with private fields - add Packed attribute to prevent struct padding - use __cblayout_ prefix in name - filter out arrays of resources (bug fix) - don't create implicit initializer for constant buffer decls - update tests
1 parent cc97653 commit 63c465b

File tree

6 files changed

+121
-96
lines changed

6 files changed

+121
-96
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14183,6 +14183,13 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
1418314183
if (getLangOpts().OpenCL &&
1418414184
Var->getType().getAddressSpace() == LangAS::opencl_local)
1418514185
return;
14186+
14187+
// In HLSL, objects in the hlsl_constat address space are initialized
14188+
// externaly, so don't synthesize an implicit initializer.
14189+
if (getLangOpts().HLSL &&
14190+
Var->getType().getAddressSpace() == LangAS::hlsl_constant)
14191+
return;
14192+
1418614193
// C++03 [dcl.init]p9:
1418714194
// If no initializer is specified for an object, and the
1418814195
// object is of (possibly cv-qualified) non-POD class type (or

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,11 @@ static bool isZeroSizedArray(const ConstantArrayType *CAT) {
269269
return CAT != nullptr;
270270
}
271271

272-
// Returns true if the record type is an HLSL resource class
273-
static bool isResourceRecordType(const Type *Ty) {
272+
// Returns true if the record type is an HLSL resource class or an array of
273+
// HLSL resource classes
274+
static bool isResourceRecordTypeOrArrayOf(const Type *Ty) {
275+
while (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
276+
Ty = CAT->getArrayElementTypeNoTypeQual();
274277
return HLSLAttributedResourceType::findHandleTypeOnResource(Ty) != nullptr;
275278
}
276279

@@ -279,11 +282,10 @@ static bool isResourceRecordType(const Type *Ty) {
279282
// array, or a builtin intangible type. Returns false it is a valid leaf element
280283
// type or if it is a record type that needs to be inspected further.
281284
static bool isInvalidConstantBufferLeafElementType(const Type *Ty) {
282-
if (Ty->isRecordType()) {
283-
if (isResourceRecordType(Ty) || Ty->getAsCXXRecordDecl()->isEmpty())
284-
return true;
285-
return false;
286-
}
285+
if (isResourceRecordTypeOrArrayOf(Ty))
286+
return true;
287+
if (Ty->isRecordType())
288+
return Ty->getAsCXXRecordDecl()->isEmpty();
287289
if (Ty->isConstantArrayType() &&
288290
isZeroSizedArray(cast<ConstantArrayType>(Ty)))
289291
return true;
@@ -339,7 +341,7 @@ static IdentifierInfo *getHostLayoutStructName(Sema &S, NamedDecl *BaseDecl,
339341
ASTContext &AST = S.getASTContext();
340342

341343
IdentifierInfo *NameBaseII = BaseDecl->getIdentifier();
342-
llvm::SmallString<64> Name("__layout_");
344+
llvm::SmallString<64> Name("__cblayout_");
343345
if (NameBaseII) {
344346
Name.append(NameBaseII->getName());
345347
} else {
@@ -393,7 +395,7 @@ static FieldDecl *createFieldForHostLayoutStruct(Sema &S, const Type *Ty,
393395
auto *Field = FieldDecl::Create(AST, LayoutStruct, SourceLocation(),
394396
SourceLocation(), II, QT, TSI, nullptr, false,
395397
InClassInitStyle::ICIS_NoInit);
396-
Field->setAccess(AccessSpecifier::AS_private);
398+
Field->setAccess(AccessSpecifier::AS_public);
397399
return Field;
398400
}
399401

@@ -417,9 +419,11 @@ static CXXRecordDecl *createHostLayoutStruct(Sema &S,
417419
if (CXXRecordDecl *RD = findRecordDeclInContext(II, DC))
418420
return RD;
419421

420-
CXXRecordDecl *LS = CXXRecordDecl::Create(
421-
AST, TagDecl::TagKind::Class, DC, SourceLocation(), SourceLocation(), II);
422+
CXXRecordDecl *LS =
423+
CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, DC, SourceLocation(),
424+
SourceLocation(), II);
422425
LS->setImplicit(true);
426+
LS->addAttr(PackedAttr::CreateImplicit(AST));
423427
LS->startDefinition();
424428

425429
// copy base struct, create HLSL Buffer compatible version if needed
@@ -472,8 +476,9 @@ void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) {
472476
IdentifierInfo *II = getHostLayoutStructName(S, BufDecl, true);
473477

474478
CXXRecordDecl *LS =
475-
CXXRecordDecl::Create(AST, TagDecl::TagKind::Class, BufDecl,
479+
CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, BufDecl,
476480
SourceLocation(), SourceLocation(), II);
481+
LS->addAttr(PackedAttr::CreateImplicit(AST));
477482
LS->setImplicit(true);
478483
LS->startDefinition();
479484

clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,3 @@ cbuffer A {
2727
// AST-NEXT: TextComment {{.*}} Text=" CBuffer decl."
2828
// AST-NEXT: VarDecl {{.*}} a 'hlsl_constant float'
2929
// AST-NEXT: VarDecl {{.*}} b 'hlsl_constant int'
30-
// AST-NEXT: CXXRecordDecl {{.*}} implicit class __layout_A definition
31-
// AST: FieldDecl {{.*}} a 'float'
32-
// AST-NEXT: FieldDecl {{.*}} b 'int'

clang/test/AST/HLSL/cbuffer.hlsl

Lines changed: 80 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -48,94 +48,104 @@ struct TwoFloats {
4848
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
4949
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
5050
cbuffer CB {
51-
// CHECK: VarDecl {{.*}} col:9 used a1 'hlsl_constant float'
51+
// CHECK: VarDecl {{.*}} used a1 'hlsl_constant float'
5252
float a1;
53-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB definition
54-
// CHECK: FieldDecl {{.*}} a1 'float'
53+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB definition
54+
// CHECK: PackedAttr
55+
// CHECK-NEXT: FieldDecl {{.*}} a1 'float'
5556
}
56-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_CB), "");
57+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_CB), "");
5758

5859
// Check that buffer layout struct does not include resources or empty types
59-
// CHECK: HLSLBufferDecl {{.*}} line:62:9 cbuffer CB
60+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
6061
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
6162
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
6263
cbuffer CB {
63-
// CHECK: VarDecl {{.*}} col:9 used a2 'hlsl_constant float'
64+
// CHECK: VarDecl {{.*}} used a2 'hlsl_constant float'
6465
float a2;
65-
// CHECK: VarDecl {{.*}} col:19 b2 'RWBuffer<float>':'hlsl::RWBuffer<float>'
66+
// CHECK: VarDecl {{.*}} b2 'RWBuffer<float>':'hlsl::RWBuffer<float>'
6667
RWBuffer<float> b2;
67-
// CHECK: VarDecl {{.*}} col:15 c2 'EmptyStruct'
68+
// CHECK: VarDecl {{.*}} c2 'EmptyStruct'
6869
EmptyStruct c2;
69-
// CHECK: VarDecl {{.*}} col:9 d2 'float[0]'
70+
// CHECK: VarDecl {{.*}} d2 'float[0]'
7071
float d2[0];
71-
// CHECK: VarDecl {{.*}} col:9 e2 'hlsl_constant float'
72+
// CHECK: VarDecl {{.*}} f2 'RWBuffer<float>[2]'
73+
RWBuffer<float> f2[2];
74+
// CHECK: VarDecl {{.*}} e2 'hlsl_constant float'
7275
float e2;
73-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_1 definition
74-
// CHECK: FieldDecl {{.*}} a2 'float'
76+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_1 definition
77+
// CHECK: PackedAttr
78+
// CHECK-NEXT: FieldDecl {{.*}} a2 'float'
7579
// CHECK-NEXT: FieldDecl {{.*}} e2 'float'
7680
}
77-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_1), "");
81+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_1), "");
7882

7983
// Check that layout struct is created for B and the empty struct C is removed
80-
// CHECK: HLSLBufferDecl {{.*}} line:83:9 cbuffer CB
84+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
8185
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
8286
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
8387
cbuffer CB {
84-
// CHECK: VarDecl {{.*}} col:5 used s1 'hlsl_constant A'
88+
// CHECK: VarDecl {{.*}} used s1 'hlsl_constant A'
8589
A s1;
86-
// CHECK: VarDecl {{.*}} col:5 s2 'hlsl_constant B'
90+
// CHECK: VarDecl {{.*}} s2 'hlsl_constant B'
8791
B s2;
88-
// CHECK: VarDecl {{.*}} col:12 s3 'CTypedef':'C'
92+
// CHECK: VarDecl {{.*}} s3 'CTypedef':'C'
8993
CTypedef s3;
90-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_2 definition
91-
// CHECK: FieldDecl {{.*}} s1 'A'
92-
// CHECK: FieldDecl {{.*}} s2 '__layout_B'
94+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_2 definition
95+
// CHECK: PackedAttr
96+
// CHECK-NEXT: FieldDecl {{.*}} s1 'A'
97+
// CHECK-NEXT: FieldDecl {{.*}} s2 '__cblayout_B'
9398
}
94-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_B definition
95-
// CHECK: FieldDecl {{.*}} a 'float'
99+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_B definition
100+
// CHECK: PackedAttr
101+
// CHECK-NEXT: FieldDecl {{.*}} a 'float'
96102

97-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_B), "");
98-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_2), "");
103+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_B), "");
104+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_2), "");
99105

100106
// check that layout struct is created for D because of its base struct
101-
// CHECK: HLSLBufferDecl {{.*}} line:104:9 cbuffer CB
107+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
102108
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
103109
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
104110
cbuffer CB {
105111
// CHECK: VarDecl {{.*}} s4 'hlsl_constant D'
106112
D s4;
107-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_3 definition
108-
// CHECK: FieldDecl {{.*}} s4 '__layout_D'
113+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_3 definition
114+
// CHECK: PackedAttr
115+
// CHECK-NEXT: FieldDecl {{.*}} s4 '__cblayout_D'
109116
}
110-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_D definition
111-
// CHECK: public '__layout_B'
112-
// CHECK: FieldDecl {{.*}} b 'float'
113-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_D), "");
114-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_3), "");
117+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_D definition
118+
// CHECK: public '__cblayout_B'
119+
// CHECK: PackedAttr
120+
// CHECK-NEXT: FieldDecl {{.*}} b 'float'
121+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_D), "");
122+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_3), "");
115123

116124
// check that layout struct is created for E because because its base struct
117125
// is empty and should be eliminated, and BTypedef should reuse the previously
118-
// defined '__layout_B'
119-
// CHECK: HLSLBufferDecl {{.*}} line:122:9 cbuffer CB
126+
// defined '__cblayout_B'
127+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
120128
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
121129
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
122130
cbuffer CB {
123131
// CHECK: VarDecl {{.*}} s5 'hlsl_constant E'
124132
E s5;
125133
// CHECK: VarDecl {{.*}} s6 'hlsl_constant BTypedef':'hlsl_constant B'
126134
BTypedef s6;
127-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_4 definition
128-
// CHECK: FieldDecl {{.*}} s5 '__layout_E'
129-
// CHECK: FieldDecl {{.*}} s6 '__layout_B'
135+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_4 definition
136+
// CHECK: PackedAttr
137+
// CHECK-NEXT: FieldDecl {{.*}} s5 '__cblayout_E'
138+
// CHECK-NEXT: FieldDecl {{.*}} s6 '__cblayout_B'
130139
}
131-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_E definition
132-
// CHECK: FieldDecl {{.*}} c 'float'
133-
// CHECK-NOT: CXXRecordDecl {{.*}} class __layout_B definition
134-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_E), "");
135-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_4), "");
140+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_E definition
141+
// CHECK: PackedAttr
142+
// CHECK-NEXT: FieldDecl {{.*}} c 'float'
143+
// CHECK-NOT: CXXRecordDecl {{.*}} struct __cblayout_B definition
144+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_E), "");
145+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_4), "");
136146

137147
// check that this produces empty layout struct
138-
// CHECK: HLSLBufferDecl {{.*}} line:141:9 cbuffer CB
148+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
139149
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
140150
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
141151
cbuffer CB {
@@ -149,27 +159,30 @@ cbuffer CB {
149159
RWBuffer<float> Buf;
150160
// CHECK: VarDecl {{.*}} ea 'EmptyArrayTypedef':'float[10][0]'
151161
EmptyArrayTypedef ea;
152-
// CHECK: CXXRecordDecl {{.*}} implicit class __layout_CB_5 definition
162+
// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_CB_5 definition
163+
// CHECK: PackedAttr
153164
// CHECK-NOT: FieldDecl
154165
}
155166

156167
// check host layout struct with compatible base struct
157-
// CHECK: HLSLBufferDecl {{.*}} line:160:9 cbuffer CB
168+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
158169
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
159170
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
160171
cbuffer CB {
161172
// CHECK: VarDecl {{.*}} s8 'hlsl_constant F'
162173
F s8;
163-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_6 definition
164-
// CHECK: FieldDecl {{.*}} s8 '__layout_F'
174+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_6 definition
175+
// CHECK: PackedAttr
176+
// CHECK-NEXT: FieldDecl {{.*}} s8 '__cblayout_F'
165177
}
166-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_F definition
167-
// CHECK: public 'A'
168-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_F), "");
169-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_CB_6), "");
178+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_F definition
179+
// CHECK: public 'A'
180+
// CHECK: PackedAttr
181+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_F), "");
182+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_CB_6), "");
170183

171184
// anonymous structs
172-
// CHECK: HLSLBufferDecl {{.*}} line:175:9 cbuffer CB
185+
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB
173186
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
174187
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer
175188
cbuffer CB {
@@ -182,26 +195,29 @@ cbuffer CB {
182195
// CHECK: FieldDecl {{.*}} f 'RWBuffer<float>':'hlsl::RWBuffer<float>'
183196
RWBuffer<float> f;
184197
} s9;
185-
// CHECK: VarDecl {{.*}} s9 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:177:3
198+
// CHECK: VarDecl {{.*}} s9 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:[[# @LINE - 8]]:3
186199
// CHECK: CXXRecordDecl {{.*}} struct definition
187200
struct {
188201
// CHECK: FieldDecl {{.*}} g 'float'
189202
float g;
190203
// CHECK: FieldDecl {{.*}} f 'RWBuffer<float>':'hlsl::RWBuffer<float>'
191204
RWBuffer<float> f;
192205
} s10;
193-
// CHECK: VarDecl {{.*}} s10 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:187:3
194-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon definition
195-
// CHECK: FieldDecl {{.*}} e 'float'
196-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon_1 definition
197-
// CHECK: FieldDecl {{.*}} g 'float'
198-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_7 definition
199-
// CHECK: FieldDecl {{.*}} s9 '__layout_anon'
200-
// CHECK: FieldDecl {{.*}} s10 '__layout_anon_1'
206+
// CHECK: VarDecl {{.*}} s10 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:[[# @LINE - 6]]:3
207+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_anon definition
208+
// CHECK: PackedAttr
209+
// CHECK-NEXT: FieldDecl {{.*}} e 'float'
210+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_anon_1 definition
211+
// CHECK: PackedAttr
212+
// CHECK-NEXT: FieldDecl {{.*}} g 'float'
213+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_7 definition
214+
// CHECK: PackedAttr
215+
// CHECK-NEXT: FieldDecl {{.*}} s9 '__cblayout_anon'
216+
// CHECK-NEXT: FieldDecl {{.*}} s10 '__cblayout_anon_1'
201217
}
202-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_anon), "");
203-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_anon_1), "");
204-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_7), "");
218+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_anon), "");
219+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_anon_1), "");
220+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_7), "");
205221

206222
// Add uses for the constant buffer declarations so they are not optimized away
207223
export float foo() {

clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace NS1 {
1919
int b;
2020
EmptyStruct es;
2121
};
22-
// CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition
22+
// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition
2323
// CHECK: FieldDecl {{.*}} b 'int'
2424
};
25-
// CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition
25+
// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition
2626
// CHECK: FieldDecl {{.*}} a 'float'
2727
}
2828

@@ -41,20 +41,20 @@ cbuffer CB1 {
4141
NS1::Foo foo2;
4242
// CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo'
4343
NS1::Bar::Foo foo3;
44-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB1 definition
45-
// CHECK: FieldDecl {{.*}} foo1 '__layout_Foo'
46-
// CHECK: FieldDecl {{.*}} foo2 'NS1::__layout_Foo'
47-
// CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__layout_Foo'
44+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB1 definition
45+
// CHECK: FieldDecl {{.*}} foo1 '__cblayout_Foo'
46+
// CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo'
47+
// CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo'
4848
}
49-
// CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition
49+
// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition
5050
// CHECK: FieldDecl {{.*}} c 'double'
5151

5252
struct CB1ExpectedShape {
5353
double a1;
5454
float a2;
5555
int a;
5656
};
57-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __layout_CB1), "");
57+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __cblayout_CB1), "");
5858

5959
namespace NS2 {
6060
struct Foo {
@@ -73,13 +73,13 @@ namespace NS2 {
7373
NS1::Foo foo2;
7474
// CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo'
7575
NS1::Bar::Foo foo3;
76-
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB2 definition
77-
// CHECK: FieldDecl {{.*}} foo0 '__layout_Foo'
78-
// CHECK: FieldDecl {{.*}} foo1 'NS2::__layout_Foo'
79-
// CHECK: FieldDecl {{.*}} foo2 'NS1::__layout_Foo'
80-
// CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__layout_Foo'
76+
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB2 definition
77+
// CHECK: FieldDecl {{.*}} foo0 '__cblayout_Foo'
78+
// CHECK: FieldDecl {{.*}} foo1 'NS2::__cblayout_Foo'
79+
// CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo'
80+
// CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo'
8181
}
82-
// CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition
82+
// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition
8383
// CHECK: FieldDecl {{.*}} d 'float[4]'
8484
}
8585

@@ -89,7 +89,7 @@ struct CB2ExpectedShape {
8989
float a2;
9090
int a;
9191
};
92-
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB2ExpectedShape, NS2::__layout_CB2), "");
92+
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB2ExpectedShape, NS2::__cblayout_CB2), "");
9393

9494
// Add uses for the constant buffer declarations so they are not optimized away
9595
// CHECK: ExportDecl

0 commit comments

Comments
 (0)