[llvm-bugs] [Bug 43426] New: licm crashes with segmentation fault

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 24 02:50:40 PDT 2019


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

            Bug ID: 43426
           Summary: licm crashes with segmentation fault
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: cszide at 163.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 22558
  --> https://bugs.llvm.org/attachment.cgi?id=22558&action=edit
.bc file of the source code

$clang -v
clang version 10.0.0 (trunk 372364)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/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 small.c

$opt -early-cse-memssa -licm  -jump-threading -instcombine -licm small.bc -o
small-opt.bc
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt
-early-cse-memssa -licm -jump-threading -instcombine -licm small.bc -o
small-opt.bc 
1.      Running pass 'Function Pass Manager' on module 'small.bc'.
2.      Running pass 'Loop Pass Manager' on function '@d'
3.      Running pass 'Loop Invariant Code Motion' on basic block '%for.body'
  #0 0x000055c5fd132dca llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x277adca)
  #1 0x000055c5fd130aa4 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2778aa4)
  #2 0x000055c5fd130be2 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2778be2)
  #3 0x00007f3b65799890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
  #4 0x000055c5fc442fe9
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8afe9)
  #5 0x000055c5fc44427e
llvm::MemorySSAUpdater::getPreviousDefFromEnd(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8c27e)
  ...
  ...
  ...
#254 0x000055c5fc4430cb
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8b0cb)
#255 0x000055c5fc44427e
llvm::MemorySSAUpdater::getPreviousDefFromEnd(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8c27e)
Segmentation fault (core dumped)

By using bugpoint, the optimization sequence can be reduced to "-licm"

$opt bugpoint-reduced-simplified.bc -licm

Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt
bugpoint-reduced-simplified.bc -licm 
1.      Running pass 'Function Pass Manager' on module
'bugpoint-reduced-simplified.bc'.
2.      Running pass 'Loop Pass Manager' on function '@d'
3.      Running pass 'Loop Invariant Code Motion' on basic block '%for.body'
  #0 0x0000563bb2d92dca llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x277adca)
  #1 0x0000563bb2d90aa4 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2778aa4)
  #2 0x0000563bb2d90be2 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x2778be2)
  #3 0x00007f83e0c10890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
  #4 0x0000563bb20a41d6
llvm::MemorySSAUpdater::getPreviousDefFromEnd(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8c1d6)
  ...
  ...
  ...
#255 0x0000563bb20a30cb
llvm::MemorySSAUpdater::getPreviousDefRecursive(llvm::BasicBlock*,
llvm::DenseMap<llvm::BasicBlock*, llvm::TrackingVH<llvm::MemoryAccess>,
llvm::DenseMapInfo<llvm::BasicBlock*>,
llvm::detail::DenseMapPair<llvm::BasicBlock*,
llvm::TrackingVH<llvm::MemoryAccess> > >&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build10/bin/opt+0x1a8b0cb)
Segmentation fault (core dumped)

----------------------------------------------------------
char a;
int b, c;
char d() {
  int e;
  for (; 5; e++) {
    int f;
    {
      int g;
      long h;
      {
        int i;
        e = 0;
        for (; e < 2; e++)
          ;
        for (; 6;)
          return 0;
        for (; 0;)
          for (;;) {
            int l;
            break;
          }
      }
      if (c) {
        int m, n;
        for (;;) {
          int o, e;
          char p, q;
          if (a)
            break;
          ++m;
          if (b)
            continue;
          n = f = 0;
        }
      } else {
        for (; 0 == 0;) {
          long r;
          int s, t, e, j, k;
          if (d)
            continue;
        }
        for (; 0;)
          return a;
        for (;; h--) {
          int u;
          if (g)
            break;
        }
      }
    }
  }
  return 0;
}

-- 
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/20190924/91358e2a/attachment.html>


More information about the llvm-bugs mailing list