<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 - [OpenMPOpt] produces: error: Invalid record (Producer: 'LLVM14.0.0git' Reader: 'LLVM 14.0.0git')"
   href="https://bugs.llvm.org/show_bug.cgi?id=51647">51647</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[OpenMPOpt] produces: error: Invalid record (Producer: 'LLVM14.0.0git' Reader: 'LLVM 14.0.0git')
          </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>normal
          </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>rlieberm@amd.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>i see this compilation issue with AMDGPU target on trunk, but not NVPTX.
we dug into this some locally, with debug build, to see what the bitcode reader
is unhappy about.  While trying to read the record for kmpc_kernel_parallel,
the single argument is not found.  

error: Invalid record (Producer: 'LLVM14.0.0git' Reader: 'LLVM 14.0.0git')

using trunk build this morning ... Aug 27

build compiler to enable amdgpu target

command line:
clang  -O2 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx900 teams_nest.c -o teams_nest



test case:

#include <stdio.h>
#include <omp.h>
extern void foobar(int);
int main(void) {

  int fail = 0;
  #pragma omp target map(tofrom: fail)
 {
    #pragma omp teams
    {
      if (omp_get_team_num() == 0)
        foobar(fail);
    }
  }

  return fail;
}


CMake variables i used: 

      -DCMAKE_BUILD_TYPE=Release \
      -DLLVM_ENABLE_PROJECTS="clang;lld;llvm" \
      -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU" \
      -DLLVM_ENABLE_ASSERTIONS=ON                        \
      -DLLVM_ENABLE_RUNTIMES="openmp" \
      -DCLANG_DEFAULT_LINKER=lld                         \


some debugging output:

location in bitcodeReader where it aborts
llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5306

295          SmallVector<Value*, 16> Args;
5296          SmallVector<Type *, 16> ArgsTys;
5297          // Read the fixed params.
5298          for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i,
++OpNum) {
5299            if (FTy->getParamType(i)->isLabelTy())
5300              Args.push_back(getBasicBlock(Record[OpNum]));
5301            else
5302              Args.push_back(getValue(Record, OpNum, NextValueNo,
5303                                      FTy->getParamType(i)));
5304            ArgsTys.push_back(FTy->getParamType(i));
(gdb)
5305            if (!Args.back())
5306              return error("Invalid record");
5307          }
5308

(gdb) p getValue(Record, OpNum, NextValueNo,FTy->getParamType(i))
$1 = (llvm::Value *) 0x0</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>