<html>
    <head>
      <base href="http://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 -Os and above (in 32-bit mode) running pass 'X86 DAG->DAG Instruction Selection': Assertion `Sequence.size() - Noops == ScheduledNodes && "The number of nodes scheduled doesn't match the expected number!"' failed"
   href="http://bugs.llvm.org/show_bug.cgi?id=32610">32610</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and above (in 32-bit mode) running pass 'X86 DAG->DAG Instruction Selection': Assertion `Sequence.size() - Noops == ScheduledNodes && "The number of nodes scheduled doesn't match the expected number!"' failed
          </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>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>This appears to be a recent regression, and the crash only triggers in the
32-bit mode, but not in the 64-bit mode. 


$ clang -v
clang version 5.0.0 (trunk 299862)
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/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

$ clang-4.0.0 -m32 -Os small.c
$ clang -m64 -Os small.c

$ clang -m32 -Os small.c
clang-5.0:
/tmp/llvm-builder/llvm-source-trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:696:
void llvm::ScheduleDAGSDNodes::VerifyScheduledSequence(bool): Assertion
`Sequence.size() - Noops == ScheduledNodes && "The number of nodes scheduled
doesn't match the expected number!"' failed.
#0 0x0000000001fa193a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1fa193a)
#1 0x0000000001f9f6be llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-5.0+0x1f9f6be)
#2 0x0000000001f9f832 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-5.0+0x1f9f832)
#3 0x00007ff6a27cd390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007ff6a1540428 gsignal
/build/glibc-9tT8Do/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007ff6a154202a abort /build/glibc-9tT8Do/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007ff6a1538bd7 __assert_fail_base
/build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
#7 0x00007ff6a1538c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00000000027cc285 (/usr/local/clang-trunk/bin/clang-5.0+0x27cc285)
#9 0x00000000027ca19f (anonymous namespace)::ScheduleDAGRRList::Schedule()
(/usr/local/clang-trunk/bin/clang-5.0+0x27ca19f)
#10 0x000000000274f33c llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang-5.0+0x274f33c)
#11 0x0000000002759ba9
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/usr/local/clang-trunk/bin/clang-5.0+0x2759ba9)
#12 0x000000000275b9c1
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone
.part.735] [clone .constprop.758]
(/usr/local/clang-trunk/bin/clang-5.0+0x275b9c1)
#13 0x00000000013f6ed4 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x13f6ed4)
#14 0x00000000018092b5
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x18092b5)
#15 0x0000000001b0ba73 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1b0ba73)
#16 0x0000000001b0bb3c llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1b0bb3c)
#17 0x0000000001b0b5dd llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1b0b5dd)
#18 0x000000000215cc70 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-5.0+0x215cc70)
#19 0x000000000281ac19
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-5.0+0x281ac19)
#20 0x0000000002bcc068 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-5.0+0x2bcc068)
#21 0x0000000002819f2a clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-5.0+0x2819f2a)
#22 0x00000000024e68e6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-5.0+0x24e68e6)
#23 0x00000000024b88a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x24b88a6)
#24 0x000000000256edea
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-5.0+0x256edea)
#25 0x0000000000a894a8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-5.0+0xa894a8)
#26 0x0000000000a1d6ec main (/usr/local/clang-trunk/bin/clang-5.0+0xa1d6ec)
#27 0x00007ff6a152b830 __libc_start_main
/build/glibc-9tT8Do/glibc-2.23/csu/../csu/libc-start.c:325:0
#28 0x0000000000a85b49 _start (/usr/local/clang-trunk/bin/clang-5.0+0xa85b49)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-5.0 -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/local/clang-trunk/lib/clang/5.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/clang-trunk/lib/clang/5.0.0/include
-internal-externc-isystem /usr/include/i386-linux-gnu -internal-externc-isystem
/include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir
/home/su -ferror-limit 19 -fmessage-length 160 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/small-e42cab.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-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 299862)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-5.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-5.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-5.0: note: diagnostic msg: /tmp/small-208ea8.c
clang-5.0: note: diagnostic msg: /tmp/small-208ea8.sh
clang-5.0: note: diagnostic msg: 

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



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


int a, b[1], c, d;

int fn1 (int e)
{
  return e && a ? e : a;
}

void fn2 ()
{
  int f;
  c = fn1 (c == b[f]);
  d = b[0] ? b[0] : a;
}

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>