<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 -div-rem-pairs crashes on code not reachable from entry"
   href="https://bugs.llvm.org/show_bug.cgi?id=45885">45885</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt -div-rem-pairs crashes on code not reachable from entry
          </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>Scalar Optimizations
          </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=23471" name="attach_23471" title="bbi-42695.ll reproducer">attachment 23471</a> <a href="attachment.cgi?id=23471&action=edit" title="bbi-42695.ll reproducer">[details]</a></span>
bbi-42695.ll reproducer

Reproduce with:
 opt -div-rem-pairs -S -o - bbi-42695.ll

Result:

opt: ../include/llvm/ADT/DenseMap.h:1241: llvm::DenseMapIterator::pointer
llvm::DenseMapIterator<llvm::BasicBlock *,
std::unique_ptr<llvm::DomTreeNodeBase<llvm::BasicBlock>,
std::default_delete<llvm::DomTreeNodeBase<llvm::BasicBlock> > >,
llvm::DenseMapInfo<llvm::BasicBlock *>,
llvm::detail::DenseMapPair<llvm::BasicBlock *,
std::unique_ptr<llvm::DomTreeNodeBase<llvm::BasicBlock>,
std::default_delete<llvm::DomTreeNodeBase<llvm::BasicBlock> > > >,
true>::operator->() const [KeyT = llvm::BasicBlock *, ValueT =
std::unique_ptr<llvm::DomTreeNodeBase<llvm::BasicBlock>,
std::default_delete<llvm::DomTreeNodeBase<llvm::BasicBlock> > >, KeyInfoT =
llvm::DenseMapInfo<llvm::BasicBlock *>, Bucket =
llvm::detail::DenseMapPair<llvm::BasicBlock *,
std::unique_ptr<llvm::DomTreeNodeBase<llvm::BasicBlock>,
std::default_delete<llvm::DomTreeNodeBase<llvm::BasicBlock> > > >, IsConst =
true]: Assertion `Ptr != End && "dereferencing end() iterator"' 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: ../../master/llvm/build-all-builtins/bin/opt
-div-rem-pairs -S -o - bbi-42695.ll 
1.      Running pass 'Function Pass Manager' on module 'bbi-42695.ll'.
2.      Running pass 'Hoist/decompose integer division and remainder' on
function '@g'
 #0 0x0000000004399a94 PrintStackTraceSignalHandler(void*)
(../../master/llvm/build-all-builtins/bin/opt+0x4399a94)
 #1 0x00000000043975ee llvm::sys::RunSignalHandlers()
(../../master/llvm/build-all-builtins/bin/opt+0x43975ee)
 #2 0x0000000004399dac SignalHandler(int)
(../../master/llvm/build-all-builtins/bin/opt+0x4399dac)
 #3 0x00007f1bb8a2c890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f1bb74d5e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f1bb74d7801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f1bb74c739a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f1bb74c7412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x000000000366f57f llvm::isGuaranteedNotToBeUndefOrPoison(llvm::Value
const*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int)
(../../master/llvm/build-all-builtins/bin/opt+0x366f57f)
 #9 0x0000000004096800 optimizeDivRem(llvm::Function&,
llvm::TargetTransformInfo const&, llvm::DominatorTree const&)
(../../master/llvm/build-all-builtins/bin/opt+0x4096800)
#10 0x0000000003c0a784 llvm::FPPassManager::runOnFunction(llvm::Function&)
(../../master/llvm/build-all-builtins/bin/opt+0x3c0a784)
#11 0x0000000003c0aa58 llvm::FPPassManager::runOnModule(llvm::Module&)
(../../master/llvm/build-all-builtins/bin/opt+0x3c0aa58)
#12 0x0000000003c0b0ad llvm::legacy::PassManagerImpl::run(llvm::Module&)
(../../master/llvm/build-all-builtins/bin/opt+0x3c0b0ad)
#13 0x0000000002430e05 main
(../../master/llvm/build-all-builtins/bin/opt+0x2430e05)
#14 0x00007f1bb74b8b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#15 0x000000000241b02a _start
(../../master/llvm/build-all-builtins/bin/opt+0x241b02a)
Abort (core dumped)

The input contains a basic block unreachable from entry that I suppose causes
the problem:

for.cond:                                         ; preds = %for.cond
  %rem = srem i16 1, %rem
  %div.i = sdiv i16 1, %rem
  br label %for.cond

Starts happening with 49f75132bc (which fixes
<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - DivRemPairs is incorrect in the presence of undef"
   href="show_bug.cgi?id=42619">https://bugs.llvm.org/show_bug.cgi?id=42619</a>):
    [DivRemPairs] Freeze operands if they can be undef values</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>