<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 at -O1: Assertion `MBB != &MF->front() && "Can't find reaching def for virtreg"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=37080">37080</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes at -O1: Assertion `MBB != &MF->front() && "Can't find reaching def for virtreg"' 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>Linux
          </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>It happens at 32-bit mode only.  64-bit mode works fine.

It appears to be a backend issue.

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



$ clang-trunk -m32 -O1 abc.c
abc.c:7:8: warning: incompatible pointer types initializing 'int *' with an
expression of type 'void ()' [-Wincompatible-pointer-types]
  int *g = fn1;
       ^   ~~~
abc.c:9:7: warning: incompatible pointer types assigning to 'int *' from 'long
*' [-Wincompatible-pointer-types]
    g = &e;
      ^ ~~
clang-7: /home/absozero/trunk/llvm/lib/CodeGen/LiveVariables.cpp:113: void
llvm::LiveVariables::MarkVirtRegAliveInBlock(llvm::LiveVariables::VarInfo&,
llvm::MachineBasicBlock*, llvm::MachineBasicBlock*,
std::vector<llvm::MachineBasicBlock*>&): Assertion `MBB != &MF->front() &&
"Can't find reaching def for virtreg"' failed.
#0 0x000000000223db4a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x223db4a)
#1 0x000000000223b9ee llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-7+0x223b9ee)
#2 0x000000000223bb42 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-7+0x223bb42)
#3 0x00007f3a78146330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f3a76cc3c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f3a76cc7028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f3a76cbcbf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f3a76cbcca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000001993216 (/home/absozero/trunk/root-clang/bin/clang-7+0x1993216)
#9 0x0000000001993255
llvm::LiveVariables::MarkVirtRegAliveInBlock(llvm::LiveVariables::VarInfo&,
llvm::MachineBasicBlock*, llvm::MachineBasicBlock*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1993255)
#10 0x0000000001993969 llvm::LiveVariables::HandleVirtRegUse(unsigned int,
llvm::MachineBasicBlock*, llvm::MachineInstr&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1993969)
#11 0x0000000001998cd4 llvm::LiveVariables::runOnInstr(llvm::MachineInstr&,
llvm::SmallVectorImpl<unsigned int>&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1998cd4)
#12 0x0000000001999320
llvm::LiveVariables::runOnBlock(llvm::MachineBasicBlock*, unsigned int)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1999320)
#13 0x000000000199a29c
llvm::LiveVariables::runOnMachineFunction(llvm::MachineFunction&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x199a29c)
#14 0x00000000019e654d
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x19e654d)
#15 0x0000000001d465e3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1d465e3)
#16 0x0000000001d466ac llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1d466ac)
#17 0x0000000001d4617d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x1d4617d)
#18 0x00000000024082ec (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/absozero/trunk/root-clang/bin/clang-7+0x24082ec)
#19 0x0000000002409aa1 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-7+0x2409aa1)
#20 0x0000000002c68e47
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x2c68e47)
#21 0x0000000003195900 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-7+0x3195900)
#22 0x0000000002c681fc clang::CodeGenAction::ExecuteAction()
(/home/absozero/trunk/root-clang/bin/clang-7+0x2c681fc)
#23 0x000000000280367e clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-7+0x280367e)
#24 0x00000000027cf8a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-7+0x27cf8a6)
#25 0x0000000002897d20
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-7+0x2897d20)
#26 0x0000000000a9de18 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-7+0xa9de18)
#27 0x0000000000a1121c main
(/home/absozero/trunk/root-clang/bin/clang-7+0xa1121c)
#28 0x00007f3a76caef45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#29 0x0000000000a99de9 _start
(/home/absozero/trunk/root-clang/bin/clang-7+0xa99de9)
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-7 -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 -dwarf-column-info
-debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir
/home/absozero/trunk/root-clang/lib/clang/7.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/7.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 142 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/abc-1bd7ab.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 'Live Variable Analysis' on function '@fn1'
clang-7: error: unable to execute command: Aborted (core dumped)
clang-7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 329676)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-7: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7: note: diagnostic msg: /tmp/abc-434316.c
clang-7: note: diagnostic msg: /tmp/abc-434316.sh
clang-7: note: diagnostic msg: 

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



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