Skip to content

[SYCL][Clang] Add __sycl_detail__::add_ir_annotations_member attribute #5879

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

Merged
merged 6 commits into from
Apr 5, 2022

Conversation

steffenlarsen
Copy link
Contributor

These changes introduce the new __sycl_detail__::add_ir_annotations_member. This attribute is similar in behaviour to __sycl_detail__::add_ir_attributes_* attributes but will generate annotation intrinsic calls rather than LLVM IR attributes.

These changes introduce the new
`__sycl_detail__::add_ir_annotations_member`. This attribute is similar
in behaviour to `__sycl_detail__::add_ir_attributes_*` attributes but
will generate annotation intrinsic calls rather than LLVM IR attributes.

Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen requested a review from a team as a code owner March 24, 2022 12:23
@steffenlarsen
Copy link
Contributor Author

Note: This is based of https://github.com/intel/llvm/blob/sycl/sycl/doc/design/CompileTimeProperties.md design document, with the change from the generated intrinsic call carrying metadata to it referencing a constant global variable with the string literals, similar to what clang::annotate does.

I will make a patch for the design document shortly. Ping @gmlueck for awareness.

Comment on lines 2907 to 2910
auto *Bitcasted = llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy);

Lookup = Bitcasted;
return Bitcasted;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto *Bitcasted = llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy);
Lookup = Bitcasted;
return Bitcasted;
return llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookup is a reference to an entry in the map to existing values, so setting also sets the entry for future reuse of the created value. I have added comments to the function and renamed it to LookupRef to make it a little more clear what the intention here is.

Additionally, I realized I didn't add a test for using the optional filter in codegen. It has been added, but it exposed a bug in this function. It has been fixed, but it does mean the function has been changed.

@@ -2873,6 +2873,43 @@ void CodeGenModule::AddGlobalAnnotations(const ValueDecl *D,
Annotations.push_back(EmitAnnotateAttr(GV, I, D->getLocation()));
}

llvm::Constant *CodeGenModule::EmitSYCLAnnotationArgs(
const SYCLAddIRAnnotationsMemberAttr *Attr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate some comments in this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! I have added comments. Let me know if you think it is sufficient.


// Tests the AST produced from instantiating templates using
// __sycl_detail__::add_ir_annotations_member attributes with pack expansion
// arguments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to come back to review this file.

…lue reuse tests

Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
Fznamznon
Fznamznon previously approved these changes Mar 28, 2022
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.

A little nit, otherwise LGTM

Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no new comments.

Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bader bader merged commit d2982c6 into intel:sycl Apr 5, 2022
steffenlarsen added a commit that referenced this pull request May 27, 2022
…annotations_member (#5884)

* [SYCL][Doc] Adjust design for compile-time properties through add_ir_annotations_member

During implementation of the attribute and translation of annotations on fields, the design was conflicting with existing features. This commit makes the following design changes:

 * Change the `llvm.ptr.annotation` intrinsic call produced by  `[[__sycl_detail__::add_ir_annotations_member()]]` to use a pointer to a constant global variable instead of metadata. This is done to adhere to the signature of the intrinsic.
 * Change the representation consumed by the translator from a new SPIR-V builtin to an extended version of existing decoration parsing using `llvm.ptr.annotation`.

Implementation of these are in review #5879 and KhronosGroup/SPIRV-LLVM-Translator#1446

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen deleted the steffen/add_ir_member_annotation branch December 6, 2023 11:38
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.

5 participants