<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: Assertion `Node2Index[SU->NodeNum] > Node2Index[I->getSUnit()->NodeNum] && "Wrong topological sorting"' failed"
   href="https://llvm.org/bugs/show_bug.cgi?id=31604">31604</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and above on x86_64-linux-gnu: Assertion `Node2Index[SU->NodeNum] > Node2Index[I->getSUnit()->NodeNum] && "Wrong topological sorting"' failed
          </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>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>$ clang -v
clang version 4.0.0 (trunk 291427)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/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.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.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.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.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.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.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.2.0
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 -O1 -c small.c
$
$ clang -Os -c small.c
clang-4.0: /tmp/llvm-builder/llvm-source-trunk/lib/CodeGen/ScheduleDAG.cpp:519:
void llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting(): Assertion
`Node2Index[SU->NodeNum] > Node2Index[I->getSUnit()->NodeNum] && "Wrong
topological sorting"' failed.
#0 0x0000000001f9bee5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f9bee5)
#1 0x0000000001f9a00e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1f9a00e)
#2 0x0000000001f9a170 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f9a170)
#3 0x00007ff3ac57c330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007ff3ab368c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007ff3ab36c028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007ff3ab361bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007ff3ab361ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000019c4737
llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting()
(/usr/local/clang-trunk/bin/clang-4.0+0x19c4737)
#9 0x000000000274d817 (anonymous namespace)::ScheduleDAGRRList::Schedule()
(/usr/local/clang-trunk/bin/clang-4.0+0x274d817)
#10 0x00000000026d8d0e llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang-4.0+0x26d8d0e)
#11 0x00000000026e0df3
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/usr/local/clang-trunk/bin/clang-4.0+0x26e0df3)
#12 0x00000000026e3087
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone
.part.956] (/usr/local/clang-trunk/bin/clang-4.0+0x26e3087)
#13 0x00000000014fc394 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x14fc394)
#14 0x00000000018e0bb7
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x18e0bb7)
#15 0x0000000001bae1f3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1bae1f3)
#16 0x0000000001bae29c llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1bae29c)
#17 0x0000000001baeada llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1baeada)
#18 0x0000000002124504 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/usr/local/clang-trunk/bin/clang-4.0+0x2124504)
#19 0x0000000002125726 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/usr/local/clang-trunk/bin/clang-4.0+0x2125726)
#20 0x000000000279d5d2
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-4.0+0x279d5d2)
#21 0x0000000002bb03bc clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2bb03bc)
#22 0x00000000027981be clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x27981be)
#23 0x0000000002480d1e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x2480d1e)
#24 0x00000000024572ee
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x24572ee)
#25 0x0000000002518c62
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2518c62)
#26 0x0000000000c041b8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xc041b8)
#27 0x0000000000ba3e15 main (/usr/local/clang-trunk/bin/clang-4.0+0xba3e15)
#28 0x00007ff3ab353f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#29 0x0000000000c0070e _start (/usr/local/clang-trunk/bin/clang-4.0+0xc0070e)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.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
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb
-coverage-notes-file /data2/small.gcno -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.0.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 328 -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 '@fn2'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 291427)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.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-4.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-4.0: note: diagnostic msg: /tmp/small-cf126c.c
clang-4.0: note: diagnostic msg: /tmp/small-cf126c.sh
clang-4.0: note: diagnostic msg:

********************
$


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


int a, b;
volatile int c, d;

int fn1 (int f, int g)

  return g ? f : 0;
}

void fn2 ()

  if (b)
    while (1)
      if (b)
        d = fn1 (c, ++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>