-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Set lexical context for generated OpenCL kernel function #1020
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
[SYCL] Set lexical context for generated OpenCL kernel function #1020
Conversation
At the moment, this isn't causing any problems (particularly since the diagnostic changes previously made don't try to diagnose during this), however this is likely something we would notice later. Start a RAII container to set the current function decl to the kernel. Signed-off-by: Erich Keane <[email protected]>
@@ -1285,6 +1285,8 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, | |||
FunctionDecl *OpenCLKernel = | |||
CreateOpenCLKernelDeclaration(getASTContext(), Name, ParamDescs); | |||
|
|||
ContextRAII FuncContext(*this, OpenCLKernel); |
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.
Do we really need this? We disabled diagnosing during OpenCL kernel generation, is it possible that we once enable it?
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.
At the moment, I no longer have a true motivating example. However, this is a bug we have worked around a few times, so I suspect we will need this fixed eventually.
Additionally, this is one of the conditions where getLexicalContext gave us not a Function Decl, so now that this is fixed, we know !FD means exactly what it should, that we are evaluating a global (and this can properly handle that once we figure that out).
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.
Okay, sounds reasonable to me.
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.
It doesn't affect anything right now, but I'm not sure that it is NFC.
I've updated the PR subject and description. @Fznamznon, @erichkeane are you okay if I use them for the commit message? |
Yep, that looks good to me. |
When doing ConstructOpenCLKernel, we don't set the current
function/lexical context correctly, so getCurLexicalContext
(or getCurFunctionDecl) fails, as we're in the TU-level at that point.
This function should set the function for diagnostics purposes (and
other analysis purposes).
At the moment, this isn't causing any problems (particularly since the
diagnostic changes previously made don't try to diagnose during this),
however this is likely something we would notice later.
Start a RAII container to set the current function decl to the kernel.
Fixes #1015.
Signed-off-by: Erich Keane [email protected]