<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 crashes with "opt -gvn-hoist": Assertion `dominates(MD, U) && "Memory Def does not dominate it's uses"' failed"
   href="https://bugs.llvm.org/show_bug.cgi?id=36635">36635</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt crashes with "opt -gvn-hoist": Assertion `dominates(MD, U) && "Memory Def does not dominate it's uses"' failed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Vsevolod.Livinskij@frtk.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20016" name="attach_20016" title="Reproducer.">attachment 20016</a> <a href="attachment.cgi?id=20016&action=edit" title="Reproducer.">[details]</a></span>
Reproducer.

opt with -O3 -gvn-hoist fails assertion Assertion `dominates(MD, U) && "Memory
Def does not dominate it's uses"' failed.

Don't pay attention to weird form of ternary operator. It occurred during
automated reduction. Original full reproducer (see attachment) is a valid c++
code without this form, and it also fails with the same assertion.
P.S. if you know how to disable this GCC extension in clang, I would appreciate
if you tell me.

Reproducer:
<span class="quote">>$ cat repr.cpp</span >
int a, b, d;
char c, e, f, g;
void h() {
  if (!!b ?: a && c)
    if (f) {
      (b ? 0 : a && c) ? b ?: a && 0 : (b ?: a && c) || 0 & e;
      d = 0;
      b ?: a &&c || e;
    }
  if ((b ? 0 : a && c) || ~e)
    g = 905728;
}

Error:
<span class="quote">>$ clang++  -std=c++11 -w -O3 -Xclang -disable-llvm-optzns -emit-llvm -c -o repr.bc repr.cpp ; opt  -O3 -o repr.ll repr.bc -gvn-hoist</span >
opt: llvm/llvm-trunk/lib/Analysis/MemorySSA.cpp:1694: void
llvm::MemorySSA::verifyDomination(llvm::Function&) const: Assertion
`dominates(MD, U) && "Memory Def does not dominate it's uses"' failed.
LLVMSymbolizer: error reading file: No such file or directory
#0 0x000000000143b0fa (opt+0x143b0fa)
#1 0x00000000014391de (opt+0x14391de)
#2 0x0000000001439342 (opt+0x1439342)
#3 0x00007f8826ef4100 __restore_rt (/lib64/libpthread.so.0+0xf100)
#4 0x00007f8825a705f7 __GI_raise (/lib64/libc.so.6+0x355f7)
#5 0x00007f8825a71ce8 __GI_abort (/lib64/libc.so.6+0x36ce8)
#6 0x00007f8825a69566 __assert_fail_base (/lib64/libc.so.6+0x2e566)
#7 0x00007f8825a69612 (/lib64/libc.so.6+0x2e612)
#8 0x0000000000a1fddc (opt+0xa1fddc)
#9 0x0000000000a1fe19 (opt+0xa1fe19)
#10 0x0000000000f273c9 (opt+0xf273c9)
#11 0x0000000000f2a8ba (opt+0xf2a8ba)
#12 0x0000000000f2aa3c (opt+0xf2aa3c)
#13 0x0000000000f2b2df (opt+0xf2b2df)
#14 0x00000000005ea0ad (opt+0x5ea0ad)
#15 0x00007f8825a5cb15 __libc_start_main (/lib64/libc.so.6+0x21b15)
#16 0x0000000000628f09 (opt+0x628f09)
Stack dump:
0.      Program arguments: opt -O3 -o repr.ll repr.bc -gvn-hoist
1.      Running pass 'Function Pass Manager' on module 'repr.bc'.
Aborted (core dumped)

LLVM version:
<span class="quote">>$ clang++ -v</span >
clang version 7.0.0 (trunk 326547)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64</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>