<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - LICM's AliasSetTracker is holding deleted values"
   href="https://llvm.org/bugs/show_bug.cgi?id=27146">27146</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LICM's AliasSetTracker is holding deleted values
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>opt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lawrence@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16134" name="attach_16134" title="reduced testcase">attachment 16134</a> <a href="attachment.cgi?id=16134&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

A problem similar to <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - LICM's AliasSetTracker is holding deleted values"
   href="show_bug.cgi?id=3787">bug 3787</a>.

If I run loop reroll after LICM, I will hit the following Assert:

An asserting value handle still pointed to this value!
UNREACHABLE executed at
/prj/llvm-arm/home/lawrence/llvmtrunk_latest/src/llvm/lib/IR/Value.cpp:744!
#0 0x00000000010f9548 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x10f9548)
#1 0x00000000010f7a56 llvm::sys::RunSignalHandlers()
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x10f7a56)
#2 0x00000000010f9d69 SignalHandler(int)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x10f9d69)
#3 0x00007f1b2e6decb0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0xfcb0)
#4 0x00007f1b2da200d5 gsignal
/build/eglibc-rrybNj/eglibc-2.15/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:64:0
#5 0x00007f1b2da2383b abort
/build/eglibc-rrybNj/eglibc-2.15/stdlib/abort.c:93:0
#6 0x00000000010b147d llvm::llvm_unreachable_internal(char const*, char const*,
unsigned int)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x10b147d)
#7 0x0000000000d53e6c llvm::ValueHandleBase::ValueIsDeleted(llvm::Value*)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xd53e6c)
#8 0x0000000000d5371b llvm::Value::~Value()
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xd5371b)
#9 0x0000000000cfd739 llvm::CallInst::~CallInst()
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xcfd739)
#10 0x0000000000cfa076 llvm::Instruction::eraseFromParent()
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xcfa076)
#11 0x0000000000fb499d (anonymous
namespace)::LoopReroll::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xfb499d)
#12 0x0000000000957e9e llvm::LPPassManager::runOnFunction(llvm::Function&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x957e9e)
#13 0x0000000000d2409d llvm::FPPassManager::runOnFunction(llvm::Function&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xd2409d)
#14 0x0000000000d242eb llvm::FPPassManager::runOnModule(llvm::Module&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xd242eb)
#15 0x0000000000d24892 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0xd24892)
#16 0x00000000005b3f5b main
(/prj/llvm-arm/home/lawrence/llvmtrunk_latest/build_release/llvm/bin/opt+0x5b3f5b)
#17 0x00007f1b2da0b76d __libc_start_main
/build/eglibc-rrybNj/eglibc-2.15/csu/libc-start.c:258:0

The problem is that LICM is designed to do runOnLoop for all the loop first,
then go to next opt, because it keep the AliasSetTracker around for outer loop,
AliasSetTracker created the ValueHandle (type Assert), without destructing the
AliasSetTracker, the ValueHandle will be kept around. Then if we run any other
opt after LICM (before destructing AliasSetTracker), we will run into this kind
of Assert.

I am thinking either we have to destruct AliasSetTracker every time in LICM; Or
we have to pass a flag to LICM to destruct AliasSetTracker if flag is set.

Any thoughts or suggestion?


Command to reproduce:
bin/opt -licm -loop-reroll -debug-only=loop-reroll -S t.ll</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>