<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-unswitch crashes: Assertion `&F == cast<Instruction>(VH)->getParent()->getParent() && "Cached assumption not inside this function!"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=42788">42788</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>loop-unswitch crashes: Assertion `&F == cast<Instruction>(VH)->getParent()->getParent() && "Cached assumption not inside this function!"' 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>Scalar Optimizations
          </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=22301" name="attach_22301" title=".bc file of the source code">attachment 22301</a> <a href="attachment.cgi?id=22301&action=edit" title=".bc file of the source code">[details]</a></span>
.bc file of the source code

$clang -v
clang version 10.0.0 (trunk 367076)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/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 -instcombine -loop-predication -lowerswitch -early-cse-memssa -simplifycfg
-loop-unroll -gvn  -hotcoldsplit -loop-unswitch small.bc -o small-opt.bc
opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/lib/Analysis/AssumptionCache.cpp:211:
void llvm::AssumptionCache::registerAssumption(llvm::CallInst*): Assertion `&F
== cast<Instruction>(VH)->getParent()->getParent() && "Cached assumption not
inside this function!"' failed.
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt -instcombine
-loop-predication -lowerswitch -early-cse-memssa -simplifycfg -loop-unroll -gvn
-hotcoldsplit -loop-unswitch small.bc -o small-opt.bc 
1.      Running pass 'Function Pass Manager' on module 'small.bc'.
2.      Running pass 'Loop Pass Manager' on function '@aa'
3.      Running pass 'Unswitch loops' on basic block '%for.cond1'
 #0 0x000055f5d238068a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x26bb68a)
 #1 0x000055f5d237e334 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x26b9334)
 #2 0x000055f5d237e472 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x26b9472)
 #3 0x00007f64b631f890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f64b4fd1e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f64b4fd3801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f64b4fc339a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f64b4fc3412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x000055f5d159bdee
llvm::AssumptionCache::registerAssumption(llvm::CallInst*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x18d6dee)
 #9 0x000055f5d21d1544 (anonymous
namespace)::LoopUnswitch::UnswitchNontrivialCondition(llvm::Value*,
llvm::Constant*, llvm::Loop*, llvm::Instruction*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x250c544)
#10 0x000055f5d21d1e10 (anonymous
namespace)::LoopUnswitch::UnswitchIfProfitable(llvm::Value*, llvm::Constant*,
llvm::Instruction*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x250ce10)
#11 0x000055f5d21d3845 (anonymous
namespace)::LoopUnswitch::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(.part.533)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x250e845)
#12 0x000055f5d16b6c6b llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x19f1c6b)
#13 0x000055f5d1d0d079 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x2048079)
#14 0x000055f5d1d0d171 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x2048171)
#15 0x000055f5d1d0c2d1 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x20472d1)
#16 0x000055f5d0527425 main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x862425)
#17 0x00007f64b4fb4b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#18 0x000055f5d05ad93a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm2/build4/bin/opt+0x8e893a)
Aborted (core dumped)

--------------------------------------------------------------
int f, k, m, o;
short g, h, j;
long i, l;
int volatile n;
short(v)();
int(w)();
long(x)();
char(y)();
void(z)();
void aa(ab) {
  char r;
  int s = o;
  for (;;) {
    int *t = &k, *a = &f;
    short b = 1;
    for (; i; i++) {
      int *c = &f;
      h = 0;
      {
        long d = g = 0;
        {
          short *e = &j;
          int *p = &o;
          l = 0;
          for (; 0;)
            ;
          *e = v();
          *a = w();
          x(0, m);
          d |= v();
          if (ab)
            break;
          *p = r = y();
          z(n || x(r, 4073709551613));
          *c = w();
        }
        {
          int q;
          *t = ab;
          if (ab)
            break;
        }
      }
    }
    if (s) {
      l = 0;
      for (; l <= 0; l++) {
        int u;
        if (ab)
          continue;
      }
    }
    for (; 0 <= 0; b++)
      ;
  }
}</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>