<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 -O2 and -O3 while running pass 'Jump Threading'"
   href="https://bugs.llvm.org/show_bug.cgi?id=35840">35840</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -O2 and -O3 while running pass 'Jump Threading'
          </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 321905. 

$ clangpolly -v
clang version 7.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
8ab750617f6c3c5e50ad8bcf932b3bde36d8a111) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
135e942bcbf1e59d0c5e177510c20d3e3c3039c7)
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 -Os small.c; ./a.out
$         
$ clangpolly -O2 small.c
#0 0x0000000002144c2a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/su/software/tmp/polly/llvm/lib/Support/Unix/Signals.inc:402:0
#1 0x0000000002142abe llvm::sys::RunSignalHandlers()
/home/su/software/tmp/polly/llvm/lib/Support/Signals.cpp:50:0
#2 0x0000000002142c32 SignalHandler(int)
/home/su/software/tmp/polly/llvm/lib/Support/Unix/Signals.inc:242:0
#3 0x00007f5bc38f9390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000001852fc6 llvm::matchSelectPattern(llvm::Value*, llvm::Value*&,
llvm::Value*&, llvm::Instruction::CastOps*)
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4595:0
#5 0x0000000001852119 matchMinMaxOfMinMax
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4173:0
#6 0x0000000001852119 matchMinMax
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4252:0
#7 0x0000000001852119 matchSelectPattern(llvm::CmpInst::Predicate,
llvm::FastMathFlags, llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*,
llvm::Value*&, llvm::Value*&)
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4432:0
#8 0x0000000001852fcb llvm::matchSelectPattern(llvm::Value*, llvm::Value*&,
llvm::Value*&, llvm::Instruction::CastOps*)
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4595:0

... 

#504 0x0000000001852fcb llvm::matchSelectPattern(llvm::Value*, llvm::Value*&,
llvm::Value*&, llvm::Instruction::CastOps*)
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4595:0
#505 0x0000000001852119 matchMinMaxOfMinMax
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4173:0
#506 0x0000000001852119 matchMinMax
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4252:0
#507 0x0000000001852119 matchSelectPattern(llvm::CmpInst::Predicate,
llvm::FastMathFlags, llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*,
llvm::Value*&, llvm::Value*&)
/home/su/software/tmp/polly/llvm/lib/Analysis/ValueTracking.cpp:4432:0
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 -resource-dir
/home/su/software/tmp/polly/llvm_build/lib/clang/7.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/su/software/tmp/polly/llvm_build/lib/clang/7.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdebug-compilation-dir /home/su -ferror-limit 19 -fmessage-length 116
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -o /tmp/small-b23784.o -x c small.c 
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 'Jump Threading' on function '@main'
clang-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
8ab750617f6c3c5e50ad8bcf932b3bde36d8a111) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
135e942bcbf1e59d0c5e177510c20d3e3c3039c7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/su/bin
clang-6.0: 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.0: 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.0: note: diagnostic msg: /tmp/small-cee743.c
clang-6.0: note: diagnostic msg: /tmp/small-cee743.sh
clang-6.0: note: diagnostic msg: 

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



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


int printf (const char *, ...);

int a, d, e, f, g, h;

int fn1 (int c)
{
  return c > 0 ? c : a;
}

void fn2 ()
{
  while (!e)
    printf ("\n");
  for (; 1; g = fn1 (g))
    {
      while (f)
        while (1)
          ;
      if (e)
        break;
      while (1)
        {
          d |= h;
          if (d)
            break;
          e = 1;
        }
    }
}

int main ()
{
  if (a)
    fn2 ();
  return 0;
}</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>