<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 in 32-bit mode"
   href="http://llvm.org/bugs/show_bug.cgi?id=19594">19594</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and above on x86_64-linux-gnu in 32-bit mode
          </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 testcase at -Os
and above on x86_64-linux-gnu in 32-bit (but not 64-bit) mode. 

This is a regression from clang 3.4.


$ clang-trunk -v
clang version 3.5.0 (trunk 207415)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.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.6
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.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

$ clang-trunk -m32 -O1 small.c; a.out
$ clang-trunk -m64 -Os small.c; a.out
$ clang-3.4 -m32 -Os small.c; a.out

$ clang-trunk -m32 -Os small.c
clang: /tmp/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp:1701: virtual
void {anonymous}::RegReductionPQBase::remove(llvm::SUnit*): Assertion
`SU->NodeQueueId != 0 && "Not in queue!"' failed.
0  clang           0x0000000002761f92 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  clang           0x0000000002761b79
2  libpthread.so.0 0x00007f5d4f20dcb0
3  libc.so.6       0x00007f5d4e233425 gsignal + 53
4  libc.so.6       0x00007f5d4e236b8b abort + 379
5  libc.so.6       0x00007f5d4e22c0ee
6  libc.so.6       0x00007f5d4e22c192
7  clang           0x0000000001fae9f8
8  clang           0x0000000001fbce7a
9  clang           0x0000000001f3cec2
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1506
10 clang           0x0000000001f4116c
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1628
11 clang           0x0000000001f42d55
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 981
12 clang           0x00000000026f177f
llvm::FPPassManager::runOnFunction(llvm::Function&) + 639
13 clang           0x00000000026f17cb
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
14 clang           0x00000000026f2dff
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 863
15 clang           0x00000000008d8306
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) +
3046
16 clang           0x00000000008d2fae
17 clang           0x0000000000aa1ad2 clang::ParseAST(clang::Sema&, bool, bool)
+ 514
18 clang           0x00000000008d4da1 clang::CodeGenAction::ExecuteAction() +
97
19 clang           0x00000000007126c6 clang::FrontendAction::Execute() + 182
20 clang           0x00000000006f00ed
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 349
21 clang           0x00000000006d4e3d
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1277
22 clang           0x00000000006ccd48 cc1_main(char const**, char const**, char
const*, void*) + 1240
23 clang           0x00000000006d2f9d main + 797
24 libc.so.6       0x00007f5d4e21e76d __libc_start_main + 237
25 clang           0x00000000006cbaf9
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu pentium4 -target-linker-version 2.22
-momit-leaf-frame-pointer -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.5.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.5.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir
/data2/c-hunter-results/C/trans-bugs/REDUCED/20140423-clang-m32-O2-O3-build-test68217
-ferror-limit 19 -fmessage-length 123 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/small-1ddcd6.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 '@main'
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.5.0 (trunk 207415)
Target: i386-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-f40b07.c
clang: note: diagnostic msg: /tmp/small-f40b07.sh
clang: note: diagnostic msg: 

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



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


int a[1], b;

void
foo (int p)
{
  b = a[b] ^ p;
}

#pragma pack(1)
struct
{
  int:19;
  int:28;
  int:14;
  int:2;
  int f1:9;
  int:28;
  int f2:10;
  int f3:23;
  int f4;
} c;

int
main ()
{
  if (c.f4)
    c.f3 = 0;
  foo (c.f1 >> 24 & 1);
  foo (c.f2 >> 24 & 1);
  foo (c.f3 >> 16 & 1);
  foo (c.f3 >> 24 & 1);
  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>