<html>
    <head>
      <base href="http://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 on valid code at -Os and above on x86_64-linux-gnu"
   href="http://llvm.org/bugs/show_bug.cgi?id=22642">22642</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and above on x86_64-linux-gnu
          </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>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>-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>llvmbugs@cs.uiuc.edu
          </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 on
x86_64-linux-gnu at -Os and above in both 32-bit and 64-bit modes.

This is a regression from 3.5.x. 


$ clang-trunk -v
clang version 3.7.0 (trunk 229830)
Target: x86_64-unknown-linux-gnu
Thread model: posix
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.3
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.2
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.2
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ clang-trunk -O1 small.c; ./a.out
$ clang-3.5.0 -Os small.c; ./a.out

$ clang-trunk -Os small.c
clang: /tmp/llvm/lib/Transforms/Scalar/LICM.cpp:620: void (anonymous
namespace)::LICM::sink(llvm::Instruction &): Assertion
`ExitBlockSet.count(ExitBlock) && "The LCSSA PHI is not in an exit block!"'
failed.
#0 0x2acac38 llvm::sys::PrintStackTrace(_IO_FILE*)
(/usr/local/clang-trunk/bin/clang+0x2acac38)
#1 0x2acbdfb (/usr/local/clang-trunk/bin/clang+0x2acbdfb)
#2 0x7f9c647f0340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x7f9c63f46cc9 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36cc9)
#4 0x7f9c63f4a0d8 abort (/lib/x86_64-linux-gnu/libc.so.6+0x3a0d8)
#5 0x7f9c63f3fb86 (/lib/x86_64-linux-gnu/libc.so.6+0x2fb86)
#6 0x7f9c63f3fc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#7 0x2503092 (/usr/local/clang-trunk/bin/clang+0x2503092)
#8 0x2501152 (/usr/local/clang-trunk/bin/clang+0x2501152)
#9 0x2500da3 (/usr/local/clang-trunk/bin/clang+0x2500da3)
#10 0x2500da3 (/usr/local/clang-trunk/bin/clang+0x2500da3)
#11 0x2500da3 (/usr/local/clang-trunk/bin/clang+0x2500da3)
#12 0x24ff7e7 (/usr/local/clang-trunk/bin/clang+0x24ff7e7)
#13 0x27b1aab llvm::LPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x27b1aab)
#14 0x2a38131 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2a38131)
#15 0x26f7848 (/usr/local/clang-trunk/bin/clang+0x26f7848)
#16 0x2a38845 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2a38845)
#17 0x94bfb3 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_ostream*) (/usr/local/clang-trunk/bin/clang+0x94bfb3)
#18 0x93c785 (/usr/local/clang-trunk/bin/clang+0x93c785)
#19 0xb4caf3 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xb4caf3)
#20 0x739d6e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x739d6e)
#21 0x70d11c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x70d11c)
#22 0x6ee836 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x6ee836)
#23 0x6e5b42 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x6e5b42)
#24 0x6ecf3a main (/usr/local/clang-trunk/bin/clang+0x6ecf3a)
#25 0x7f9c63f31ec5 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec5)
#26 0x6e57b9 _start (/usr/local/clang-trunk/bin/clang+0x6e57b9)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -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
-target-linker-version 2.24 -momit-leaf-frame-pointer -dwarf-column-info
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.7.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -Os -fdebug-compilation-dir
/home/share/bugs/C/trans-bugs/shared/20150218-clang-trunk-m64-O3-build-1352
-ferror-limit 19 -fmessage-length 100 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -vectorize-loops -vectorize-slp -o
/tmp/small-f81b98.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 'Loop Pass Manager' on function '@fn2'
5.    Running pass 'Loop Invariant Code Motion' on basic block '%lbl'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (trunk 229830)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: 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: note: diagnostic msg: 
********************

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

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



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


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

int a, c, f;
short b, e, h;

void fn1 (char p) { }

char
fn2 ()
{
  long i = 0;
lbl:
  if (f)
    for (;;)
      {
    fn1 (i);
    printf ("%d", f);
    if (f)
      {
        if (b < -(short) 58227)
          return h;
        a = 2;
        if (b)
          goto lbl;
        for (; c; c++)
          if (e)
        break;
        return i;
      }
    i += 3;
    for (; i < 2;)
      ;
      }
  for (;;)
    ;
}

int
main ()
{
  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>