[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 21 10:18:21 PDT 2021


Anastasia created this revision.
Anastasia added reviewers: svenvh, azabaznov.
Herald added subscribers: ebevhan, jfb, yaxunl.
Anastasia requested review of this revision.

Clang's implementation of the extension pragma is broken because it doesn't respect the following requirement from OpenCL Extension spec s1.2:

https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#extensions-overview

> **disable**  Behave (including issuing errors and warnings) as if the extension extension_name is not part of the language definition.

This means that extension functionality should not be exposed by default and if extension identifiers are not reserved they should not be recognized by the compiler. This is for example the case for some of the atomic types (i.e. 64 bit types) from extensions.

As fixing the implementation of extension pragma is not feasible and it will affect backward compatibility and require significant rework in the parser this patch simplifies the implementation of pragma by making the behavior as consistent and intuitive as possible.

This change removes the requirement on pragma when atomic types from the extensions are supported because the behavior is not conformant. With this change, the developers can use atomic types from the extensions if they are supported without enabling the pragma because disabling the pragma doesn't do anything useful but only prevents the use of already available identifiers for types and issues extra diagnostics. This makes semantics consistent with the atomic functions that are also available when the extension is supported without any need for the pragma.

This patch does not break backward compatibility since the extension pragma is still supported and it makes the behavior of the compiler less strict by accepting code without extra pragma statements.

Note that there is an ongoing thread to alter the behavior in the spec
https://github.com/KhronosGroup/OpenCL-Docs/issues/82
however this change is orthogonal as it simplifies the current implementation that is not conformant.
Any new functionality can be added later if the behavior in the spec is fixed.


https://reviews.llvm.org/D100976

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/Parser/opencl-atomics-cl20.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100976.339278.patch
Type: text/x-patch
Size: 11009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210421/77870179/attachment.bin>


More information about the cfe-commits mailing list