<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 -enable-new-pm=0 -loop-deletion fails with Assertion `!isInvalid() && "Loop not in a valid state!"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=49967">49967</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt -enable-new-pm=0 -loop-deletion fails with Assertion `!isInvalid() && "Loop not in a valid state!"' failed.
          </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=24755" name="attach_24755" title="bbi-55148.ll reproducer">attachment 24755</a> <a href="attachment.cgi?id=24755&action=edit" title="bbi-55148.ll reproducer">[details]</a></span>
bbi-55148.ll reproducer

llvm commit: c3f12714641

Reproduce with:
 opt -enable-new-pm=0 -loop-deletion -o /dev/null bbi-55148.ll

Result:
opt: ../include/llvm/Analysis/LoopInfo.h:123: bool
llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::contains(const LoopT *) const
[BlockT = llvm::BasicBlock, LoopT = llvm::Loop]: Assertion `!isInvalid() &&
"Loop not in a valid state!"' failed.
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: /repo/uabelho/master-github/llvm/build-all/bin/opt
-enable-new-pm=0 -loop-deletion -o /dev/null bbi-55148.ll
1.      Running pass 'Function Pass Manager' on module 'bbi-55148.ll'.
2.      Running pass 'Loop Pass Manager' on function '@test'
3.      Running pass 'Delete dead loops' on basic block '%vector.ph'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x294f683]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x294d33e]
/repo/uabelho/master-github/llvm/build-all/bin/opt[0x294fb46]
/lib64/libpthread.so.0(+0xf630)[0x7f8cb537e630]
/lib64/libc.so.6(gsignal+0x37)[0x7f8cb2ab1387]
/lib64/libc.so.6(abort+0x148)[0x7f8cb2ab2a78]
/lib64/libc.so.6(+0x2f1a6)[0x7f8cb2aaa1a6]
/lib64/libc.so.6(+0x2f252)[0x7f8cb2aaa252]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution18computeSCEVAtScopeEPKNS_4SCEVEPKNS_4LoopE+0xf76)[0x1aa7116]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution14getSCEVAtScopeEPKNS_4SCEVEPKNS_4LoopE+0x7c)[0x1a9f2cc]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution24computeExitLimitFromICmpEPKNS_4LoopEPNS_8ICmpInstEbbb+0x9a)[0x1a9d77a]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution28computeExitLimitFromCondImplERNS0_14ExitLimitCacheEPKNS_4LoopEPNS_5ValueEbbb+0xd8)[0x1a9cee8]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution30computeExitLimitFromCondCachedERNS0_14ExitLimitCacheEPKNS_4LoopEPNS_5ValueEbbb+0xe7)[0x1a9ca27]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution16computeExitLimitEPKNS_4LoopEPNS_10BasicBlockEb+0x5d0)[0x1a9c140]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution25computeBackedgeTakenCountEPKNS_4LoopEb+0x290)[0x1a98c10]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution20getBackedgeTakenInfoEPKNS_4LoopE+0x1ba)[0x1a9738a]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm15ScalarEvolution21getBackedgeTakenCountEPKNS_4LoopENS0_13ExitCountKindE+0x24)[0x1a983f4]
/repo/uabelho/master-github/llvm/build-all/bin/opt[0x26d5f6c]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm13LPPassManager13runOnFunctionERNS_8FunctionE+0x75b)[0x19eb04b]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x47f)[0x2155e5f]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x38)[0x215c7b8]
/repo/uabelho/master-github/llvm/build-all/bin/opt(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x35d)[0x215642d]
/repo/uabelho/master-github/llvm/build-all/bin/opt(main+0x3137)[0x7808a7]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f8cb2a9d555]
/repo/uabelho/master-github/llvm/build-all/bin/opt[0x76b8f5]
Abort

This starts happening with commit faf9f11589ce:
    [SCEV] Don't walk uses of phis without SCEV expression when forgetting

    I've run into some cases where a large fraction of compile-time is
    spent invalidating SCEV. One of the causes is forgetLoop(), which
    walks all values that are def-use reachable from the loop header
    phis. When invalidating a topmost loop, that might be close to all
    values in a function. Additionally, it's fairly common for there to
    not actually be anything to invalidate, but we'll still be performing
    this walk again and again.

    My first thought was that we don't need to continue walking the uses
    if the current value doesn't have a SCEV expression. However, this
    isn't quite right, because SCEV construction can skip over values
    (e.g. for a chain of adds, we might only create a SCEV expression
    for the final value).

    What this patch does instead is to only walk the (full) def-use chain
    of loop phis that have a SCEV expression. If there's no expression
    for a phi, then we also don't have any dependent expressions to
    invalidate.

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