Repository navigation
[SYCL] Unify work-group scope variable checks - #23644
Open
inteltdelisle wants to merge 2 commits into
Open
inteltdelisle wants to merge 2 commits into
inteltdelisle wants to merge 2 commits into
Conversation
Four places in CodeGen checked whether a variable is a work-group local by looking for SYCLScopeAttr on the variable or on its type, with slight differences between them. Replace them with CGSYCLRuntime::getWorkGroupVarKind, which distinguishes hierarchical parallelism locals (attribute on the variable) from wg_scope types such as work_group_static (attribute on the type). Generated code is unchanged. Add CodeGen tests for wg_scope types, and extend the hierarchical parallelism tests to cover private_memory, wg_scope types and const locals. Fixes intel#23626 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
These checks hardcode Itanium-mangled internal symbol names, which makes the test more brittle to… · NewCHECK-NOT: __cxa_guardis currently module-wide and can become a false-failure if unrelated code… · New The last clause is ambiguous given the new distinction betweenHoistedAutomatic(attr on the… · New
What changed in this PR
Unifies SYCL work-group scope variable detection in CodeGen by routing all checks through a single helper that distinguishes hierarchical hoisted locals from wg_scope types, and adds/extends CodeGenSYCL tests to cover these cases.
Changes:
- Introduce
CGSYCLRuntime::getWorkGroupVarKind()and use it in multiple CodeGen locations to consistently classify work-group variables. - Adjust initialization handling so only hierarchical hoisted locals get the special “no guarded init + store-based init” path.
- Add/extend CodeGenSYCL tests for
wg_scope-decorated types,private_memory, and const locals in hierarchical kernels.
| File | Description |
|---|---|
| clang/test/CodeGenSYCL/wg_scope_class.cpp | New test validating wg_scope-type variables are emitted in local AS and are zero-initialized like statics. |
| clang/test/CodeGenSYCL/wg_init.cpp | Extends hierarchical WG init test to cover private_memory and wg_scope types. |
| clang/test/CodeGenSYCL/const-wg-init.cpp | Extends const hierarchical WG local test with an explicit global undef check. |
| clang/lib/CodeGen/CodeGenModule.cpp | Use unified work-group variable classification to choose local address space for globals. |
| clang/lib/CodeGen/CGSYCLRuntime.h | Adds WorkGroupVarKind enum and getWorkGroupVarKind() API. |
| clang/lib/CodeGen/CGSYCLRuntime.cpp | Implements getWorkGroupVarKind() and uses it to validate WG local emission. |
| clang/lib/CodeGen/CGDecl.cpp | Replace ad-hoc attribute checks with unified kind query and refine WG init handling. |
Review effort: Lite
Comment on lines
+6
to
+7
| // scope alloca, and that a variable of a type with the wg_scope attribute is | ||
| // treated as a hierarchical work group local (no initializer). |
According to copilot:
These checks hardcode Itanium-mangled internal symbol names, which makes the test more brittle to minor frontend/mangling changes. Prefer matching with a looser symbol regex (e.g. @{{.*}}AutoWGS{{.*}}) or anchoring on the IR properties being validated (addrspace(3), type, initializer) without requiring the exact mangled spelling.
Seems reasonnable.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot stopped reviewing on behalf of
inteltdelisle due to an error
October 27, 2026 22:33
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Four places in CodeGen checked whether a variable is a work-group local by looking for SYCLScopeAttr on the variable or on its type, with slight differences between them. Replace them with CGSYCLRuntime::getWorkGroupVarKind, which distinguishes hierarchical parallelism locals (attribute on the variable) from wg_scope types such as work_group_static (attribute on the type).
Generated code is unchanged.
Add CodeGen tests for wg_scope types, and extend the hierarchical parallelism tests to cover private_memory, wg_scope types and const locals.
Fixes #23626
Co-Authored-By: Claude Opus 5.5