<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 -indvars -loop-deletion crashing with "Trip Count for Loop [...] Changed!""
   href="https://bugs.llvm.org/show_bug.cgi?id=47753">47753</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt -indvars -loop-deletion crashing with "Trip Count for Loop [...] Changed!"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.com
          </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=24030" name="attach_24030" title="bbi -48247.ll reproducer">attachment 24030</a> <a href="attachment.cgi?id=24030&action=edit" title="bbi -48247.ll reproducer">[details]</a></span>
bbi -48247.ll reproducer

llvm commit: dce03e3059f

Reproduce with:
 opt -S -o - bbi-48247.ll -indvars -loop-deletion

Result:
Trip Count for Loop at depth 1 containing:
%arrayinit.body11.i<header><latch><exiting>
 Changed!
Old: 9223372036854775807
New: 0
Delta: 9223372036854775807
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: ../../master/llvm/build-all/bin/opt -S -o -
bbi-48247.ll -indvars -loop-deletion 
1.      Running pass 'Function Pass Manager' on module 'bbi-48247.ll'.
2.      Running pass 'Loop Pass Manager' on function '@g'
3.      Running pass 'Delete dead loops' on basic block '<badref>'
 #0 0x00000000027d2723 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(../../master/llvm/build-all/bin/opt+0x27d2723)
 #1 0x00000000027d03ee llvm::sys::RunSignalHandlers()
(../../master/llvm/build-all/bin/opt+0x27d03ee)
 #2 0x00000000027d2bdc SignalHandler(int)
(../../master/llvm/build-all/bin/opt+0x27d2bdc)
 #3 0x00007f81189d78a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f8115ff9f47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f8115ffb8b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00000000019a6ec6 llvm::ScalarEvolution::verify() const
(../../master/llvm/build-all/bin/opt+0x19a6ec6)
 #7 0x0000000002890beb llvm::deleteDeadLoop(llvm::Loop*, llvm::DominatorTree*,
llvm::ScalarEvolution*, llvm::LoopInfo*, llvm::MemorySSA*)
(../../master/llvm/build-all/bin/opt+0x2890beb)
 #8 0x000000000255f075 deleteLoopIfDead(llvm::Loop*, llvm::DominatorTree&,
llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::MemorySSA*,
llvm::OptimizationRemarkEmitter&)
(../../master/llvm/build-all/bin/opt+0x255f075)
 #9 0x000000000255f9a9 (anonymous
namespace)::LoopDeletionLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) (../../master/llvm/build-all/bin/opt+0x255f9a9)
#10 0x00000000018e08db llvm::LPPassManager::runOnFunction(llvm::Function&)
(../../master/llvm/build-all/bin/opt+0x18e08db)
#11 0x000000000202274f llvm::FPPassManager::runOnFunction(llvm::Function&)
(../../master/llvm/build-all/bin/opt+0x202274f)
#12 0x0000000002028fe8 llvm::FPPassManager::runOnModule(llvm::Module&)
(../../master/llvm/build-all/bin/opt+0x2028fe8)
#13 0x0000000002022d1d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(../../master/llvm/build-all/bin/opt+0x2022d1d)
#14 0x000000000075e5f1 main (../../master/llvm/build-all/bin/opt+0x75e5f1)
#15 0x00007f8115fdcb97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#16 0x000000000074589a _start (../../master/llvm/build-all/bin/opt+0x74589a)
Abort (core dumped)

This starts happening with commit 60b852092c9:
    [LoopDeletion] Forget loop before setting values to undef

    After D71539, we need to forget the loop before setting the incoming
    values of phi nodes in exit blocks, because we are looking through those
    phi nodes now and the SCEV expression could depend on the loop phi. If
    we update the phi nodes before forgetting the loop, we miss those users
    during invalidation.

    Reviewed By: reames

    Differential Revision: <a href="https://reviews.llvm.org/D88167">https://reviews.llvm.org/D88167</a></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>