<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 crashes on valid code at -O1 and above on x86_64-linux-gnu while running pass 'Early GVN Hoisting of Expressions'"
   href="https://bugs.llvm.org/show_bug.cgi?id=38982">38982</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -O1 and above on x86_64-linux-gnu while running pass 'Early GVN Hoisting of Expressions'
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>su@cs.ucdavis.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Tested with trunk revision 342457. 

$ clangpolly -v
clang version 8.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
0c965af23bb73e9da25306503ff6f6e92817fa60) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
0a5be7e8d363bebccce1d73696508598c8fa9423)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/su/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ clangpolly -O0 -c small.c

$ clangpolly -O1 -c small.c
Stack dump:
0.      Program arguments: /home/su/software/tmp/polly/llvm_build/bin/clang-6.0
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
small.c -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-momit-leaf-frame-pointer -coverage-notes-file /home/su/small.gcno
-resource-dir /home/su/software/tmp/polly/llvm_build/lib/clang/8.0.0
-internal-isystem /usr/local/include -internal-isystem
/home/su/software/tmp/polly/llvm_build/lib/clang/8.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir /home/su -ferror-limit 19 -fmessage-length 127
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x
c small.c -faddrsig 
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'small.c'.
4.      Running pass 'Early GVN Hoisting of Expressions' on function '@g'
#0 0x000000000245b40a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x245b40a)
#1 0x00000000024597ac llvm::sys::RunSignalHandlers()
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x24597ac)
#2 0x0000000002459917 SignalHandler(int)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x2459917)
#3 0x00007f3fc6b88390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00000000041ac356
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x41ac356)
#5 0x00000000041ac37b
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x41ac37b)
#6 0x00000000041ac37b
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x41ac37b)

...

#254 0x00000000041ac37b
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x41ac37b)
#255 0x00000000041ac37b
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/su/software/tmp/polly/llvm_build/bin/clang-6.0+0x41ac37b)
clang-6: error: unable to execute command: Segmentation fault (core dumped)
clang-6: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
0c965af23bb73e9da25306503ff6f6e92817fa60) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
0a5be7e8d363bebccce1d73696508598c8fa9423)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/su/bin
clang-6: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-6: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6: note: diagnostic msg: /tmp/small-6b8ff5.c
clang-6: note: diagnostic msg: /tmp/small-6b8ff5.sh
clang-6: note: diagnostic msg: 

********************



-------------------------


int a, b, c, d;

void g ()
{
  while (1)
    {
      int f;
      if (d)
        {
          g ();
          while (f++)
            ;
        }
      c = b || a + c;
      b = a;
    }
}</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>