[llvm-bugs] [Bug 50163] New: C++ for OpenCL fails to use constexpr construcor to create variable in __constant space

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 29 01:26:21 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50163

            Bug ID: 50163
           Summary: C++ for OpenCL fails to use constexpr construcor to
                    create variable in __constant space
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: OpenCL
          Assignee: unassignedclangbugs at nondot.org
          Reporter: drohr at jwdt.org
                CC: anastasia.stulova at arm.com, llvm-bugs at lists.llvm.org

Created attachment 24811
  --> https://bugs.llvm.org/attachment.cgi?id=24811&action=edit
testcase

The attached test case fails to compile in C++4OpenCL with a problem creating a
__constant variable using a constexpr constructor. The relevant part of the
error seems to be: candidate constructor ignored: cannot be used to construct
an object in address space '__constant'
         constexpr bitset(unsigned int vv) : v(vv){};
I am wondering why the simple constexpr constructor is ignored.
In the testcase I have a workaround (workaround.patch) which creates the bitset
explicitly, which works. So there is no general problem.

Note: the test case requires https://reviews.llvm.org/D101168.
I have been testing with clang trunk (clang version 13.0.0
(https://github.com/llvm/llvm-project.git
837fded984ed36fa462daeb0f671eec58f71ae26)) + https://reviews.llvm.org/D101168
and with the following command line:
/home/qon/alice/llvm-project/build/bin/clang++ -O0 -cl-std=clc++ -x cl
-emit-llvm --target=spir64-unknown-unknown -Xclang -fdenormal-fp-math-f32=ieee
-cl-mad-enable -cl-no-signed-zeros -ferror-limit=1000
-Dcl_clang_storage_class_specifiers -c fail.cl -o test.bc

Full error:

In file included from ../Base/opencl-common/GPUReconstructionOCL.cl:80:
In file included from ../Base/GPUReconstructionIncludesDevice.h:31:
In file included from ../SliceTracker/GPUTPCTracker.cxx:21:
In file included from ../SliceTracker/GPUTPCTrackletConstructor.h:20:
In file included from ../Base/GPUConstantMem.h:25:
In file included from ../TRDTracking/GPUTRDTracker.h:23:
In file included from ../TRDTracking/GPUTRDTrack.h:46:
In file included from ../TRDTracking/GPUTRDInterfaces.h:140:
In file included from
/home/qon/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackTPCITS.h:20:
In file included from
/home/qon/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h:20:
/home/qon/alice/O2/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h:178:4:
error: no viable conversion from 'unsigned int' to '__constant DetID::mask_t'
(aka '__constant bitset<32>')
  {math_utils::bit2Mask(DetID::ITS), math_utils::bit2Mask(DetID::TPC),
math_utils::bit2Mask(DetID::TRD), math_utils::bit2Mask(DetID::TOF),
math_utils::bit2Mask(DetID::PHS),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../GPUUtils/GPUCommonBitSet.h:38:27: note: candidate constructor not viable: no
known conversion from 'unsigned int' to 'const __generic
o2::gpu::gpustd::bitset<32> &__private' for 1st argument
                constexpr bitset(const bitset&) = default;
                          ^
../GPUUtils/GPUCommonBitSet.h:39:20: note: candidate constructor ignored:
cannot be used to construct an object in address space '__constant'
         constexpr bitset(unsigned int vv) : v(vv){};

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210429/9f15464a/attachment.html>


More information about the llvm-bugs mailing list