Avimitin wrote:
I encountered a clang compiler crash (segmentation fault) when attempting to
compile the `utf8_count.c` benchmark from the `rvv-bench` project
([https://github.com/camel-cdr/rvv-bench/blob/main/bench/utf8\_count.c](https://github.com/camel-cdr/rvv-bench/blob/main/bench/utf8_count.c))
using clang build from this branch. The crash occurs during the 'RISC-V
DAG-\>DAG Pattern Instruction Selection' pass.
**Steps to Reproduce:**
1. Obtain the `utf8_count.c` file from the `rvv-bench` project (or use the
minimal C code provided below).
2. Compile the C code with the following command:
```bash
riscv32-none-elf-clang -mabi=ilp32f
-march=rv32imafc_xsfmm128t_zve32f_zvl2048b -mno-relax -static -nostartfiles
-mcmodel=medany -fvisibility=hidden -fno-PIC -g -O3 -fno-rtti -fno-exceptions
-fno-threadsafe-statics -c utf8_count.c -o utf8_count.o
```
**Error Log:**
Compiler Error Output
```console
$ riscv32-none-elf-clang -mabi=ilp32f
-march=rv32imafc_xsfmm128t_zve32f_zvl2048b -mno-relax -static -nostartfiles
-mcmodel=medany -fvisibility=hidden -fno-PIC -g -O3 -fno-rtti -fno-exceptions
-fno-threadsafe-statics -c test.c -o test.o
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:
/nix/store/4b17xsrdcyd2bnm91pdclfw2wz3g0ikg-clang-21.0.0-unstable-2025-03-23/bin/clang
@/tmp/nix-shell.VojIba/cc-params.249Z4g
1. parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'utf8_count.c'.
4. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on
function '@utf8_count_SWAR_popc_bithack_autovec'
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 libLLVM.so.21.0git 0x7fffea78aa0c
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 60
1 libLLVM.so.21.0git 0x7fffea788774
llvm::sys::CleanupOnSignal(unsigned long) + 148
2 libLLVM.so.21.0git 0x7fffea668a88
3 libc.so.6 0x7fffe8e40f30
4 libLLVM.so.21.0git 0x7fffea9f4454
llvm::ScalableVectorType::get(llvm::Type*, unsigned int) + 20
5 libLLVM.so.21.0git 0x7fffeb0d2c50
llvm::EVT::getExtendedVectorVT(llvm::LLVMContext&, llvm::EVT,
llvm::ElementCount) + 48
6 libLLVM.so.21.0git 0x7fffeb35a250
7 libLLVM.so.21.0git 0x7fffeb35c008
8 libLLVM.so.21.0git 0x7fffeb2fd970
9 libLLVM.so.21.0git 0x7fffeb2fe3a9
llvm::SelectionDAG::LegalizeTypes() + 1321
10 libLLVM.so.21.0git 0x7fffeb47af5f
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 271
11 libLLVM.so.21.0git 0x7fffeb47dc5a
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 5274
12 libLLVM.so.21.0git 0x7fffeb47fb99
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 217
13 libLLVM.so.21.0git 0x7fffeb46e8e9
llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) + 409
14 libLLVM.so.21.0git 0x7fffead5e853
15 libLLVM.so.21.0git 0x7fffea972d89
llvm::FPPassManager::runOnFunction(llvm::Function&) + 1705
16 libLLVM.so.21.0git 0x7fffea972f3c
llvm::FPPassManager::runOnModule(llvm::Module&) + 44
17 libLLVM.so.21.0git 0x7fffea971f69
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1081
18 libclang-cpp.so.21.0git 0x75cc47f4
clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&,
llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::IntrusiveRefCntPtr,
std::unique_ptr>, clang::BackendConsumer*) + 2772
19 libclang-cpp.so.21.0git 0x760764bc
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1692
20 libclang-cpp.so.21.0git 0x74616eec clang::ParseAST(clang::Sema&,
bool, bool) + 1212
21 libclang-cpp.so.21.0git 0x76a79928 clang::FrontendAction::Execute()
+ 40
22 libclang-cpp.so.21.0git 0x769eec13
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1475
23 libclang-cpp.so.21.0git 0x76b1b11b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 539
24 clang 0x0041670a cc1_main(llvm::ArrayRef, char const*, void*) + 7306
25 clang 0x0040e8f3
26 libclang-cpp.so.21.0git 0x765d9a99
27 libLLVM.so.21.0git 0x7fffea668e93
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) + 35
28 libclang-cpp.so.21.0git 0x765da545
29 libclang-cpp.so.21.0git 0x7659966c
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&, bool) const + 172
30 libclang-cpp.so.21.0git 0x7659a652
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl>&, bool)
const + 146
31 libclang-cpp.so.21.0git 0x765b017c
c