<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151892>151892</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llvm-20: orc: unable to legalize instruction
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jcelerier
</td>
</tr>
</table>
<pre>
Attached file causes the following error when trying to JIT it:
```
LLVM ERROR: unable to legalize instruction: %27:_(<4 x s64>) = G_SHUFFLE_VECTOR %26:_(<4 x s64>), %21:_, shufflemask(0, 0, 0, 0) (in function: _ZN7Example12MyAvndEffectclEN4halp4tickE)
#9 0x00007f592a22560d abort /usr/src/debug/glibc/glibc/stdlib/abort.c:81:3
#10 0x00007f5903c83382 (/usr/lib/libLLVM.so.20.1+0x4083382)
#11 0x00007f590639b95f (/usr/lib/libLLVM.so.20.1+0x679b95f)
#12 0x00007f590639b28f llvm::reportGISelFailure(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::MachineOptimizationRemarkEmitter&, char const*, llvm::StringRef, llvm::MachineInstr const&) (/usr/lib/libLLVM.so.20.1+0x679b28f)
#13 0x00007f5903d2b961 llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/libLLVM.so.20.1+0x412b961)
#14 0x00007f5903918367 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/libLLVM.so.20.1+0x3d18367)
#15 0x00007f5903e4a90f llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/libLLVM.so.20.1+0x424a90f)
#16 0x00007f5903e42f13 (/usr/lib/libLLVM.so.20.1+0x4242f13)
#17 0x00007f5903e41896 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/libLLVM.so.20.1+0x4241896)
#18 0x00007f59050f90f0 llvm::orc::SimpleCompiler::operator()(llvm::Module&) (/usr/lib/libLLVM.so.20.1+0x54f90f0)
#19 0x00007f59050f8b09 llvm::orc::ConcurrentIRCompiler::operator()(llvm::Module&) (/usr/lib/libLLVM.so.20.1+0x54f8b09)
#20 0x00007f59065bf388 llvm::orc::IRCompileLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility>>, llvm::orc::ThreadSafeModule) (/usr/lib/libLLVM.so.20.1+0x69bf388)
#21 0x00007f59065bed14 llvm::orc::IRTransformLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility>>, llvm::orc::ThreadSafeModule) (/usr/lib/libLLVM.so.20.1+0x69bed14)
#22 0x00007f59065bed14 llvm::orc::IRTransformLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility>>, llvm::orc::ThreadSafeModule) (/usr/lib/libLLVM.so.20.1+0x69bed14)
#23 0x00007f59065bf1f3 llvm::orc::BasicIRLayerMaterializationUnit::materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility>>) (/usr/lib/libLLVM.so.20.1+0x69bf1f3)
#24 0x00007f59065b7369 llvm::orc::MaterializationTask::run() (/usr/lib/libLLVM.so.20.1+0x69b7369)
#25 0x00007f59071eafb9 (/usr/lib/libLLVM.so.20.1+0x75eafb9)
#26 0x00007f592a7002f4 std::default_delete<std::thread::_State>::operator()(std::thread::_State*) const /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/unique_ptr.h:93:2
#27 0x00007f592a7002f4 std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>::~unique_ptr() /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/unique_ptr.h:399:17
#28 0x00007f592a7002f4 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:106:5
#29 0x00007f592a2a80d6 start_thread /usr/src/debug/glibc/glibc/nptl/pthread_create.c:448:8
#30 0x00007f592a33b05c (/usr/lib/libc.so.6+0x13b05c)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```
[llvm-orc-legalize.zip](https://github.com/user-attachments/files/21569374/llvm-orc-legalize.zip)
It works if I set
opts.EnableGlobalISel = false;
in the llvm::TargetOptions
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWEmP47oR_jX0hbBBkVoPPqg91sRB9-uBu9875GJQFGXzNU0pJNXLHPLbA1Ly2p5eZpIgQAIIXsTiV199LC5FaoxYK86nILoC0ZcR7eym0dM_GZdcC65HZVO9THNrKdvwCtZCcshoZ7iBdsNh3UjZPAm1hlzrRsOnDVfQ6hf3xjbwr4t7KCwgOUD-idHwoPz6-o8bOF8ub5eA5LBTtJTcdZF8TaX4zqFQxuqOWdEoZwFwhBNA8hXAKSCzED5DE4eAzAHOICBf4NfV3V9-L4rr-eqP-ez-dul7xD_oAfDMtwd9-wyaTVfXkm-peQA4Re7VyUcGAU6FgnWn9pRWf_stmT_TbSt5gG9e8kdVzeuaM8vk_LdwQ2UbWsEevD_kIiAZRM8IIZTUUYYpxlGMKkjLRlsIcNEZDXBhNAO4qHjZrQEu1lKU7Ojb2EqKEuDC95owQPLUBUGcvJgE6MgDIiwlJMWO-h6-7y1F6QZgYpoJRpMA4Cv0HCJv3bN1WMExVkyyMovqD2LFibc-YOFzLJzWUMrHrUsOkmveNtp-XdxxWVAhO80BTg_NN5RthOLFTnwcu2E5tN9Tveb2GzVm1qharCFrlLGvzAaY29aKrfhOHdSSb6l-mG-FtVwPHdiG6h1CfopwZ7VQ6yWvLwIvXMoe-c4-oRZOj9QiJ6NY4TKLgyN318Mc0YN4nbpVryR6R76PcgsD7_3ALTzhlgUpiZPXUux8uTE5YnmR3k_xIpX3fOAVnfDiIc3QcYYV3xyVG6ro-kS3fx2jEHufB0bxGSNcB-TjWM76gJWcYQVpFh9F51ZN9tL_PopzsW3lP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