Skip to content

[RISC-V][RVV] Inline ASM causes 'Invalid size request on a scalable vector' #99782

Closed
@Blokyk

Description

@Blokyk

Trying to compile the following code crashes clang:

#include <riscv_vector.h>

int vslidedown() {
    vuint8m8_t v;

    asm volatile(
        "vadd.vv %0, %0, %0"
        : "=g" (v)
        : "g" (v)
    );
}
Crash message
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: 

********************

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions