<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 - Clang asserts when compiling OpenMP offloading with -Xclang -print-stats"
   href="https://bugs.llvm.org/show_bug.cgi?id=50970">50970</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang asserts when compiling OpenMP offloading with -Xclang -print-stats
          </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>All
          </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>cchen@cray.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=24997" name="attach_24997" title="A very simple OpenMP offloading sample code.">attachment 24997</a> <a href="attachment.cgi?id=24997&action=edit" title="A very simple OpenMP offloading sample code.">[details]</a></span>
A very simple OpenMP offloading sample code.

When compiling OpenMP offload code with `-fopenmp-targets` and `-print-stats`,
we got an assertion failure:

clang++ -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa hello_gpu.c -Xclang
-print-stats

```
clang-13:
/ptmp/cchen/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:442:
clang::Preprocessor& clang::CompilerInstance::getPreprocessor() const:
Assertion `PP && "Compiler instance has no preprocessor!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /cray/css/users/cchen/myllvm/bin/clang-13 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations
-disable-free -main-file-name a.out-wrapper -mrelocation-model static
-mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/users/cchen -resource-dir
/cray/css/users/cchen/myllvm/lib/clang/13.0.0
-fdebug-compilation-dir=/home/users/cchen -ferror-limit 19 -fopenmp
-fgnuc-version=4.2.1 -fcolor-diagnostics -print-stats
-fopenmp-targets=amdgcn-amd-amdhsa -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
/tmp/a-406030.o -x ir /tmp/a-a041f3.bc
 #0 0x0000000002ffc5ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/ptmp/cchen/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:3
 #1 0x0000000002ffa614 llvm::sys::RunSignalHandlers()
/ptmp/cchen/llvm-project/llvm/lib/Support/Signals.cpp:76:20
 #2 0x0000000002ffacbd SignalHandler(int)
/ptmp/cchen/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #3 0x00007fcbfee702d0 __restore_rt (/lib64/libpthread.so.0+0x132d0)
 #4 0x00007fcbfdbe0520 raise (/lib64/libc.so.6+0x39520)
 #5 0x00007fcbfdbe1b01 abort (/lib64/libc.so.6+0x3ab01)
 #6 0x00007fcbfdbd8b1a __assert_fail_base (/lib64/libc.so.6+0x31b1a)
 #7 0x00007fcbfdbd8b92 (/lib64/libc.so.6+0x31b92)
 #8 0x000000000389f83c clang::CompilerInstance::getSourceManager() const
/ptmp/cchen/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:422:5
 #9 0x000000000389f83c clang::FrontendAction::EndSourceFile()
/ptmp/cchen/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1005:25
#10 0x000000000384190f
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/ptmp/cchen/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:967:57
#11 0x000000000395d768
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/ptmp/cchen/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#12 0x0000000000d77372 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /ptmp/cchen/llvm-project/clang/tools/driver/cc1_main.cpp:246:40
#13 0x0000000000d72ef7 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/ptmp/cchen/llvm-project/clang/tools/driver/driver.cpp:343:34
#14 0x0000000000cb8359 main
/ptmp/cchen/llvm-project/clang/tools/driver/driver.cpp:415:26
#15 0x00007fcbfdbcb34a __libc_start_main (/lib64/libc.so.6+0x2434a)
#16 0x0000000000d71faa _start
/home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:122:0
clang-13: error: unable to execute command: Aborted (core dumped)
```

Upstream Clang do not asserts if not compiling device code:
clang++ -fopenmp hello_gpu.c -Xclang -print-stats</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>