This is an archive of the discontinued LLVM Phabricator instance.

[RFC][OpenCL] Add new diagnostic for extension pragma with no effect
Needs ReviewPublic

Authored by Anastasia on Nov 16 2020, 5:22 AM.



All OpenCL extensions implemented in clang were adding an extension pragma. However, the spec has never described what the pragma was needed for. There is now an issue open to the spec to clarify the behavior of pragma

The majory of extension pragmas are simply ignored by clang. This is for example the case for all extensions from the list II in RFC: The pragmas are simply ignored because the only functionality needed is extension macro definition.

In I proposed alternative mechanisms to define the extension macro. But that patch completely removed the pragma for the extension that was accepted by the parser originally. This implies that the existing kernels that used the pragma will be compiled with a warning for the new clang releases:

unknown OpenCL extension 'cl_khr_depth_images' - ignoring

Even though it is not uncommon that the new warnings occur for the existing code with new compiler releases, it has been discussed in that this might be unacceptable for the OpenCL developers. To prevent this warning the suggestion is to introduce a new warning that is TURNED OFF by default with the following wording:

OpenCL extension pragma 'cl_khr_depth_images' has no effect - ignoring

This design favors the existing kernels that might have used the pragma. This is highly unlikely because the pragma never did anything but it is not impossible. The developer of new kernels that wish to avoid redundant pragma will be able to pass -Wpedantic-redundant-pragma flag to clang which will then provide the warning with the wording below if such pragmas are found.

Note that the same behavior has been implemented for the extension pragma that become core functionality of the specification. See -Wpedantic-core-features for more details. The proposed approach is therefore built on top of the existing concept.

Diff Detail

Event Timeline

Anastasia created this revision.Nov 16 2020, 5:22 AM
Anastasia created this object with edit policy "Anastasia (Anastasia Stulova)".
Anastasia requested review of this revision.Nov 16 2020, 5:22 AM
Anastasia retitled this revision from [RFC][OpenCL] Add new diagnostic for OpenCL pragma with no effect to [RFC][OpenCL] Add new diagnostic for extension pragma with no effect.
Anastasia edited the summary of this revision. (Show Details)Nov 16 2020, 5:26 AM
Anastasia added a reviewer: jvesely.
Anastasia edited subscribers, added: cfe-commits; removed: yaxunl.
Anastasia updated this revision to Diff 305723.Nov 17 2020, 3:40 AM

Added full diff.