<html>
    <head>
      <base href="https://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 with "-mllvm -enable-newgvn": Do not know how to expand the result of this operator!"
   href="https://bugs.llvm.org/show_bug.cgi?id=33041">33041</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes with "-mllvm -enable-newgvn": Do not know how to expand the result of this operator!
          </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>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>helloqirun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code crashes the current trunk version at "-O2" and above in
32-bit mode with "-mllvm -enable-newgvn". The 64-bit mode also crashes but the
error message is similar to PR32945.


$ clang-trunk --version
clang version 5.0.0 (trunk 303041)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

$ clang-trunk -O2 -mllvm -enable-newgvn -m32 abc.c
abc.c:6:5: warning: incompatible pointer to integer conversion assigning to
'long' from 'long long *' [-Wint-conversion]
  c = &f;
    ^ ~~
abc.c:14:3: warning: expression result unused [-Wunused-value]
  b - f ?: (*g &= 9);
  ^~~~~~~~~~~~~~~~~~
ExpandIntegerResult #0: t5: i64 = llvm.ssa.copy TargetConstant:i32<136>, t3

Do not know how to expand the result of this operator!
UNREACHABLE executed at
/home/absozero/trunk/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:1345!
#0 0x0000000001c8f004 PrintStackTraceSignalHandler(void*)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c8f004)
#1 0x0000000001c8f336 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c8f336)
#2 0x00007faf9770e330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#3 0x00007faf9628bc37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#4 0x00007faf9628f028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#5 0x0000000001c47ecb (/home/absozero/trunk/root-clang/bin/clang-5.0+0x1c47ecb)
#6 0x00000000024f0d8a
llvm::DAGTypeLegalizer::ExpandIntegerResult(llvm::SDNode*, unsigned int)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x24f0d8a)
#7 0x0000000002487845 llvm::DAGTypeLegalizer::run()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x2487845)
#8 0x000000000248dede llvm::SelectionDAG::LegalizeTypes()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x248dede)
#9 0x000000000244ab5c llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x244ab5c)
#10 0x000000000244907a
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x244907a)
#11 0x0000000002445762
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x2445762)
#12 0x0000000001178441 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1178441)
#13 0x000000000155f1b4
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x155f1b4)
#14 0x000000000183018f llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x183018f)
#15 0x00000000018303e3 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x18303e3)
#16 0x00000000018308e5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x18308e5)
#17 0x0000000001e1679f 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> >)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x1e1679f)
#18 0x000000000250d387
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x250d387)
#19 0x0000000002969ca6 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x2969ca6)
#20 0x00000000021e8af8 clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x21e8af8)
#21 0x000000000219bb01
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x219bb01)
#22 0x000000000226b0bd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x226b0bd)
#23 0x000000000083d4fc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-5.0+0x83d4fc)
#24 0x000000000083b495 main
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x83b495)
#25 0x00007faf96276f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#26 0x0000000000838649 _start
(/home/absozero/trunk/root-clang/bin/clang-5.0+0x838649)
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-5.0 -cc1
-triple i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.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
/home/absozero/trunk/root-clang/lib/clang/5.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/5.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -enable-newgvn -o
/tmp/abc-c151f5.o -x c abc.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'abc.c'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@fn1'
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 303041)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/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/abc-952a6c.c
clang-5.0: note: diagnostic msg: /tmp/abc-952a6c.sh
clang-5.0: note: diagnostic msg:

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


$ cat abc.c
long a, c;
short b, e;
int d;
void fn1() {
  long long f = 0;
  c = &f;
  e = a = e;
  long long *g = &f;
  a = a / (0 == (*g ^= 2));
  if (a & 2)
    ;
  else
    f = d;
  b - f ?: (*g &= 9);
}</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>