<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54339>54339</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llc crash with `-fp-armv8` and `global-isel=1` when attempting to lower non-scalable function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nasherm
</td>
</tr>
</table>
<pre>
Hi, I've come across the following crash when attempting to debug an [issue in rustc](https://github.com/rust-lang/rust/issues/80268).
platform: x86_64-apple-darwin
fail.ll
```
define float @foo(double %x) {
start:
%0 = fptrunc double %x to float
ret float %0
}
```
crash stack trace
```
$ llc -march=aarch64 -mattr=-fp-armv8 -global-isel=1 fail.ll
LLVM ERROR: unable to lower function: float (double)* (in function: foo)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc -march=aarch64 -mattr=-fp-armv8 -global-isel=1 test.ll
1. Running pass 'Function Pass Manager' on module 'test.ll'.
2. Running pass 'IRTranslator' on function '@foo'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 llc 0x000000010e4b87f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 llc 0x000000010e4b75b8 llvm::sys::RunSignalHandlers() + 248
2 llc 0x000000010e4b8e40 SignalHandler(int) + 272
3 libsystem_platform.dylib 0x00007ff801f85e2d _sigtramp + 29
4 libsystem_platform.dylib 0x0000000800000000 _sigtramp + 18446603404907618800
5 libsystem_c.dylib 0x00007ff801ebcd10 abort + 123
6 llc 0x000000010e3f23c5 llvm::report_fatal_error(llvm::Twine const&, bool) + 469
7 llc 0x000000010e96d833 reportTranslationError(llvm::MachineFunction&, llvm::TargetPassConfig const&, llvm::OptimizationRemarkEmitter&, llvm::OptimizationRemarkMissed&) + 323
8 llc 0x000000010e981891 llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) + 3265
9 llc 0x000000010d88da7d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 397
10 llc 0x000000010dcd5241 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1073
11 llc 0x000000010dcdb8c8 llvm::FPPassManager::runOnModule(llvm::Module&) + 72
12 llc 0x000000010dcd58ce llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1102
13 llc 0x000000010c2ab8a3 main + 9731
14 dyld 0x000000011720a4fe start + 462
```
I've been able to trace the issue down to a check made in `llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp`
```cpp
...
if (CLI->fallBackToDAGISel(*MF)) {
OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure",
F.getSubprogram(), &F.getEntryBlock());
R << "unable to lower function: " << ore::NV("Prototype", F.getType());
reportTranslationError(*MF, *TPC, *ORE, R);
return false;
}
...
```
Inspecting `fallBackToDAGISel` further it appears that the function itself is being recognised as a `ScalableVectorType` within `llvm/lib/Target/AArch64/AArch64ISelLowering.cpp`
```cpp
...
bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
if (isa<ScalableVectorType>(Inst.getType()))
return true;
for (unsigned i = 0; i < Inst.getNumOperands(); ++i)
if (isa<ScalableVectorType>(Inst.getOperand(i)->getType()))
return true;
if (const AllocaInst *AI = dyn_cast<AllocaInst>(&Inst)) {
if (isa<ScalableVectorType>(AI->getAllocatedType()))
return true;
}
return false;
}
...
```
I'm relatively new to contributing to LLVM, but I'd like to fix this bug. Would anybody be able to give guidance on the scope of this problem and whether it wouldn't too large in scope? Is my intuition correct in thinking that `fallBackToDAGISel` shouldn't recognise our function as a scalable-vector type? Any help is appreciated
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydWFtv4roW_jXpiwXKDZI88EAvzCC1uxWt5uicl8pJHPCpY0eOU4b96_dadsJlyrTsQYgktvOtb129TK7K3ew798IbsvTC5J2RQtWM0EKrti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