<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61265>61265</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AArch64 merges two calls causing a `phi` to be passed in to `immarg` parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dmlloyd
</td>
</tr>
</table>
<pre>
I'm not sure what pass is responsible for this, but AArch64 will, under some unknown circumstances, try to merge two similar blocks which contain a call to an intrinsic that has `immarg` arguments, incorrectly replacing those arguments with a `phi` value. This bug first appears in `15.0.0`, as far as we can tell.
The example is pretty large unfortunately (too large to put in a comment, and it won't let me attach text files 🙄). The source file that fails is at the end of the report (It's pretty long, and I couldn't figure out a minimal reproducer). Here's a [compiler explorer link](https://godbolt.org/z/n6eWEPs9s) which shows the problem with the original source file that caused it.
The error is like this:
```
immarg operand has non-immediate parameter
%1 = phi i64 [ 144531, %bb8 ], [ 144532, %bb13 ]
%2 = invoke token (i64, i32, void (i8 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i8f(i64 %1, i32 0, void (i8 addrspace(1)*)* elementtype(void (i8 addrspace(1)*)) @_Jorg_qbicc_runtime_main_VMHelpers_raiseNullPointerException___V, i32 1, i32 0, i8 addrspace(1)* %thr, i64 0, i64 0) #3
to label %bb14.cont unwind label %bb5.catch, !dbg !619
in function _Jjava_lang_ThreadGroup_add__Ljava_lang_Thread_2_V
LLVM ERROR: Broken function found, compilation aborted!
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-15.0.0/bin/llc -o /app/output.s --mtriple=aarch64 <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'Module Verifier' on function '@_Jjava_lang_ThreadGroup_add__Ljava_lang_Thread_2_V'
#0 0x000055e7df076594 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055e7df073df4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fa3a5d9d420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007fa3a586a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007fa3a5849859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x000055e7dc8bb655 llvm::DisplayGraph(llvm::StringRef, bool, llvm::GraphProgram::Name) (.cold) GraphWriter.cpp:0:0
#6 0x000055e7defbd68e (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x2fe568e)
#7 0x000055e7de8a6b96 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0
#8 0x000055e7de7fcc10 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x2824c10)
#9 0x000055e7de7fcd89 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x2824d89)
#10 0x000055e7de7fd970 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x2825970)
#11 0x000055e7dc97960b compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#12 0x000055e7dc8ca1c2 main (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x8f21c2)
#13 0x00007fa3a584b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#14 0x000055e7dc9718fe _start (/opt/compiler-explorer/clang-15.0.0/bin/llc+0x9998fe)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0V0tv3DgS_jX0pWBBot6HPnRi9ySDZMZIAs9RoKiSxDFFakkqbe-vX5DqpxNgk82O4W6p-fjqY71YxawVg0LckPwNye9u2OJGbTbdJKV-6W5a3b1s3hNaTqC0A7sYhP3IHMz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