[llvm-bugs] [Bug 45885] New: opt -div-rem-pairs crashes on code not reachable from entry

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 12 04:37:38 PDT 2020


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

            Bug ID: 45885
           Summary: opt -div-rem-pairs crashes on code not reachable from
                    entry
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23471
  --> https://bugs.llvm.org/attachment.cgi?id=23471&action=edit
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 https://bugs.llvm.org/ 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
https://bugs.llvm.org/show_bug.cgi?id=42619):
    [DivRemPairs] Freeze operands if they can be undef values

-- 
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/20200512/45859f97/attachment.html>


More information about the llvm-bugs mailing list