<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 - Runtime fails with declare mapper due clang generate extra mapper component for non-array map variable."
   href="https://bugs.llvm.org/show_bug.cgi?id=48423">48423</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Runtime fails with declare mapper due clang generate extra mapper component for non-array map variable.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>OpenMP
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jennifer.yu@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24242" name="attach_24242" title="Test to reproduce the problem.">attachment 24242</a> <a href="attachment.cgi?id=24242&action=edit" title="Test to reproduce the problem.">[details]</a></span>
Test to reproduce the problem.

Test failed at runtime:
command line to reproduce:

<span class="quote">>clang++ -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu -g -O0 j.cpp</span >
bash-4.4$ ./a.out
Sizeof C = 16 8
Sizeof C.s = 1cf8f808 1cf8f810
Libomptarget message: explicit extension not allowed: host address specified is
0x00007ffe1cf8f808 (16 bytes), but device allocation maps to host at
0x00007ffe1cf8f808 (4 bytes)
Libomptarget error: Call to getOrAllocTgtPtr returned null pointer (device
failure or illegal mapping).
Libomptarget error: Call to targetDataBegin via targetDataMapper for custom
mapper failed.
Libomptarget error: Call to targetDataBegin failed, abort target.
Libomptarget error: Failed to process data before launching the kernel.
Libomptarget error: run with env LIBOMPTARGET_INFO>1 to dump host-target
pointer maps
j.cpp:17:3: Libomptarget fatal error 1: failure of target construct while
offloading is mandatory
Aborted (core dumped)

The problem clang generate 4 Mapper components should be 3:

$11 = std::vector of length 4, capacity 4 = {{Base = 0x7fffffff9f28,
    Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28,
    Begin = 0x7fffffff9f28, Size = 16, Type = 32}, {Base = 0x7fffffff9f28,
    Begin = 0x7fffffff9f28, Size = 4, Type = 562949953421315}, {
    Base = 0x7fffffff9f30, Begin = 0x7fffffff9f10, Size = 16,
    Type = 562949953421331}}

During run mapper_id(clang generated), isarray gets set true cause extra
MapperComponent is generated.   

 %omp.arrayinit.isarray = icmp sge i64 %6, 1

In emitUDMapperArrayInitOrDel: following code seems not right.
      llvm::Value *IsArray = MapperCGF.Builder.CreateICmpSGE(
      Size, MapperCGF.Builder.getInt64(1), "omp.arrayinit.isarray");

ā€œC cā€ is not same with ā€œC c[1]ā€;  but both Size are 1;

Compiler knows map variable type, should not necessary to generate runtime code
for isarray.</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>