[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-05-15 Thread Jiongjia Lu via cfe-commits

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

[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-05-15 Thread Jiongjia Lu via cfe-commits

Avimitin wrote:

> Is the issue really related to this PR? Why would a MC change cause CodeGen 
> errors? Is it because uncommon extension combinations?

I've try to change march combination but which doesn't seems like the root 
cause of this issue. Even `-march=rv32gc_zve32f_xsfmm128t` could fail. But 
during the debug process I found that the root cause of this issue is from the 
`-O3` flag. The pass error could also happen for `-O2` flag. If I turn 
optimization flag off, or with `-O1`, `-O0`(the default optimization), `-Og`, 
the above problematic code could be compile successfully.

https://github.com/llvm/llvm-project/pull/133031
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-05-15 Thread Jiongjia Lu via cfe-commits

Avimitin wrote:

> can you please provide the 2 files indicated in the crash report

Yes here is the files (Sorry GitHub doesn't support uploading code file, so I 
have to change them to txt suffix):
[test-ef7560.sh.txt](https://github.com/user-attachments/files/20238776/test-ef7560.sh.txt)
[test-ef7560.c.txt](https://github.com/user-attachments/files/20238777/test-ef7560.c.txt)


https://github.com/llvm/llvm-project/pull/133031
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-05-20 Thread Jiongjia Lu via cfe-commits

Avimitin wrote:

I still get compiler error for the above case, but with additional error 
message:

```text
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: 
/nix/store/n44qhrqxb3qnbylypsfq75jl2lfsvbp6-clang-21.0.0-unstable-2025-03-23/bin/clang
 @/tmp/nix-shell.9YUR38/cc-params.lXn6o1
1.   parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'test.c'.
4.  Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on 
function '@utf8_count_SWAR_popc_bithack_autovec'
```

And here is the debug files:

[test.c.txt](https://github.com/user-attachments/files/20348260/test.c.txt)
[test.sh.txt](https://github.com/user-attachments/files/20348266/test.sh.txt)


https://github.com/llvm/llvm-project/pull/133031
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits