@@ -1674,7 +1674,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1674
1674
// Contains a count of how many containers we're in. This is used by the
1675
1675
// pointer-struct-wrapping code to ensure that we don't try to wrap
1676
1676
// non-top-level pointers.
1677
- uint64_t ContainerDepth = 0 ;
1677
+ uint64_t StructDepth = 0 ;
1678
1678
1679
1679
// Using the statements/init expressions that we've created, this generates
1680
1680
// the kernel body compound stmt. CompoundStmt needs to know its number of
@@ -2018,7 +2018,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2018
2018
2019
2019
bool handlePointerType (FieldDecl *FD, QualType FieldTy) final {
2020
2020
Expr *PointerRef =
2021
- createPointerParamReferenceExpr (FD->getType (), ContainerDepth != 0 );
2021
+ createPointerParamReferenceExpr (FD->getType (), StructDepth != 0 );
2022
2022
addFieldInit (FD, FieldTy, PointerRef);
2023
2023
return true ;
2024
2024
}
@@ -2034,7 +2034,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2034
2034
}
2035
2035
2036
2036
bool enterStream (const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
2037
- ++ContainerDepth ;
2037
+ ++StructDepth ;
2038
2038
// Add a dummy init expression to catch the accessor initializers.
2039
2039
const auto *StreamDecl = Ty->getAsCXXRecordDecl ();
2040
2040
CollectionInitExprs.push_back (createInitListExpr (StreamDecl));
@@ -2044,7 +2044,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2044
2044
}
2045
2045
2046
2046
bool leaveStream (const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
2047
- --ContainerDepth ;
2047
+ --StructDepth ;
2048
2048
// Stream requires that its 'init' calls happen after its accessors init
2049
2049
// calls, so add them here instead.
2050
2050
const auto *StreamDecl = Ty->getAsCXXRecordDecl ();
@@ -2059,15 +2059,15 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2059
2059
}
2060
2060
2061
2061
bool enterStruct (const CXXRecordDecl *RD, FieldDecl *FD, QualType Ty) final {
2062
- ++ContainerDepth ;
2062
+ ++StructDepth ;
2063
2063
addCollectionInitListExpr (Ty->getAsCXXRecordDecl ());
2064
2064
2065
2065
addFieldMemberExpr (FD, Ty);
2066
2066
return true ;
2067
2067
}
2068
2068
2069
2069
bool leaveStruct (const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
2070
- --ContainerDepth ;
2070
+ --StructDepth ;
2071
2071
CollectionInitExprs.pop_back ();
2072
2072
2073
2073
removeFieldMemberExpr (FD, Ty);
@@ -2076,7 +2076,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2076
2076
2077
2077
bool enterStruct (const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
2078
2078
QualType) final {
2079
- ++ContainerDepth ;
2079
+ ++StructDepth ;
2080
2080
2081
2081
CXXCastPath BasePath;
2082
2082
QualType DerivedTy (RD->getTypeForDecl (), 0 );
@@ -2095,7 +2095,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2095
2095
2096
2096
bool leaveStruct (const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
2097
2097
QualType) final {
2098
- --ContainerDepth ;
2098
+ --StructDepth ;
2099
2099
MemberExprBases.pop_back ();
2100
2100
CollectionInitExprs.pop_back ();
2101
2101
return true ;
@@ -2250,6 +2250,11 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2250
2250
const ParmVarDecl *SamplerArg = InitMethod->getParamDecl (0 );
2251
2251
assert (SamplerArg && " sampler __init method must have sampler parameter" );
2252
2252
2253
+ // For samplers, we do some special work to ONLY initialize the first item
2254
+ // to the InitMethod as a performance improvement presumably, so the normal
2255
+ // offsetOf calculation wouldn't work correctly. Therefore, we need to call
2256
+ // a version of addParam where we calculate the offset based on the true
2257
+ // FieldDecl/FieldType pair, rather than the SampleArg type.
2253
2258
addParam (FD, SamplerArg->getType (), SYCLIntegrationHeader::kind_sampler,
2254
2259
offsetOf (FD, FieldTy));
2255
2260
return true ;
0 commit comments