Skip to content

[SYCL] Fix function attribute merging on template declarations#21158

Merged
sarnex merged 7 commits intointel:syclfrom
0x12CC:fix-template-attr-merge
Feb 4, 2026
Merged

[SYCL] Fix function attribute merging on template declarations#21158
sarnex merged 7 commits intointel:syclfrom
0x12CC:fix-template-attr-merge

Conversation

@0x12CC
Copy link
Contributor

@0x12CC 0x12CC commented Jan 28, 2026

#20419 implements attribute merging for add_ir_attributes_* attributes. This commit fixes an issue that occurs when merging attributes on function template declarations.

Attribute merging is deferred until template instantiation if an attribute contains dependent expressions. Previously, we only checked if the existing attribute was dependent but not if the new attribute was dependent. This would cause the merge to fail but the new attribute would still be dropped from the AST. This commit ensures both attributes are checked and new dependent attributes do not disappear.

Signed-off-by: Michael Aziz <michael.aziz@intel.com>
Signed-off-by: Michael Aziz <michael.aziz@intel.com>
@0x12CC 0x12CC requested a review from a team as a code owner January 28, 2026 20:49
Signed-off-by: Michael Aziz <michael.aziz@intel.com>
@0x12CC
Copy link
Contributor Author

0x12CC commented Jan 30, 2026

@intel/dpcpp-cfe-reviewers, friendly ping.

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.

Makes sense, just a couple of questions.

https://github.com/intel/llvm/pull/20419/changes also brings changes for two other attributes - SYCLAddIRAttributesKernelParameterAttr and SYCLAddIRAttributesGlobalVariableAttr . Do they have the same problem?

Signed-off-by: Michael Aziz <michael.aziz@intel.com>
Signed-off-by: Michael Aziz <michael.aziz@intel.com>
@0x12CC
Copy link
Contributor Author

0x12CC commented Feb 3, 2026

Thank you, @Fznamznon,

https://github.com/intel/llvm/pull/20419/changes also brings changes for two other attributes - SYCLAddIRAttributesKernelParameterAttr and SYCLAddIRAttributesGlobalVariableAttr . Do they have the same problem?

I think so. The two other functions with similar logic are SemaSYCL::addSYCLAddIRAttributesKernelParameterAttr and SemaSYCL::addSYCLAddIRAttributesGlobalVariableAttr.

I fixed SemaSYCL::addSYCLAddIRAttributesFunctionAttr since these attributes are used for adding properties to free function kernels. I didn't change the other two since I couldn't find any way to write SYCL code that caused the merging issue. For the add_ir_attributes_kernel_parameter, the entire compile-time property list goes into one attribute. Similarly, for add_ir_attributes_global_variable, a single attribute is used to annotate all the device global metadata. Free functions are unique since the user can directly control the number of attributes in the AST using the SYCL_EXT_ONEAPI_FUNCTION_PROPERTY macro.

Signed-off-by: Michael Aziz <michael.aziz@intel.com>
Signed-off-by: Michael Aziz <michael.aziz@intel.com>
@0x12CC
Copy link
Contributor Author

0x12CC commented Feb 4, 2026

The failing end-to-end tests are unrelated to this change:

  1. Regression/queue_submit.cpp, reported in Regression/queue_submit.cpp sporadic fail on PVC #21095.
  2. Basic/out_of_order_queue_status_khr_empty.cpp, reported in queue::submit doesn't Enqueue Kernels before It Returns/after Host Tasks are Complete under OpenCL Backend sometimes #20837.

@intel/llvm-gatekeepers, this PR should be ready to merge.

@sarnex sarnex merged commit 3a1b0d5 into intel:sycl Feb 4, 2026
27 of 29 checks passed
@0x12CC 0x12CC deleted the fix-template-attr-merge branch February 4, 2026 20:30
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.

3 participants