<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114819>114819</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AMDGPU global-isel doesn't legalize @llvm.amdgcn.if
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU,
llvm:globalisel
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
tpopp
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tpopp
</td>
</tr>
</table>
<pre>
This might be an invalid input case, as I was seeing some divergent behavior that I haven't localized yet
Command: `llc -global-isel reduced.ll`
Input:
```
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
target triple = "amdgcn-amd-amdhsa"
define amdgpu_kernel void @"main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store"() {
%1 = call { i1, i64 } @llvm.amdgcn.if.i64(i1 false)
ret void
}
; Function Attrs: nocallback nofree nounwind willreturn
declare { i1, i64 } @llvm.amdgcn.if.i64(i1) #0
attributes #0 = { nocallback nofree nounwind willreturn }
```
Dump:
```
# *** IR Dump Before Legalizer (legalizer) ***:
# Machine code for function main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store: IsSSA, TracksLiveness
Function Live Ins: $sgpr0_sgpr1_sgpr2_sgpr3 in %0, $sgpr4_sgpr5 in %1, $sgpr6_sgpr7 in %2, $sgpr8_sgpr9 in %3, $vgpr0 in %4, $vgpr1 in %5, $vgpr2 in %6, $sgpr10 in %7, $sgpr11 in %8, $sgpr12 in %9, $sgpr13 in %10
bb.1 (%ir-block.0):
liveins: $sgpr6_sgpr7
%13:_(s1) = G_CONSTANT i1 false
%11:_(s1), %12:_(s64) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if), %13:_(s1)
S_ENDPGM 0
# End machine code for function main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store.
LLVM ERROR: unable to legalize instruction: %11:_(s1), %12:_(s64) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.if), %13:_(s1) (in function: main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/tpopp/gisel/iree-build/llvm-project/bin/llc -global-isel reduced.ll
1. Running pass 'CallGraph Pass Manager' on module 'reduced.ll'.
2. Running pass 'Legalizer' on function '@"main$async_dispatch_19_softmax_16384x16384xf32_dispatch_tensor_store"'
#0 0x0000600c1dc7fd87 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x0000600c1dc7dfc0 llvm::sys::RunSignalHandlers() /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x0000600c1dc8044a SignalHandler(int) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x00007f322f242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f322f2969fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#5 0x00007f322f2969fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#6 0x00007f322f2969fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#7 0x00007f322f242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f322f2287f3 abort ./stdlib/./stdlib/abort.c:81:7
#9 0x0000600c1dbf47b3 llvm::report_fatal_error(llvm::Twine const&, bool) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
#10 0x0000600c1e12a6e4 (/home/tpopp/gisel/iree-build/llvm-project/bin/llc+0x604b6e4)
#11 0x0000600c1e12a9c8 llvm::DiagnosticInfoOptimizationBase::~DiagnosticInfoOptimizationBase() /home/tpopp/gisel/iree/third_party/llvm-project/llvm/include/llvm/IR/DiagnosticInfo.h:414:7
#12 0x0000600c1e12a9c8 llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, char const*, llvm::StringRef, llvm::MachineInstr const&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/GlobalISel/Utils.cpp:277:1
#13 0x0000600c1e0c3ffd llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:0:5
#14 0x0000600c1ceb54c4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:0:13
#15 0x0000600c1d332875 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
#16 0x0000600c1ca2943c (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, llvm::CallGraphSCC&, llvm::CallGraph&, bool&, bool&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:180:25
#17 0x0000600c1ca2943c (anonymous namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&, llvm::CallGraph&, bool&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:469:9
#18 0x0000600c1ca2943c (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:534:18
#19 0x0000600c1d333002 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
#20 0x0000600c1ba1a5e3 compileModule(char**, llvm::LLVMContext&) /home/tpopp/gisel/iree/third_party/llvm-project/llvm/tools/llc/llc.cpp:755:17
#21 0x0000600c1ba1a5e3 main /home/tpopp/gisel/iree/third_party/llvm-project/llvm/tools/llc/llc.cpp:412:22
#22 0x00007f322f229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f322f229e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f322f229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x0000600c1ba17d25 _start (/home/tpopp/gisel/iree-build/llvm-project/bin/llc+0x3938d25)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWUtzo7i3_zTKRmUXSDwXWThOnOuqdHcqzsxdUgKErRshKEm4k1ncz_6vI8CGJD3TM_90pistgx6_8z46EswYsVecX6LwChFi26ZtESEovL5gnT00-tJ1XeRN-XL5eBAG12J_sDjnmCks1JFJUWKh2s7ighmOyBozg7f4OzPYcC7UHpum5rgUR673XMHSAzuKRmN7YBZv8YEduUIktlg2BZPiD17iF26Rd428Vd-um7pmqkR0hVHkSVlgvNjLJmdyIQyXWPOyK3i5lBJF3nThFhhDdHiDwf7PvVqm99ziklkm2UvTWYzoNUaE8EWL6CoKXLNo_ekLQXRF-2bR0ulLMJ0WTkei6UuM6MqPPERXJIxOLYwkMEKGdtGm8JCStxPFSOXoRw5scSRBP3QcyRyDZJiTRgPg8QS2OJ4QF8fQh97QJ4uj7zkc-Fkciecg4GehHGwULHaULFbh4tZfKIHoCmSBSSm4zFSnVotW8lGfrC73hVqwuoT_B8NO0_u25JVQHMO0tsueuFZc4mMjSowCDxFSM6EQCZh5UUVWCtMyWxwyP81MU9maPWd-RJPguW8rSs5zLFem0ZmxjeZAlCSIpBjFVz1hjBEJfc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