<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 - UNREACHABLE executed at /usr/src/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp:214!"
   href="https://bugs.llvm.org/show_bug.cgi?id=48527">48527</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UNREACHABLE executed at /usr/src/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp:214!
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pkubaj@anongoth.pl
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>FreeBSD head, powerpc64 (happens also on powerpc, powerpcspe and powerpc64le),
llvm 11.0.0

Happens during build of ceph 12.2.12.

Test case:
template <class a> struct b { typedef a c; };
typedef enum { j } d;
struct e {
  _Atomic(int) f;
} g;
class h {
public:
  bool m_fn1() const;
  int k;
};
bool h::m_fn1() const {
  int l;
  for (int i = 0; i < k; ++i) {
    d m = j, o = m;
    int n;
    using p = b<decltype(g.f)>::c *;
    n = __c11_atomic_load(p(&g), o);
    l = n;
    char af = n;
    if (af)
      return false;
  }
  return true;
}
class q {
  bool r() const;
  h s;
};
struct t {
  long ah;
  long ai;
};
__thread t aj;
#define ak(al, am) aj.al = am;
bool q::r() const {
  if (s.m_fn1())
    ak(ah, 1) else ak(ai, 1) return false;
}

Execute:
/usr/bin/c++ -cc1 -triple powerpc64-unknown-freebsd13.0 -emit-obj -O2
plain_table_reader-ca874a.cpp

Result:
Invalid PPC CTR loop!
UNREACHABLE executed at
/usr/src/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp:214!
PLEASE submit a bug report to <a href="https://bugs.freebsd.org/submit/">https://bugs.freebsd.org/submit/</a> and include the
crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/c++ -cc1 -triple
powerpc64-unknown-freebsd13.0 -emit-obj -O2 plain_table_reader-ca874a.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module
'plain_table_reader-ca874a.cpp'.
4.      Running pass 'PowerPC CTR Loops Verify' on function '@_ZNK1q1rEv'
#0 0x00000000140a5c7c PrintStackTrace
/usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
#1 0x00000000140a3268 RunSignalHandlers
/usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:67:5
#2 0x00000000140a684c SignalHandler
/usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
#3 0x0000000815ecba80 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:303:3
Abort trap (core dumped)</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>