[PATCH] D102615: [LoopDeletion] Break backedge if we can prove that the loop is exited on 1st iteration (try 3)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 14:54:26 PDT 2021


nikic added a comment.

Still crashing, here's the backtrace:

  ld: /home/nikic/llvm-project/llvm/include/llvm/Support/Casting.h:104: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::Constant; From = llvm::Value]: Assertion `Val && "isa<> used on a null pointer"' failed.
  
  Thread 2.1 "ld" received signal SIGABRT, Aborted.
  [Switching to Thread 0x7ffff7c2e100 (LWP 388814)]
  __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
  (gdb) bt
  #0  __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x00007ffff7c70859 in __GI_abort () at abort.c:79
  #2  0x00007ffff7c70729 in __assert_fail_base (
      fmt=0x7ffff7e06588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
      assertion=0x7ffff49afba0 "Val && \"isa<> used on a null pointer\"", 
      file=0x7ffff49afaa0 "/home/nikic/llvm-project/llvm/include/llvm/Support/Casting.h", line=104, function=<optimized out>) at assert.c:92
  #3  0x00007ffff7c81f36 in __GI___assert_fail (
      assertion=0x7ffff49afba0 "Val && \"isa<> used on a null pointer\"", 
      file=0x7ffff49afaa0 "/home/nikic/llvm-project/llvm/include/llvm/Support/Casting.h", line=104, 
      function=0x7ffff49afb28 "static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::Constant; From = llvm::Value]") at assert.c:101
  #4  0x00007ffff1669db7 in llvm::cast_retty<llvm::Constant, llvm::Value*>::ret_type llvm::dyn_cast<llvm::Constant, llvm::Value>(llvm::Value*) ()
     from /home/nikic/llvm-project/build/bin/../lib/LLVMgold.so
  #5  0x00007ffff43120d9 in SimplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) ()
     from /home/nikic/llvm-project/build/bin/../lib/LLVMgold.so
  #6  0x00007ffff3a563d3 in canProveExitOnFirstIteration(llvm::Loop*, llvm::DominatorTree&, llvm::LoopInfo&) ()
     from /home/nikic/llvm-project/build/bin/../lib/LLVMgold.so

It looks like the LHS argument to SimplifyICmpInst is null. I suspect this may be due to reference invalidation, commented inline.



================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:302
+        if (DT.dominates(Incoming, BB->getTerminator()))
+          FirstIterValue[&PN] =
+              getValueOnFirstIteration(Incoming, FirstIterValue, SQ);
----------------
This acquired a reference to `FirstIterValue[&PN]`, then calls `getValueOnFirstIteration()` which may invalidate it and then writes to it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102615/new/

https://reviews.llvm.org/D102615



More information about the llvm-commits mailing list