[all-commits] [llvm/llvm-project] 6781fe: Don't permit array bound constant folding in OpenCL.

Richard Smith via All-commits all-commits at lists.llvm.org
Tue Oct 20 16:52:48 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6781fee085058913444e0c5937da9c0e7e928db5
      https://github.com/llvm/llvm-project/commit/6781fee085058913444e0c5937da9c0e7e928db5
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M clang/lib/AST/Decl.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
    M clang/test/SemaOpenCL/address-spaces.cl

  Log Message:
  -----------
  Don't permit array bound constant folding in OpenCL.

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 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.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D89520




More information about the All-commits mailing list