<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 - Opt component crashes using -simplifycfg -sroa -jump-threading -lcssa -loop-unroll"
   href="https://bugs.llvm.org/show_bug.cgi?id=47813">47813</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Opt component crashes using -simplifycfg -sroa -jump-threading -lcssa -loop-unroll
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>suochenyao@163.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>description:
Hi,
I guess I find a bug in clang.
Opt component crashes when using "-simplifycfg -sroa -jump-threading -lcssa
-loop-unroll".
But it doesn't occur under O0-O3 levels.
-----------------------------------------------------------------------------
clang version:
$ /home/suocy/bin/llvm-dev/bin/clang --version
clang version 12.0.0 (/home/suocy/src/llvm-dev/llvm-project/llvm/tools/clang
568035ac3955790aee2a5dbc2b1f4074c76bb4d7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/suocy/bin/llvm-dev/bin
-----------------------------------------------------------------------------
command line:
$ /home/suocy/bin/llvm-dev/bin/clang -c -emit-llvm -O3 -mllvm
-disable-llvm-optzns a.c -o a.bc
a.c:31:22: warning: expression result unused [-Wunused-value]
            k[3][0][1];
            ~~~~~~~ ~^
a.c:32:14: warning: equality comparison result unused [-Wunused-comparison]
          &n == &n;
          ~~~^~~~~
2 warnings generated.

$ /home/suocy/bin/llvm-dev/bin/opt -simplifycfg -sroa -jump-threading -lcssa
-loop-unroll a.bc -o a.opt.bc
PHI nodes must have at least one entry.  If the block is dead, the PHI should
be removed!
  %retval.3 = phi i32
in function i
LLVM ERROR: Broken function found, compilation aborted!
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0.      Program arguments: /home/suocy/bin/llvm-dev/bin/opt -simplifycfg -sroa
-jump-threading -lcssa -loop-unroll a.bc -o a.opt.bc
1.      Running pass 'Function Pass Manager' on module 'a.bc'.
2.      Running pass 'Module Verifier' on function '@i'
 #0 0x00000000029d923c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/suocy/bin/llvm-dev/bin/opt+0x29d923c)
 #1 0x00000000029d71e4 llvm::sys::RunSignalHandlers()
(/home/suocy/bin/llvm-dev/bin/opt+0x29d71e4)
 #2 0x00000000029d7343 SignalHandler(int)
(/home/suocy/bin/llvm-dev/bin/opt+0x29d7343)
 #3 0x00007f67f3c2f630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f67f281d387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f67f281ea78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x000000000294e964 llvm::report_fatal_error(llvm::Twine const&, bool)
(/home/suocy/bin/llvm-dev/bin/opt+0x294e964)
 #7 0x000000000294ea98 (/home/suocy/bin/llvm-dev/bin/opt+0x294ea98)
 #8 0x00000000022b658f (anonymous
namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&)
(/home/suocy/bin/llvm-dev/bin/opt+0x22b658f)
 #9 0x000000000223b7e8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/suocy/bin/llvm-dev/bin/opt+0x223b7e8)
#10 0x000000000223c289 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/suocy/bin/llvm-dev/bin/opt+0x223c289)
#11 0x000000000223b093 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/suocy/bin/llvm-dev/bin/opt+0x223b093)
#12 0x000000000071ee5e main (/home/suocy/bin/llvm-dev/bin/opt+0x71ee5e)
#13 0x00007f67f2809555 __libc_start_main (/lib64/libc.so.6+0x22555)
#14 0x00000000007cfb75 _start (/home/suocy/bin/llvm-dev/bin/opt+0x7cfb75)
Aborted

$ /home/suocy/bin/llvm-dev/bin/opt -O0 a.bc -o a.opt.bc
$ /home/suocy/bin/llvm-dev/bin/opt -O1 a.bc -o a.opt.bc
$ /home/suocy/bin/llvm-dev/bin/opt -O2 a.bc -o a.opt.bc
$ /home/suocy/bin/llvm-dev/bin/opt -O3 a.bc -o a.opt.bc
$ /home/suocy/bin/llvm-dev/bin/opt -Os a.bc -o a.opt.bc
-----------------------------------------------------------------------------
program:
union a {
  short b;
  short c;
};

int d=1, e=1;
long f=1L, g=1L;

long (h)() {
  return 0;
}

int i() {
  union a j;
  j.c=1;
  for (;; j.c = h()) {
    long k[4][3][4] = {g};
    k[3][0][1] = g;
    d = 0;
    for (; d >= 0;)
      return 0;
    for (;;) {
      if (j.c)
        ;
      else {
        int l=2;
        int *m = &l;
        int **n = &m;
        for (; f;) {
          for (; e;)
            k[3][0][1];
          &n == &n;
          return 0;
        }
      }
      if (j.b)
        break;
    }
  }
  return 0;
}

int main() {
  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>