Skip to content

[SYCL] Add an attr tablegen feature for checking langopts #3234

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 5 commits into from
Feb 25, 2021

Conversation

AaronBallman
Copy link
Contributor

For SYCL, we want some attributes to be ignored in host mode, but
without diagnosing the attribute as being ignored. This adds a bit to
the tablegen emitter to specify that a given language option opts into
this behavior. This allows us to more naturally specify that an
attribute is a device-only attribute from Attr.td without adding logic
in SemaDeclAttr.cpp to bail out in host mode (which looks like a bug
due to the lack of an ignored attribute warning).

As a drive-by, this also corrects a think-o with the
[[intel::reqd_sub_group_size]] attribute in OpenCL mode, which was
always being silently dropped.

For SYCL, we want some attributes to be ignored in host mode, but
without diagnosing the attribute as being ignored. This adds a bit to
the tablegen emitter to specify that a given language option opts into
this behavior. This allows us to more naturally specify that an
attribute is a device-only attribute from Attr.td without adding logic
in SemaDeclAttr.cpp to bail out in host mode (which looks like a bug
due to the lack of an ignored attribute warning).

As a drive-by, this also corrects a think-o with the
[[intel::reqd_sub_group_size]] attribute in OpenCL mode, which was
always being silently dropped.
@AaronBallman
Copy link
Contributor Author

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).

We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

@smanna12
Copy link
Contributor

smanna12 commented Feb 19, 2021

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).

We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

inside SemaStmtAttr.cpp, i see checking for all loop attributes.
if (S.LangOpts.SYCLIsHost)
return nullptr;

I think they all will be removed as well.

@AaronBallman
Copy link
Contributor Author

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).
We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

inside SemaStmtAttr.cpp, i see checking for all loop attributes.
if (S.LangOpts.SYCLIsHost)
return nullptr;

I think they all will be removed as well.

Good call, I'll work on those for this patch as well.

We still want to list explicitly that the attribute is accepted in host
mode, otherwise there's no good way to see that the attribute is
silently being accepted there. This complicates the tablegen slightly,
but also makes for a more obvious feature.
(Statement attributes do not currently utilize the tablegen
functionality for checking things like language options and subjects.)
@AaronBallman
Copy link
Contributor Author

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).
We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

inside SemaStmtAttr.cpp, i see checking for all loop attributes.
if (S.LangOpts.SYCLIsHost)
return nullptr;
I think they all will be removed as well.

Good call, I'll work on those for this patch as well.

I've added the right definitions to Attr.td, but that's as far as I think I'll go with that in this patch. Statement attributes do not have the same common attribute handling code as declaration attributes, so we don't take advantage of much of the tablegen goodies for those. I need to work on a patch to improve that, but that'll be an upstream patch first most likely.

@smanna12
Copy link
Contributor

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).
We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

inside SemaStmtAttr.cpp, i see checking for all loop attributes.
if (S.LangOpts.SYCLIsHost)
return nullptr;
I think they all will be removed as well.

Good call, I'll work on those for this patch as well.

I've added the right definitions to Attr.td, but that's as far as I think I'll go with that in this patch. Statement attributes do not have the same common attribute handling code as declaration attributes, so we don't take advantage of much of the tablegen goodies for those. I need to work on a patch to improve that, but that'll be an upstream patch first most likely.

I should note: there are more attributes in Attr.td that should be investigated. I hit all the ones that should be an NFC change (aside from the OpenCL-related fix).
We have some attributes that have no spellings (those don't need any LangOpts) and we have a bunch that have no checking for them in SemaDeclAttr.cpp but specify both device and host in Attr.td.

inside SemaStmtAttr.cpp, i see checking for all loop attributes.
if (S.LangOpts.SYCLIsHost)
return nullptr;
I think they all will be removed as well.

Good call, I'll work on those for this patch as well.

I've added the right definitions to Attr.td, but that's as far as I think I'll go with that in this patch. Statement attributes do not have the same common attribute handling code as declaration attributes, so we don't take advantage of much of the tablegen goodies for those. I need to work on a patch to improve that, but that'll be an upstream patch first most likely.

Thanks for the update and explanation.

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

Change looks ok to me but I am not familiar with TableGen code. So @erichkeane @premanandrao could you also please take a look?

smanna12
smanna12 previously approved these changes Feb 22, 2021
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

erichkeane
erichkeane previously approved these changes Feb 22, 2021
erichkeane
erichkeane previously approved these changes Feb 22, 2021
@romanovvlad romanovvlad merged commit d0a678c into intel:sycl Feb 25, 2021
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