Skip to content

[libclc] Don't rely on fp16 pragma guards in headers #122751

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 2 commits into from
Jan 22, 2025

Conversation

frasercrmck
Copy link
Contributor

@frasercrmck frasercrmck commented Jan 13, 2025

Having the fp16 pragmas enabled in the header file is risky. The macros defined by that header don't (and can't) include the pragmas that make fp16 types themselves legal, and another header may disable the fp16 pragma before the macro's use.

The safest thing to do is the use of pragmas surrounding each use of the macro in the implementation files. This pattern is also far more common across the codebase.

Having the fp16 pragmas enabled in the header file is risky, as we have
some headers that also disable pragmas. We want to be as immune to
changes in the order of included header files as possible.

This pattern of setting pragmas in the implementation files is also far
more common across the codebase.
@frasercrmck frasercrmck added the libclc libclc OpenCL library label Jan 13, 2025
@frasercrmck frasercrmck requested a review from arsenm January 13, 2025 17:47
Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

Title is misleading now, since this isn't moving the guards anymore

@frasercrmck frasercrmck changed the title [libclc] Move fp16 pragma guards out of header file [libclc] Don't rely on pragma guards in headers Jan 22, 2025
@frasercrmck frasercrmck changed the title [libclc] Don't rely on pragma guards in headers [libclc] Don't rely on fp16 pragma guards in headers Jan 22, 2025
@frasercrmck frasercrmck merged commit 9e0b2b6 into llvm:main Jan 22, 2025
8 checks passed
@frasercrmck frasercrmck deleted the libclc-move-guards branch January 22, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants