<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 on valid code at -Os and above on x86_64-linux-gnu"
   href="https://llvm.org/bugs/show_bug.cgi?id=25979">25979</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>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The current clang trunk and clang 3.7.0 crash 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.6.x.


$ clang-trunk -v
clang version 3.8.0 (trunk 256567)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
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/i686-linux-gnu/5.2.1
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.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.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
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.2.1
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 -c small.c
$ clang-3.6 -Os -c small.c

$ clang-trunk -Os -c small.c
clang: /tmp/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6653: unsigned int
llvm::SelectionDAG::AssignTopologicalOrder(): Assertion
`AllNodes.back().use_empty() && "Last node in topologic sort has users!"'
failed.
#0 0x0000000002f898d5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x2f898d5)
#1 0x0000000002f87686 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x2f87686)
#2 0x0000000002f878b1 (/usr/local/clang-trunk/bin/clang+0x2f878b1)
#3 0x00007fe2ede35340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fe2ece3fcc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fe2ece430d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fe2ece38b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fe2ece38c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x00000000024da075 llvm::SelectionDAG::AssignTopologicalOrder()
(/usr/local/clang-trunk/bin/clang+0x24da075)
#9 0x000000000254e1df llvm::SelectionDAGISel::DoInstructionSelection()
(/usr/local/clang-trunk/bin/clang+0x254e1df)
#10 0x0000000002556cd2 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang+0x2556cd2)
#11 0x000000000255a98e
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/usr/local/clang-trunk/bin/clang+0x255a98e)
#12 0x000000000255c41b
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang+0x255c41b)
#13 0x0000000002344694 (/usr/local/clang-trunk/bin/clang+0x2344694)
#14 0x0000000002f01783 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x2f01783)
#15 0x0000000002f01b3b llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2f01b3b)
#16 0x0000000002f01e4f llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x2f01e4f)
#17 0x0000000000bf71fc clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*, std::unique_ptr<llvm::FunctionInfoIndex,
std::default_delete<llvm::FunctionInfoIndex> >)
(/usr/local/clang-trunk/bin/clang+0xbf71fc)
#18 0x0000000000bd2cf3 (/usr/local/clang-trunk/bin/clang+0xbd2cf3)
#19 0x0000000000e0818b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xe0818b)
#20 0x0000000000bd2f1e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xbd2f1e)
#21 0x00000000009ee7e6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x9ee7e6)
#22 0x00000000009c88ce
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x9c88ce)
#23 0x00000000009add8a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x9add8a)
#24 0x00000000009a5748 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang+0x9a5748)
#25 0x00000000009668aa main (/usr/local/clang-trunk/bin/clang+0x9668aa)
#26 0x00007fe2ece2aec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#27 0x00000000009a3dbd _start (/usr/local/clang-trunk/bin/clang+0x9a3dbd)
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
-debugger-tuning=gdb -coverage-file /data2/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.8.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -Os -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 134 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o small.o -x c small.c 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'X86 DAG->DAG Instruction Selection' on function '@fn1'
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.8.0 (trunk 256567)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
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-ecd1a7.c
clang: note: diagnostic msg: /tmp/small-ecd1a7.sh
clang: note: diagnostic msg: 

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



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


struct
{
  int f0:17;
  int f1:31;
} a;
int b;

void
fn1 ()
{
  b = (a.f1 = a.f0) && a.f0;
}</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>