<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 - opt crashes with "opt -gvn-hoist -loop-reduce -licm" : Assertion `ReplacementDone && "Incomplete phi during partial rename"' failed."
href="https://bugs.llvm.org/show_bug.cgi?id=47541">47541</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>opt crashes with "opt -gvn-hoist -loop-reduce -licm" : Assertion `ReplacementDone && "Incomplete phi during partial rename"' 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=23969" name="attach_23969" title="small.bc">attachment 23969</a> <a href="attachment.cgi?id=23969&action=edit" title="small.bc">[details]</a></span>
small.bc
This bug is similar to the fixed <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - gvn-hoist crashes: Assertion `ReplacementDone && "Incomplete phi during partial rename"' failed."
href="show_bug.cgi?id=43541">bug 43541</a>, since they have the same failed
assertion. I am not sure that this bug is a corner case of the patch for bug
43541, so I report it as a new bug rather than reopen <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - gvn-hoist crashes: Assertion `ReplacementDone && "Incomplete phi during partial rename"' failed."
href="show_bug.cgi?id=43541">bug 43541</a>.
$clang -v
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
65f6810d3a4b0ef1fdaad49e808459fbd133bb20)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$clang -O3 -c -emit-llvm -femit-all-decls -mllvm -disable-llvm-optzns small.c
$opt -early-cse-memssa -instcombine -loop-unroll -gvn-hoist -loop-reduce -licm
small.bc -o small-opt.bc
opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/llvm/lib/Analysis/MemorySSAUpdater.cpp:296:
void setMemoryPhiValueForBlock(llvm::MemoryPhi*, const llvm::BasicBlock*,
llvm::MemoryAccess*): Assertion `i != -1 && "Should have found the basic block
in the phi"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0. Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt
-early-cse-memssa -instcombine -loop-unroll -gvn-hoist -loop-reduce -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 '@e'
3. Running pass 'Loop Invariant Code Motion' on basic block '%for.cond'
#0 0x0000558fad13b99c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b9999c)
#1 0x0000558fad139714 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b97714)
#2 0x0000558fad139863 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b97863)
#3 0x00007fc3ea33b8a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#4 0x00007fc3e8fedf47 raise
/build/glibc-2ORdQG/glibc-2.27/sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007fc3e8fef8b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007fc3e8fdf42a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
#7 0x00007fc3e8fdf4a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
#8 0x0000558fac2259dd setMemoryPhiValueForBlock(llvm::MemoryPhi*,
llvm::BasicBlock const*, llvm::MemoryAccess*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c839dd)
#9 0x0000558fac2316fe
llvm::MemorySSAUpdater::fixupDefs(llvm::SmallVectorImpl<llvm::WeakVH> const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c8f6fe)
#10 0x0000558fac231d33 llvm::MemorySSAUpdater::insertDef(llvm::MemoryDef*,
bool)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c8fd33)
#11 0x0000558faceb8f91 (anonymous
namespace)::LoopPromoter::doExtraRewritesBeforeFinalDeletion()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2916f91)
#12 0x0000558fad280c40
llvm::LoadAndStorePromoter::run(llvm::SmallVectorImpl<llvm::Instruction*>
const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2cdec40)
#13 0x0000558faceb83e7
llvm::promoteLoopAccessesToScalars(llvm::SmallSetVector<llvm::Value*, 8u>
const&, llvm::SmallVectorImpl<llvm::BasicBlock*>&,
llvm::SmallVectorImpl<llvm::Instruction*>&,
llvm::SmallVectorImpl<llvm::MemoryAccess*>&, llvm::PredIteratorCache&,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo const*,
llvm::Loop*, llvm::AliasSetTracker*, llvm::MemorySSAUpdater*,
llvm::ICFLoopSafetyInfo*, llvm::OptimizationRemarkEmitter*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x29163e7)
#14 0x0000558facec2167 (anonymous
namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*,
llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*,
llvm::OptimizationRemarkEmitter*) (.part.775)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2920167)
#15 0x0000558facec2daa (anonymous
namespace)::LegacyLICMPass::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2920daa)
#16 0x0000558fac1f1ae3 llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c4fae3)
#17 0x0000558fac97ccc8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23dacc8)
#18 0x0000558fac97d7c9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23db7c9)
#19 0x0000558fac97c546 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23da546)
#20 0x0000558faae044c9 main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x8624c9)
#21 0x00007fc3e8fd0b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/libc-start.c:344:0
#22 0x0000558faaeb37ca _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x9117ca)
Aborted (core dumped)
I also use bugpoint to reduce the testcase.
$opt bugpoint-reduced-simplified.bc -gvn-hoist -loop-reduce -licm
opt bugpoint-reduced-simplified.bc -gvn-hoist -loop-reduce -licm
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
opt:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/llvm/lib/Analysis/MemorySSA.cpp:1123:
void llvm::MemorySSA::renameSuccessorPhis(llvm::BasicBlock*,
llvm::MemoryAccess*, bool): Assertion `ReplacementDone && "Incomplete phi
during partial rename"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0. Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt
bugpoint-reduced-simplified.bc -gvn-hoist -loop-reduce -licm
1. Running pass 'Function Pass Manager' on module
'bugpoint-reduced-simplified.bc'.
2. Running pass 'Loop Pass Manager' on function '@e'
3. Running pass 'Loop Invariant Code Motion' on basic block '%for.cond'
#0 0x0000556f6134d99c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b9999c)
#1 0x0000556f6134b714 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b97714)
#2 0x0000556f6134b863 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2b97863)
#3 0x00007fcdf2bf18a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#4 0x00007fcdf18a3f47 raise
/build/glibc-2ORdQG/glibc-2.27/sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007fcdf18a58b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007fcdf189542a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
#7 0x00007fcdf18954a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
#8 0x0000556f60429b5f llvm::MemorySSA::renameSuccessorPhis(llvm::BasicBlock*,
llvm::MemoryAccess*, bool)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c75b5f)
#9 0x0000556f6042a008
llvm::MemorySSA::renamePass(llvm::DomTreeNodeBase<llvm::BasicBlock>*,
llvm::MemoryAccess*, llvm::SmallPtrSetImpl<llvm::BasicBlock*>&, bool, bool)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c76008)
#10 0x0000556f60443eba llvm::MemorySSAUpdater::insertDef(llvm::MemoryDef*,
bool)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c8feba)
#11 0x0000556f60444ba3 void
llvm::MemorySSAUpdater::moveTo<llvm::MemorySSA::InsertionPlace>(llvm::MemoryUseOrDef*,
llvm::BasicBlock*, llvm::MemorySSA::InsertionPlace)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c90ba3)
#12 0x0000556f610c7006 moveInstructionBefore(llvm::Instruction&,
llvm::Instruction&, llvm::ICFLoopSafetyInfo&, llvm::MemorySSAUpdater*,
llvm::ScalarEvolution*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2913006)
#13 0x0000556f610c7fc8 hoist(llvm::Instruction&, llvm::DominatorTree const*,
llvm::Loop const*, llvm::BasicBlock*, llvm::ICFLoopSafetyInfo*,
llvm::MemorySSAUpdater*, llvm::ScalarEvolution*,
llvm::OptimizationRemarkEmitter*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2913fc8)
#14 0x0000556f610ce92d
llvm::hoistRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*, llvm::Loop*,
llvm::AliasSetTracker*, llvm::MemorySSAUpdater*, llvm::ScalarEvolution*,
llvm::ICFLoopSafetyInfo*, llvm::SinkAndHoistLICMFlags&,
llvm::OptimizationRemarkEmitter*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x291a92d)
#15 0x0000556f610d33e2 (anonymous
namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*,
llvm::LoopInfo*, llvm::DominatorTree*, llvm::TargetLibraryInfo*,
llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*,
llvm::OptimizationRemarkEmitter*) (.part.775)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x291f3e2)
#16 0x0000556f610d4daa (anonymous
namespace)::LegacyLICMPass::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x2920daa)
#17 0x0000556f60403ae3 llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x1c4fae3)
#18 0x0000556f60b8ecc8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23dacc8)
#19 0x0000556f60b8f7c9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23db7c9)
#20 0x0000556f60b8e546 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x23da546)
#21 0x0000556f5f0164c9 main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x8624c9)
#22 0x00007fcdf1886b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/libc-start.c:344:0
#23 0x0000556f5f0c57ca _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm-project/build/bin/opt+0x9117ca)
Aborted (core dumped)
---small.c-------------------
int a, b;
short c;
int d[];
void e() {
b = 0;
for (; b < 9; b++) {
a = 0;
for (; a < 2; a++) {
c = 0;
for (; c; c++)
d[b] = 0;
}
}
}
void main() {}</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>