Skip to content

Commit 693ae2b

Browse files
author
Erich Keane
committed
Revert "Correct behavior of integration header, now that enterField isn't here."
Temporarily rever the int-header changes to see if this fixes the validation machine issues I see. This reverts commit 90ae330. Conflicts: clang/lib/Sema/SemaSYCL.cpp
1 parent 1a96e20 commit 693ae2b

File tree

1 file changed

+22
-42
lines changed

1 file changed

+22
-42
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,27 +2176,10 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
21762176

21772177
void addParam(const FieldDecl *FD, QualType ArgTy,
21782178
SYCLIntegrationHeader::kernel_param_kind_t Kind) {
2179-
addParam(FD, ArgTy, Kind, IsArrayElement(FD, ArgTy));
2180-
}
2181-
void addParam(const FieldDecl *FD, QualType ArgTy,
2182-
SYCLIntegrationHeader::kernel_param_kind_t Kind,
2183-
bool IsArrayElem) {
21842179
uint64_t Size;
21852180
Size = SemaRef.getASTContext().getTypeSizeInChars(ArgTy).getQuantity();
2186-
uint64_t Offset = CurOffset;
2187-
if (!IsArrayElem)
2188-
Offset += offsetOf(FD);
21892181
Header.addParamDesc(Kind, static_cast<unsigned>(Size),
2190-
static_cast<unsigned>(Offset));
2191-
}
2192-
2193-
// Returns 'true' if the thing we're visiting (Based on the FD/QualType pair)
2194-
// is an element of an array. This will determine whether we do
2195-
// MemberExprBases in some cases or not, AND determines how we initialize
2196-
// values.
2197-
bool IsArrayElement(const FieldDecl *FD, QualType Ty) const {
2198-
SemaRef.getASTContext().hasSameType(FD->getType(), Ty);
2199-
return FD->getType() != Ty;
2182+
static_cast<unsigned>(CurOffset + offsetOf(FD)));
22002183
}
22012184

22022185
public:
@@ -2232,10 +2215,8 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
22322215
AccTy->getTemplateArgs()[1].getAsIntegral().getExtValue());
22332216
int Info = getAccessTarget(AccTy) | (Dims << 11);
22342217

2235-
uint64_t Offset = CurOffset;
2236-
if (!IsArrayElement(FD, FieldTy))
2237-
Offset += offsetOf(FD);
2238-
Header.addParamDesc(SYCLIntegrationHeader::kind_accessor, Info, Offset);
2218+
Header.addParamDesc(SYCLIntegrationHeader::kind_accessor, Info,
2219+
CurOffset + offsetOf(FD));
22392220
return true;
22402221
}
22412222

@@ -2249,8 +2230,7 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
22492230
const ParmVarDecl *SamplerArg = InitMethod->getParamDecl(0);
22502231
assert(SamplerArg && "sampler __init method must have sampler parameter");
22512232

2252-
addParam(FD, SamplerArg->getType(), SYCLIntegrationHeader::kind_sampler,
2253-
IsArrayElement(FD, FieldTy));
2233+
addParam(FD, SamplerArg->getType(), SYCLIntegrationHeader::kind_sampler);
22542234
return true;
22552235
}
22562236

@@ -2303,31 +2283,35 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
23032283
return true;
23042284
}
23052285

2306-
bool enterStream(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
2286+
bool enterStream(const CXXRecordDecl *, FieldDecl *FD, QualType) final {
23072287
++StructDepth;
2308-
if (!IsArrayElement(FD, Ty))
2309-
CurOffset += offsetOf(FD);
2288+
// TODO: Is this right?! I think this only needs to be incremented when we
2289+
// aren't in an array, otherwise 'enterArray's base offsets should handle
2290+
// this right. Otherwise an array of structs is going to be in the middle
2291+
// of nowhere.
2292+
CurOffset += offsetOf(FD);
23102293
return true;
23112294
}
23122295

2313-
bool leaveStream(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
2296+
bool leaveStream(const CXXRecordDecl *, FieldDecl *FD, QualType) final {
23142297
--StructDepth;
2315-
if (!IsArrayElement(FD, Ty))
2316-
CurOffset -= offsetOf(FD);
2298+
CurOffset -= offsetOf(FD);
23172299
return true;
23182300
}
23192301

2320-
bool enterStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
2302+
bool enterStruct(const CXXRecordDecl *, FieldDecl *FD, QualType) final {
23212303
++StructDepth;
2322-
if (!IsArrayElement(FD, Ty))
2323-
CurOffset += offsetOf(FD);
2304+
// TODO: Is this right?! I think this only needs to be incremented when we
2305+
// aren't in an array, otherwise 'enterArray's base offsets should handle
2306+
// this right. Otherwise an array of structs is going to be in the middle
2307+
// of nowhere.
2308+
CurOffset += offsetOf(FD);
23242309
return true;
23252310
}
23262311

2327-
bool leaveStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
2312+
bool leaveStruct(const CXXRecordDecl *, FieldDecl *FD, QualType) final {
23282313
--StructDepth;
2329-
if (!IsArrayElement(FD, Ty))
2330-
CurOffset -= offsetOf(FD);
2314+
CurOffset -= offsetOf(FD);
23312315
return true;
23322316
}
23332317

@@ -2343,12 +2327,8 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
23432327
return true;
23442328
}
23452329

2346-
bool enterArray(FieldDecl *FD, QualType ArrayTy, QualType) final {
2347-
uint64_t Offset = CurOffset;
2348-
if (!IsArrayElement(FD, ArrayTy))
2349-
Offset += offsetOf(FD);
2350-
2351-
ArrayBaseOffsets.push_back(Offset);
2330+
bool enterArray(FieldDecl *, QualType, QualType) final {
2331+
ArrayBaseOffsets.push_back(CurOffset);
23522332
return true;
23532333
}
23542334

0 commit comments

Comments
 (0)