[PATCH] D89520: Don't permit array bound constant folding in OpenCL.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 17:56:13 PDT 2020
rsmith created this revision.
rsmith added reviewers: Anastasia, bader, yaxunl.
Herald added subscribers: kerbowa, nhaehnle, jvesely.
Herald added a project: clang.
rsmith requested review of this revision.
Permitting non-standards-driven "do the best you can" constant-folding
of array bounds is permitted solely as a GNU compatibility feature. We
should not be doing it in any language mode that is attempting to be
conforming.
>From https://reviews.llvm.org/D20090 it appears the intent here was to
permit `__constant int` globals to be used in array bounds, but the
change in that patch only added half of the functionality necessary to
support that in the constant evaluator. This patch adds the other half
of the functionality and turns off constant folding for array bounds in
OpenCL.
I couldn't find any spec justification for accepting the kinds of cases
that D20090 <https://reviews.llvm.org/D20090> accepts, so a reference to where in the OpenCL specification
this is permitted would be useful.
Note that this change also affects the code generation in one test:
because after 'const int n = 0' we now treat 'n' as a constant
expression with value 0, it's now a null pointer, so '(local int *)n'
forms a null pointer rather than a zero pointer.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89520
Files:
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
clang/test/SemaOpenCL/address-spaces.cl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89520.298528.patch
Type: text/x-patch
Size: 9762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201016/eb6a49d3/attachment-0001.bin>
More information about the cfe-commits
mailing list