<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99782>99782</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][RVV] Inline ASM causes 'Invalid size request on a scalable vector'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Blokyk
</td>
</tr>
</table>
<pre>
Trying to compile the following code crashes `clang`:
```c
#include <riscv_vector.h>
int vslidedown() {
vuint8m8_t v;
asm volatile(
"vadd.vv %0, %0, %0"
: "=g" (v)
: "g" (v)
);
}
```
<details>
<summary>Crash message</summary>
```
fatal error: error in backend: Invalid size request on a scalable vector.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/bin/clang-19 --target=riscv32 -fuse-ld=lld -Wno-unused-command-line-argument -march=rv32imzve32x -mabi=ilp32 -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -nodefaultlibs -ffreestanding -fno-builtin -fno-builtin-memcpy -Wall -Wextra -I/work/sxc/stage/internships/work/RVV/perf/vicuna/sw//lib/ -I.//samples/ -Wno-pointer-sign -g -c -o obj/instrs.o obj/instrs.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'obj/instrs.c'.
4. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@vslidedown'
#0 0x0000744bd54a3a46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea3a46)
#1 0x0000744bd54a1620 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea1620)
#2 0x0000744bd53f128e (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xdf128e)
#3 0x0000744bd53f124b (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xdf124b)
#4 0x0000744bd549dcf7 llvm::sys::Process::Exit(int, bool) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xe9dcf7)
#5 0x0000630c45004513 (/usr/bin/clang-19+0x12513)
#6 0x0000744bd53ffbc9 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xdffbc9)
#7 0x0000744bd53ffab6 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xdffab6)
#8 0x0000744bd5457a89 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xe57a89)
#9 0x0000744bd5457aa6 llvm::TypeSize::operator unsigned long() const (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xe57aa6)
#10 0x0000744bd5cb7f39 llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase const&, llvm::BasicBlock const*) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x16b7f39)
#11 0x0000744bd5c9f681 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x169f681)
#12 0x0000744bd5d3b9f9 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, bool&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x173b9f9)
#13 0x0000744bd5d3ad80 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x173ad80)
#14 0x0000744bd5d396ae llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x17396ae)
#15 0x0000744bd5d381da llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x17381da)
#16 0x0000744bd5880628 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1280628)
#17 0x0000744bd55f1444 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xff1444)
#18 0x0000744bd55f6cc3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xff6cc3)
#19 0x0000744bd55f1b9e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xff1b9e)
#20 0x0000744bddffdd0e clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1dfdd0e)
#21 0x0000744bde39a1a2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x219a1a2)
#22 0x0000744bdce1b419 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0xc1b419)
#23 0x0000744bdee8e415 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2c8e415)
#24 0x0000744bdedfeb04 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2bfeb04)
#25 0x0000744bdef0ad7e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2d0ad7e)
#26 0x0000630c45004105 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-19+0x12105)
#27 0x0000630c45001035 (/usr/bin/clang-19+0xf035)
#28 0x0000744bdea97ec9 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2897ec9)
#29 0x0000744bd53f1228 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xdf1228)
#30 0x0000744bdea9783d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x289783d)
#31 0x0000744bdea5d495 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x285d495)
#32 0x0000744bdea5d6fe clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x285d6fe)
#33 0x0000744bdea7a80c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x287a80c)
#34 0x0000630c45000a81 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-19+0xea81)
#35 0x0000630c4500e586 main (/usr/bin/clang-19+0x1c586)
#36 0x0000744bd3e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#37 0x0000744bd3e29e40 call_init ./csu/../csu/libc-start.c:128:20
#38 0x0000744bd3e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#39 0x0000630c44ffecc5 _start (/usr/bin/clang-19+0xccc5)
clang-19: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Ubuntu clang version 19.0.0 (++20240715042114+8da3852f44c6-1~exp1~20240715042233.1804)
Target: riscv32--
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
clang-19: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-19: note: diagnostic msg: /tmp/instrs-e64ce2.c
clang-19: note: diagnostic msg: /tmp/instrs-e64ce2.sh
clang-19: note: diagnostic msg:
********************
```
</details>
Similar issues: #61561 and #88576 -- but this build supposedly already contains the fixes for them, and yet it still crashes
Version: `Ubuntu clang version 19.0.0 (++20240715042114+8da3852f44c6-1~exp1~20240715042233.1804)`
[Crash reproducer and pre-processed source here](https://gist.github.com/Blokyk/a56caa89e86a11e1e87a6840bc94dd1d)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWlFz4yqy_jXKCyWXhCRbesiD48RzspW5k0py5jy6ELRsdhDSAnLi87C__RZItoXjnJk747O3dmoqlqBpvm6a7gY10ZqvJcB1kN0E2e0V6cymUdc3ovm2-3ZVNmx3_aJ2XK6RaRBt6pYLQGYDqGqEaF5tB20YIKqI3oBGwTSigsh1MI2CZB5Et0G0_zuN-v90eMcJl1R0DFCQLBTXdLvaAjWNmmyC5G48lEuDtlpwBqx5lQHOA1ygYHbT9yKE0Lbj0uR1vjJoGyQ348G2m-gabRtBDBdghx867L8A4y1hbLLdogBnUYAXJ7_4hD6Z2zFBcrsOMEYBzrcBLs7SnCGwTweAs9sT3XgKSxYMDOFCH9WRLHRX10TtguRuYVWOatCarCFIFgFeHjvPar5_rYghAoFSjbIw3QPiEpWEfgPJbNu93BLBGdL8T0AK_tWBNqiRiCBNiSClADQsVc_y8eFu_nyHdFfW3CCCym6NFLSNMtZsNsa02loDX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