Skip to content

[SYCL] Correction to constant-size array recognition. #2072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

rdeodhar
Copy link
Contributor

@rdeodhar rdeodhar commented Jul 8, 2020

Signed-off-by: rdeodhar [email protected]

Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I fully understand what is happening here. @erichkeane , could you please help with review?
Also, @rdeodhar, do you have a test for this change?

@Fznamznon Fznamznon requested a review from erichkeane July 9, 2020 07:42
@@ -797,7 +797,8 @@ static void VisitField(CXXRecordDecl *Owner, RangeTy &&Item, QualType ItemTy,
template <typename RangeTy, typename... Handlers>
static void VisitArrayElements(RangeTy Item, QualType FieldTy,
Handlers &... handlers) {
const ConstantArrayType *CAT = cast<ConstantArrayType>(FieldTy);
const ConstantArrayType *CAT =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of casts throughout this, you want to be doing getas. https://clang.llvm.org/doxygen/classclang_1_1Type.html#adae68e1f4c85ede2d36da45fbefc48a2

This will make sure you get the unqualified desugared type.

Copy link
Contributor

@elizabethandrews elizabethandrews Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if getAs works with ArrayType. While working on another patch I hit this assert -https://clang.llvm.org/doxygen/Type_8h_source.html#l07153

This was the code that failed:
if (const ConstantArrayType *CAT = FieldTy->getAs < ConstantArrayType > ( ))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I was just looking into that. Do you know if that will work when checking elaborated types? It wasn't clear to me by looking at definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? It does some canonicalization by calling getSplitDesugaredType, so that would imply to me that it removes typedef-type sugaring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I was looking at the wrong definition. I think it will work. This is what the comment says -

 If the type is an instance of the specified class,
 /// return the Type pointer for the underlying maximally pretty type.  This
 /// is a member of ASTContext because this may need to do some amount of
 /// canonicalization, e.g. to move type qualifiers into the element type.

return checkNotCopyableToKernel(FD, ET);
}
QualType FCT = FieldTy.getUnqualifiedType().getCanonicalType();
if (isa<ConstantArrayType>(FCT))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above suggestion allows you to do what you were doing above here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAsConstantArrayType is an ASTContext API. To use it, the Visitor functions will need to get the context from the handlers. The context is not currently available outside the handler classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it is really the only right way to do this... The way above loses context in a few ways that it shouldn't.

I think the visitor functions themselves should probably have a reference to Sema, and the handlers can capture what they need.

IMO, the visitors likely should all belong to a class. I'll submit a patch on which you can rebase in order to get this info.

@erichkeane
Copy link
Contributor

See #2081

@Fznamznon
Copy link
Contributor

This one is covered by #2082 . Can we close it?

@rdeodhar rdeodhar closed this Jul 10, 2020
@rdeodhar
Copy link
Contributor Author

Yes, this can be closed, and has been.

@rdeodhar rdeodhar deleted the akp6 branch July 10, 2020 16:23
jsji pushed a commit that referenced this pull request Jul 17, 2023
Compilation unit can be translated earlier, e.g. in `transEntryPoint()`.
We should save the translated LLVM value to be used further.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@803e528
jsji pushed a commit that referenced this pull request Aug 11, 2023
Compilation unit can be translated earlier, e.g. in `transEntryPoint()`.
We should save the translated LLVM value to be used further.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@803e528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants