<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 - loop-versioning crashes: Assertion `idx < size()' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=43322">43322</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>loop-versioning crashes: Assertion `idx < size()' 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>Transformation Utilities
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>cszide@163.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=22501" name="attach_22501" title="salsa20.c">attachment 22501</a> <a href="attachment.cgi?id=22501&action=edit" title="salsa20.c">[details]</a></span>
salsa20.c

In this bug, opt crashes for the program salsa20.c in testsuit with
loop-versioning pass.

$clang -v
clang version 10.0.0 (trunk 371952)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$clang -O3 -c -emit-llvm -femit-all-decls -mllvm -disable-llvm-optzns salsa20.c

$opt -licm -loop-rotate -loop-unroll -mem2reg -loop-versioning salsa20.bc

opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/include/llvm/ADT/SmallVector.h:153:
const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2>
<span class="quote">>::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2>
>::size_type) const [with T = llvm::RuntimePointerChecking::PointerInfo;</span >
<template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T,
<template-parameter-1-2> >::const_reference = const
llvm::RuntimePointerChecking::PointerInfo&; llvm::SmallVectorTemplateCommon<T,
<template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx <
size()' failed.
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt -licm
-loop-rotate -loop-unroll -mem2reg -loop-versioning salsa20.bc 
1.      Running pass 'Function Pass Manager' on module 'salsa20.bc'.
2.      Running pass 'Loop Versioning' on function '@salsa20'
 #0 0x000056373999e27a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x277727a)
 #1 0x000056373999bf54 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x2774f54)
 #2 0x000056373999c092 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x2775092)
 #3 0x00007fc518ad2890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007fc517784e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007fc517786801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007fc51777639a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007fc517776412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x0000563739a5f68f llvm::LoopVersioning::prepareNoAliasMetadata()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x283868f)
 #9 0x0000563739a601ec llvm::LoopVersioning::annotateLoopWithNoAlias()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x28391ec)
#10 0x0000563739a6256e (anonymous
namespace)::LoopVersioningPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x283b56e)
#11 0x00005637392ddde9 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6de9)
#12 0x00005637392ddee1 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6ee1)
#13 0x00005637392dd041 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6041)
#14 0x0000563737ab674f main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x88f74f)
#15 0x00007fc517767b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#16 0x0000563737b2e54a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x90754a)
Aborted (core dumped)

By using bugpoint, the optimization sequence can be further reduced.

$opt bugpoint-reduced-simplified.bc -loop-versioning

opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/include/llvm/ADT/SmallVector.h:153:
const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2>
<span class="quote">>::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2>
>::size_type) const [with T = llvm::RuntimePointerChecking::PointerInfo;</span >
<template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T,
<template-parameter-1-2> >::const_reference = const
llvm::RuntimePointerChecking::PointerInfo&; llvm::SmallVectorTemplateCommon<T,
<template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx <
size()' failed.
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt
bugpoint-reduced-simplified.bc -loop-versioning 
1.      Running pass 'Function Pass Manager' on module
'bugpoint-reduced-simplified.bc'.
2.      Running pass 'Loop Versioning' on function '@salsa20'
 #0 0x0000562055ca427a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x277727a)
 #1 0x0000562055ca1f54 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x2774f54)
 #2 0x0000562055ca2092 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x2775092)
 #3 0x00007fc495a0a890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007fc4946bce97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007fc4946be801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007fc4946ae39a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007fc4946ae412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x0000562055d6568f llvm::LoopVersioning::prepareNoAliasMetadata()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x283868f)
 #9 0x0000562055d661ec llvm::LoopVersioning::annotateLoopWithNoAlias()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x28391ec)
#10 0x0000562055d6856e (anonymous
namespace)::LoopVersioningPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x283b56e)
#11 0x00005620555e3de9 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6de9)
#12 0x00005620555e3ee1 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6ee1)
#13 0x00005620555e3041 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x20b6041)
#14 0x0000562053dbc74f main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x88f74f)
#15 0x00007fc49469fb97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#16 0x0000562053e3454a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build9/bin/opt+0x90754a)
Aborted (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>