-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Fix bug with constexpr recursion #4257
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
Conversation
The compiler hits the assert when DeclStmt constains both TypeDecl and VarDecl (case added to lit test). This patch removes code added to handle constexpr variables, in call graph creation. This code is not technically not required since the AST visitor in SemaSYCL, will handle non-traversal of nodes representing constexpr variables. Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Ideally, we could avoid creating the subgraphs for constexpr nodes as the removed code attempted to do. I was however unable to figure out how to continue visiting Decl nodes which did not represent constexpr variables, since statement visitors handle only statements and expressions. I tried visiting initializers of these variables instead but ran into issues there as well. I can look into this in more detail if reviewers prefer not creating the subgraph. |
What does the DeclStmt visit call by default? It should eventually call a VarDecl or something, right? Alternatively, we might have to loop through the decl-stmt children to find which are constexpr and skip those. |
I tried this after I debugged StmtVisitor::VisitDeclStmt. It calls S->children, but this returns the InitListExpr/ConstructorExpr, not the VarDecl. I wasn't sure how to tell if it was in a constexpr context or not. |
S->childen as in decl-stmt's children |
|
This was one of the initial (incomplete) solutions I tried -
I think this is similar to one of the solutions you proposed? This caused lit failure which I believe was because
Can you elaborate on this? You iterate through statements and visit sub-expressions, not Decls.
|
From my look (not having spent much time in this unfortuantely), that would be my guess, is something like that.
Looks like DeclStmt::children is: This appears to create an iterator to So at least the 'child' handler of it SHOULD have the information needed. Though it at least seems to go through I suspect something like the VisitDecl above is the right idea, but you'll likely want to loop through children/decls and find the corresponding ones in some way, so that you do a normal 'VisitStmt' on all children that AREN'T a constexpr VarDecl. Check out |
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Sorry for the VERY long delay in getting back to this PR. It slipped off my radar. I think I've implemented what you suggested here. The subgraph is not generated for constexpr nodes |
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
I am okay with the changes. @erichkeane, since you were involved with the changes earlier, would you like to review as well? |
I did a quick sweep yesterday and didn't have anything worth bringing up. Direction seems right (according to my memory), and your comments/questions seem to be productive enough that this looks thoroughly reviewed. I'm happy. |
Thanks for the review @premanandrao and @erichkeane ! Patch has caused a crash in pre-commit testing though. I will investigate that and update PR. |
Marking as Draft since the Visitor logic is flawed. |
As per offline discussion, this PR now reverts problematic code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Commit 9a9a018 introduced a regression in following case -
E.g.
The assert was hit when DeclStmt contains both TypeDecl and VarDecl i.e. a CXXRecordDecl which is not constexpr and a VarDecl which is. This PR removes code added in call graph creation. This code is not technically not required since the AST visitor in SemaSYCL, will handle non-traversal of nodes representing constexpr variables.
Closes: #4048
Signed-off-by: Elizabeth Andrews elizabeth.andrews@intel.com