| Issue |
107609
|
| Summary |
`clang++-17` and `clang++-18` segfault when using aliased ARM64 SVE intrinsic types
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
bashimao
|
The following compiles with clang++-16, clang++-17 and clang++18:
```
#include <arm_sve.h>
#include <iostream>
int main(int,const char*[]) {
svbool_t pg{svptrue_b8()};
svint8_t a{svdup_s8(1)};
svint8_t b{svdup_s8(2)};
svint8_t c = svadd_s8_x(pg, a, b);
std::cout << svaddv_s8(pg, c) << '\n';
}
```
But, if you alias the vector type with `using` as in the following:
```
#include <arm_sve.h>
#include <iostream>
using vec_t = svint8_t;
int main(int,const char*[]) {
svbool_t pg{svptrue_b8()};
vec_t a{svdup_s8(1)};
vec_t b{svdup_s8(2)};
vec_t c = svadd_s8_x(pg, a, b);
std::cout << svaddv_s8(pg, c) << '\n';
}
```
and compile it:
```
clang++-18 -march=armv9-a main.cpp
clang++-17 -march=armv9-a main.cpp
```
both `clang++-18` and `clang++-17` will just die with segfault.
```
clang++-18 -march=armv9-a main.cpp
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/lib/llvm-18/bin/clang -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v9a -target-feature +crc -target-feature +dotprod -target-feature +complxnum -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +pauth -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +neon -target-feature +sve -target-feature +sve2 -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/monkey-wrench/minimal-sample -fcoverage-compilation-dir=/monkey-wrench/minimal-sample -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/aarch64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -target-feature +outline-atomics -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-ad1a30.o -x c++ main.cpp
1. main.cpp:19:1: current parser token 'int'
2. main.cpp:6:5: LLVM IR generation of declaration 'main'
3. main.cpp:6:5: Generating code for declaration 'main'
#0 0x0000e82423ecd398 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9d398)
#1 0x0000e82423ecb5a8 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9b5a8)
#2 0x0000e82423ecdafc (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9dafc)
#3 0x0000e8242e2009d0 (linux-vdso.so.1+0x9d0)
#4 0x0000e8242401a3f8 llvm::LLVMContext::shouldDiscardValueNames() const (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xeea3f8)
#5 0x0000e8242407b854 llvm::Value::setNameImpl(llvm::Twine const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xf4b854)
#6 0x0000e8242407bc10 llvm::Value::setName(llvm::Twine const&) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xf4bc10)
#7 0x0000e8242c2b6bd4 clang::CodeGen::CGBuilderInserter::InsertHelper(llvm::Instruction*, llvm::Twine const&, llvm::BasicBlock*, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, false>) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f36bd4)
#8 0x0000e8242bf8ab58 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1c0ab58)
#9 0x0000e8242c13ebe4 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dbebe4)
#10 0x0000e8242c13ee54 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dbee54)
#11 0x0000e8242c12df44 clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1dadf44)
#12 0x0000e8242c1145b4 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d945b4)
#13 0x0000e8242c1185b0 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d985b0)
#14 0x0000e8242c1164f8 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d964f8)
#15 0x0000e8242c112c3c clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d92c3c)
#16 0x0000e8242c112940 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1d92940)
#17 0x0000e8242c25bc44 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1edbc44)
#18 0x0000e8242c25afe4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1edafe4)
#19 0x0000e8242c264700 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1ee4700)
#20 0x0000e8242c2b2420 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f32420)
#21 0x0000e8242c2b2e48 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f32e48)
#22 0x0000e8242c2d2ab8 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f52ab8)
#23 0x0000e8242c2cbb28 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4bb28)
#24 0x0000e8242c2cf72c clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4f72c)
#25 0x0000e8242c2ca78c clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f4a78c)
#26 0x0000e8242c36bd58 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1febd58)
#27 0x0000e8242c2a5658 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x1f25658)
#28 0x0000e8242af0a610 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb8a610)
#29 0x0000e8242ccbfa34 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x293fa34)
#30 0x0000e8242cc50590 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x28d0590)
#31 0x0000e8242cd38e4c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29b8e4c)
#32 0x0000ab1a073521c4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x121c4)
#33 0x0000ab1a0734fbac (/usr/lib/llvm-18/bin/clang+0xfbac)
#34 0x0000ab1a0734ed00 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0xed00)
#35 0x0000ab1a0735ae40 main (/usr/lib/llvm-18/bin/clang+0x1ae40)
#36 0x0000e82422d084c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
#37 0x0000e82422d08598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
#38 0x0000ab1a0734c970 _start (/usr/lib/llvm-18/bin/clang+0xc970)
clang++-18: error: unable to execute command: Segmentation fault (core dumped)
clang++-18: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++-18: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++-18: note: diagnostic msg: /tmp/main-2c0338.cpp
clang++-18: note: diagnostic msg: /tmp/main-2c0338.sh
clang++-18: note: diagnostic msg:
********************
```
This code can be compiled with `clang++-16` though. So, something was somewhat recently changed that broke it.
[main-2c0338.cpp.txt](https://github.com/user-attachments/files/16910995/main-2c0338.cpp.txt)
[main-2c0338.sh.txt](https://github.com/user-attachments/files/16910996/main-2c0338.sh.txt)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs