-
Notifications
You must be signed in to change notification settings - Fork 775
[SYCL] Enable aspect usage propagation pass and add diagnostics #6982
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] Enable aspect usage propagation pass and add diagnostics #6982
Conversation
This commit adds a warning diagnostic for when there is a mismatch between aspect usage propagated to a function and the function's `device_has` attribute. Additionally, notes accompany the warning to give the user a trace through to where the aspects originate. Since the aspects are propagated in an LLVM pass, the warning is issued from there, which means no source information is available by default. To alleviate this, Clang CodeGen will now add srcloc metadata with an encoded version of the source location to allow the backend to correctly report the location for the various new diagnostics. Additionally, this commit also adds the SYCLPropagateAspectsUsage pass to the passes run for SYCL device code. Co-authored-by: Sabianin, Maksim <maksim.sabianin@intel.com> Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@@ -1086,6 +1086,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, | |||
Fn->setMetadata("sycl_used_aspects", | |||
llvm::MDNode::get(getLLVMContext(), AspectsMD)); | |||
} | |||
|
|||
// SYCL needs to know the source location of functions for diagnostics in | |||
// the aspect propagation pass. Save the token in a srcloc metadata node. |
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.
I heard that not all optimizations care about metadata. Will it work when early optimizations enabled?
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.
The pass that uses srcloc relies on other metadata too, so we need it to run as early as possible. As such, srcloc should also be preserved with early opts too. As you suggest in the other comment, it may make sense to add it to the tests.
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.
I have added a test checking that it works with early optimizations: sycl/test/warnings/aspect_perserve_srcloc.cpp
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
/verify with intel/llvm-test-suite#1353 |
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
/verify with intel/llvm-test-suite#1353 |
1 similar comment
/verify with intel/llvm-test-suite#1353 |
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. One nitpick. It might be helpful to reword the topic to let reviewers know that this change also adds this pass into the SYCL compilation pipeline.
Thanks.
/verify with intel/llvm-test-suite#1353 |
Remaining verification failure in OpenCL on Windows for KernelAndProgram/kernel-bundle-merge-options-env.cpp is a known issue. |
…anged compiler behavior (#146) * fix CI failed, due to compiler change after 20221202 Signed-off-by: Ni, Wenhui <wenhui.ni@intel.com> * disable math_exec math_habs on gen12 Signed-off-by: Ni, Wenhui <wenhui.ni@intel.com>
This commit adds a warning diagnostic for when there is a mismatch between aspect usage propagated to a function and the function's
device_has
attribute. Additionally, notes accompany the warning to give the user a trace through to where the aspects originate. Since the aspects are propagated in an LLVM pass, the warning is issued from there, which means no source information is available by default. To alleviate this, Clang CodeGen will now add srcloc metadata with an encoded version of the source location to allow the backend to correctly report the location for the various new diagnostics.Additionally, this commit also adds the SYCLPropagateAspectsUsage pass to the passes run for SYCL device code.