@@ -5053,6 +5053,7 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
50535053 }
50545054
50555055 bool leaveStruct (const CXXRecordDecl *, ParmVarDecl *, QualType) final {
5056+ Header.setParentStruct (nullptr );
50565057 return true ;
50575058 }
50585059
@@ -7276,8 +7277,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
72767277 for (ParmVarDecl *Param : K.SyclKernel ->parameters ()) {
72777278 if (!Param->getType ()->isStructureType ())
72787279 continue ;
7279- const RecordDecl *Struct =
7280- Param->getType ()->getAsRecordDecl ();
7280+ const RecordDecl *Struct = Param->getType ()->getAsRecordDecl ();
72817281 QualType type = Param->getType ();
72827282 if (!S.getStructsWithSpecialType ().count (Struct) ||
72837283 visitedStructWithSpecialType.count (Struct))
@@ -7408,8 +7408,16 @@ void SYCLIntegrationHeader::addParamDesc(kernel_param_kind_t Kind, int Info,
74087408 PD.Kind = Kind;
74097409 PD.Info = Info;
74107410 PD.Offset = Offset;
7411- OffsetSizeInfo[ParentStruct].emplace_back (std::make_pair (Offset, Info));
7412- KindInfo[ParentStruct].emplace_back (Kind);
7411+ // If we are adding a free function kernel parameter that is a struct that
7412+ // contains a special type, a little more work needs to be done in order to
7413+ // help the runtime set the kernel arguments properly. Add the offset, size,
7414+ // and Kind information to the integration header for each field inside this
7415+ // struct. Also, verify that we are actually adding a field and not the struct
7416+ // itself by checking the Kind.
7417+ if (ParentStruct && Kind != kernel_param_kind_t ::kind_struct_with_special_type) {
7418+ OffsetSizeInfo[ParentStruct].emplace_back (std::make_pair (Offset, Info));
7419+ KindInfo[ParentStruct].emplace_back (Kind);
7420+ }
74137421}
74147422
74157423void SYCLIntegrationHeader::setParentStruct (ParmVarDecl *parent) {
0 commit comments