<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 code with crc32 builtin on x86_64-linux-gnu (in pass 'X86 DAG->DAG Instruction Selection')"
   href="https://llvm.org/bugs/show_bug.cgi?id=28635">28635</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on code with crc32 builtin on x86_64-linux-gnu (in pass 'X86 DAG->DAG Instruction Selection')
          </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 crashes when compiling the following test case on
x86_64-linux-gnu in the 32-bit mode (but not in the 64-bit mode). 

It seems to also affect all previous versions of clang since at least as early
as 3.2.x.


$ clang -v
clang version 4.0.0 (trunk 276092)
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.3
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.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.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.1.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 -m64 -c small.c
$
$ clang -m32 -c small.c
ExpandIntegerResult #0: t3: i64 = llvm.x86.sse42.crc32.64.64
TargetConstant:i32<5889>, Constant:i64<0>, Constant:i64<0>

Do not know how to expand the result of this operator!
UNREACHABLE executed at
/tmp/llvm-builder/llvm-source-trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:1293!
#0 0x0000000001d8fa95 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8fa95)
#1 0x0000000001d8db4e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8db4e)
#2 0x0000000001d8dcb0 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d8dcb0)
#3 0x00007f50bc6e8340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f50bb4d9cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f50bb4dd0d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x0000000001d41afa (/usr/local/clang-trunk/bin/clang-4.0+0x1d41afa)
#7 0x00000000025162b6
llvm::DAGTypeLegalizer::ExpandIntegerResult(llvm::SDNode*, unsigned int)
(/usr/local/clang-trunk/bin/clang-4.0+0x25162b6)
#8 0x000000000249ee72 llvm::DAGTypeLegalizer::run()
(/usr/local/clang-trunk/bin/clang-4.0+0x249ee72)
#9 0x000000000249fb6a llvm::SelectionDAG::LegalizeTypes()
(/usr/local/clang-trunk/bin/clang-4.0+0x249fb6a)
#10 0x000000000246649c llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang-4.0+0x246649c)
#11 0x000000000246ee52
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/usr/local/clang-trunk/bin/clang-4.0+0x246ee52)
#12 0x000000000247127f
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x247127f)
#13 0x000000000138ac84 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x138ac84)
#14 0x00000000017473a5
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x17473a5)
#15 0x00000000019e8403 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x19e8403)
#16 0x00000000019e8a0b llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x19e8a0b)
#17 0x0000000001efc489 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
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+0x1efc489)
#18 0x000000000252517f
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252517f)
#19 0x000000000289369d clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x289369d)
#20 0x00000000025254fe clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x25254fe)
#21 0x00000000022300de clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x22300de)
#22 0x00000000022058d6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x22058d6)
#23 0x00000000022be422
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x22be422)
#24 0x0000000000b18c38 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb18c38)
#25 0x0000000000ac7637 main (/usr/local/clang-trunk/bin/clang-4.0+0xac7637)
#26 0x00007f50bb4c4ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#27 0x0000000000b14c64 _start (/usr/local/clang-trunk/bin/clang-4.0+0xb14c64)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple
i386-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu
pentium4 -dwarf-column-info -debugger-tuning=gdb -coverage-file /data2/small.c
-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
/include -internal-externc-isystem /usr/include -fdebug-compilation-dir /data2
-ferror-limit 19 -fmessage-length 141 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -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 '@foo'
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 276092)
Target: i386-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-c3a458.c
clang-4.0: note: diagnostic msg: /tmp/small-c3a458.sh
clang-4.0: note: diagnostic msg:

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


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


__attribute__ ((target ("sse4.2")))
int foo ()

  return __builtin_ia32_crc32di (0, 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>