<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong IR emitted for "target enter data" with dependences"
   href="https://bugs.llvm.org/show_bug.cgi?id=47126">47126</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong IR emitted for "target enter data" with dependences
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Clang Compiler Support
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rofirrim@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi all,

the following test is failing in x86-64

  libomptarget :: offloading/target_depend_nowait.cpp

The following small reproducer seems to show the issue

// -- t.cpp
#include <omp.h>
#include <stdio.h>

#define N 1024

int A[N];
int main() {
#pragma omp target enter data map(to:A) depend(out:A[0])
}
// -- end of t.cpp

For reference this is the compilation line

clang++ \
   -fopenmp \
   -pthread \
   -fno-experimental-isel \
   -I /work/llvm-src/openmp/libomptarget/test \
   -I
/work/llvm-build-debug/runtimes/runtimes-bins/openmp/libomptarget/../runtime/src
\
   -fopenmp-targets=x86_64-pc-linux-gnu \
   t.cpp \
   -S -emit-llvm \
   -o t.ll

The generated IR contains a memcpy with a source from null pointer.

%20 = getelementptr inbounds %struct..kmp_privates.t, %struct..kmp_privates.t*
%11, i32 0, i32 3
%21 = bitcast [1 x i8*]* %20 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %21, i8* align 8 null, i64 8,
i1 false) ; <-- bug?

Kind regards,</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>