<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 at -O1 and above on x86_64-linux-gnu running pass 'Interprocedural Sparse Conditional Constant Propagation'"
   href="https://llvm.org/bugs/show_bug.cgi?id=26282">26282</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes at -O1 and above on x86_64-linux-gnu running pass 'Interprocedural Sparse Conditional Constant Propagation'
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>helloqirun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The current clang trunk crashes when compiling the following test case at -O1
and above on x86_64-linux-gnu in both 32-bit and 64-bit modes. 


$ clang-trunk -v
clang version 3.9.0 (trunk 258658)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
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.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
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
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64



$ clang-trunk -O1 -c abc.c
abc.c:6:12: warning: expression result unused [-Wunused-value]
      a[b++];
      ~ ~~~^
#0 0x0000000001839405 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1839405)
#1 0x0000000001837426 llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1837426)
#2 0x0000000001837625 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1837625)
#3 0x00007fd8558bf340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x0000000001507e29 llvm::Instruction::Instruction(llvm::Type*, unsigned int,
llvm::Use*, unsigned int, llvm::Instruction*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1507e29)
#5 0x000000000150e43c
llvm::UnreachableInst::UnreachableInst(llvm::LLVMContext&, llvm::Instruction*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x150e43c)
#6 0x000000000187113b llvm::changeToUnreachable(llvm::Instruction*, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x187113b)
#7 0x000000000178ecf3 (anonymous namespace)::IPSCCP::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x178ecf3)
#8 0x000000000152b8e0 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x152b8e0)
#9 0x000000000193eda1 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x193eda1)
#10 0x0000000001e2952a
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1e2952a)
#11 0x00000000020d6bbb clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x20d6bbb)
#12 0x0000000001bd387e clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1bd387e)
#13 0x0000000001bb3015
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1bb3015)
#14 0x0000000001c500d1
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x1c500d1)
#15 0x00000000008d0ba8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-3.9+0x8d0ba8)
#16 0x00000000008843f3 main
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x8843f3)
#17 0x00007fd854ad2ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#18 0x00000000008cd1b4 _start
(/home/absozero/trunk/root-clang/bin/clang-3.9+0x8cd1b4)
Stack dump:
0.    Program arguments: /home/absozero/trunk/root-clang/bin/clang-3.9 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier
-main-file-name abc.c -mrelocation-model static -mthread-model posix
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer
-dwarf-column-info -debugger-tuning=gdb -coverage-file
/home/absozero/projects/reduction/abc.c -resource-dir
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/bin/../lib/clang/3.9.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/absozero/projects/reduction -ferror-limit 19
-fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o abc.o -x c abc.c
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Interprocedural Sparse Conditional Constant Propagation' on
module 'abc.c'.
clang-3.9: error: unable to execute command: Segmentation fault (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 258658)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-3.9: 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-3.9: note: diagnostic msg:
********************

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

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






——————
$ cat abc.c
double *a;
void fn1() {
  int b, c;
  if (a)
    for (; c;)
      a[b++];
}</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>