<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64661>64661</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
opt -O2 crash Assertion `false && "memory location set"' failed, but works under `instcombine`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Hatsunespica
</td>
</tr>
</table>
<pre>
Here is the link:
https://godbolt.org/z/cG6eYExYx
Source code:
```
define i1 @fold_to_new_instruction(ptr %a, ptr %b) {
%c = icmp uge ptr %a, %b, !annotation !0
ret i1 %c
}
!0 = !{ !"auto-init" }
```
This test case comes from:
https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/InstCombine/annotations.ll
Error message:
```
opt: /root/llvm-project/llvm/lib/Transforms/Utils/MoveAutoInit.cpp:53: std::optional<llvm::MemoryLocation> writeToAlloca(const llvm::Instruction&): Assertion `false && "memory location set"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -O2 <source>
#0 0x0000000003487758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3487758)
#1 0x000000000348504c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f29ed71b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f29ed1de00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f29ed1bd859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f29ed1bd729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f29ed1cefd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x00000000043bd0e4 runMoveAutoInit(llvm::Function&, llvm::DominatorTree&, llvm::MemorySSA&) MoveAutoInit.cpp:0:0
#8 0x00000000043be178 llvm::MoveAutoInitPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43be178)
#9 0x000000000369bf9e llvm::detail::PassModel<llvm::Function, llvm::MoveAutoInitPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369bf9e)
#10 0x0000000000d3fa9d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd3fa9d)
#11 0x00000000022be41f llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x22be41f)
#12 0x0000000000d247de llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd247de)
#13 0x00000000022b68cb llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x22b68cb)
#14 0x000000000369b45e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369b45e)
#15 0x00000000022baad5 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x22baad5)
#16 0x000000000369b47e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369b47e)
#17 0x00000000022b8c79 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x22b8c79)
#18 0x0000000003ee0a3f llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ee0a3f)
#19 0x000000000369b07e llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369b07e)
#20 0x0000000002df2adc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2df2adc)
#21 0x0000000000887d2a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x887d2a)
#22 0x000000000078e0c1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x78e0c1)
#23 0x00007f29ed1bf083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#24 0x000000000087cf6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x87cf6e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1v2zoS_TX0C2GDpr4f_OA6cRtsgwZ17i7uk0GJI5sbihRIqknur1_ow4noJL1J64dubwrXskTyzMyZM2NLDLNW7BTAAkUfUHQ2YY3ba7P4xJxtFNhaFGySa36_-AQGsLDY7QFLoW5QsETkDJHl3rnatmd0jeh6p3mupZtps0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