[llvm-bugs] [Bug 51976] New: static constexpr symbol removed in offload when using -O1

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 26 07:44:32 PDT 2021


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

            Bug ID: 51976
           Summary: static constexpr symbol removed in offload when using
                    -O1
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenMP
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gcgt96 at durham.ac.uk
                CC: llvm-bugs at lists.llvm.org

Hi,

We use llvm13-rc3 with cuda10.1.243 for OMP offloading on x86 and power9.

We noticed that when turning on optimisation (-O1 and higher), symbols are
lost, leading to program errors of the kind

     Target CUDA RTL --> Loading global /bar/ failed"

Our code looks like this:

   class foo
   {
      public:
        #pragma omp declare target
        static constexpr int bar = 42;
        #pragma omp end declare target
   };

Johannes Doerfert pointed out that we can do

   class foo
   {
      public:
        #pragma omp declare target
        static constexpr int bar = 42;
        static const int * _keepalive_bar;
        #pragma omp end declare target
   };

and use this in the implementation:

   const int *foo::_keepalive_bar = &foo::bar;



While I can confirm that this indeed works, it would be nice not having to do
that.

Thanks a lot,
Holger

-- 
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/20210926/fefb2585/attachment.html>


More information about the llvm-bugs mailing list