-
Notifications
You must be signed in to change notification settings - Fork 769
[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
[SYCL][Clang] Add __sycl_detail__::add_ir_annotations_member attribute #5879
Conversation
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>
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 I will make a patch for the design document shortly. Ping @gmlueck for awareness. |
clang/lib/CodeGen/CodeGenModule.cpp
Outdated
auto *Bitcasted = llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy); | ||
|
||
Lookup = Bitcasted; | ||
return Bitcasted; |
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.
auto *Bitcasted = llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy); | |
Lookup = Bitcasted; | |
return Bitcasted; | |
return llvm::ConstantExpr::getBitCast(GV, GlobalsInt8PtrTy); |
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.
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) { |
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 would appreciate some comments in this code.
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.
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. |
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 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>
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.
A little nit, otherwise LGTM
Signed-off-by: Steffen Larsen <steffen.larsen@intel.com>
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 no new comments.
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
…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>
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.