[llvm-bugs] [Bug 37651] New: Assertion `SE->DT.dominates(ENT.ExitingBlock, Latch) && "We should only have known counts for exiting blocks that dominate " "latch!"' failed. with -iv-users -simple-loop-unswitch -indvars

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 1 01:54:30 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37651

            Bug ID: 37651
           Summary: Assertion `SE->DT.dominates(ENT.ExitingBlock, Latch)
                    && "We should only have known counts for exiting
                    blocks that dominate " "latch!"' failed. with
                    -iv-users -simple-loop-unswitch -indvars
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20381
  --> https://bugs.llvm.org/attachment.cgi?id=20381&action=edit
reduced reproducer

opt -iv-users -simple-loop-unswitch -indvars -S -o - bbi-14845.ll

gives

opt: ../lib/Analysis/ScalarEvolution.cpp:6728: const llvm::SCEV
*llvm::ScalarEvolution::BackedgeTakenInfo::getExact(const llvm::Loop *,
llvm::ScalarEvolution *, llvm::SCEVUnionPredicate *) const: Assertion
`SE->DT.dominates(ENT.ExitingBlock, Latch) && "We should only have known counts
for exiting blocks that dominate " "latch!"' failed.
Stack dump:
0.      Program arguments: build-all/bin/opt -iv-users -simple-loop-unswitch
-indvars -S -o - bbi-14845.ll 
1.      Running pass 'Function Pass Manager' on module 'bbi-14845.ll'.
2.      Running pass 'Loop Pass Manager' on function '@f1'
3.      Running pass 'Induction Variable Simplification' on basic block '%bb3'
#0 0x00000000021a48a4 PrintStackTraceSignalHandler(void*)
(build-all/bin/opt+0x21a48a4)
#1 0x00000000021a2b80 llvm::sys::RunSignalHandlers()
(build-all/bin/opt+0x21a2b80)
#2 0x00000000021a4c08 SignalHandler(int) (build-all/bin/opt+0x21a4c08)
#3 0x00007f44eec51330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f44ed840c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f44ed844028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f44ed839bf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f44ed839ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000017475b6
llvm::ScalarEvolution::BackedgeTakenInfo::getExact(llvm::Loop const*,
llvm::ScalarEvolution*, llvm::SCEVUnionPredicate*) const
(build-all/bin/opt+0x17475b6)
#9 0x0000000001f9ef1a (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
(build-all/bin/opt+0x1f9ef1a)
#10 0x0000000001fa44fc (anonymous
namespace)::IndVarSimplifyLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) (build-all/bin/opt+0x1fa44fc)
#11 0x00000000016d0885 llvm::LPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x16d0885)
#12 0x0000000001c2567a llvm::FPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x1c2567a)
#13 0x0000000001c258d8 llvm::FPPassManager::runOnModule(llvm::Module&)
(build-all/bin/opt+0x1c258d8)
#14 0x0000000001c25e0d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(build-all/bin/opt+0x1c25e0d)
#15 0x000000000077058c main (build-all/bin/opt+0x77058c)
#16 0x00007f44ed82bf45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#17 0x0000000000759a5d _start (build-all/bin/opt+0x759a5d)
Abort

This started happening with commit r328611:

    [SCEV] Make exact taken count calculation more optimistic

    Currently, `getExact` fails if it sees two exit counts in different blocks.
There is
    no solid reason to do so, given that we only calculate exact non-taken
count
    for exiting blocks that dominate latch. Using this fact, we can simply take
min
    out of all exits of all blocks to get the exact taken count.

    This patch makes the calculation more optimistic with enforcing our
assumption
    with asserts. It allows us to calculate exact backedge taken count in
trivial loops
    like

      for (int i = 0; i < 100; i++) {
        if (i > 50) break;
        . . .
      }

    Differential Revision: https://reviews.llvm.org/D44676
    Reviewed By: fhahn


    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328611
91177308-0d34-0410-b5e6-96231b3b80d8

Found when running random passes on random input. We don't normally use
-iv-users -simple-loop-unswitch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180601/6a4325e9/attachment-0001.html>


More information about the llvm-bugs mailing list