Open bashimao opened 1 month ago
@llvm/issue-subscribers-clang-codegen
Author: Matthias Langer (bashimao)
Could you please try 19 or main
branch? https://godbolt.org should be helpful.
@EugeneZelenko It compiles on Godbolt. I compile for ARM64 on ARM64. I suppose the Godbolt compiler cross compiles on x86 for ARM64. So maybe this problem is just limited to the ARM64-compiled version of Clang?
@EugeneZelenko https://godbolt.org/z/d4aeYnaM4
@EugeneZelenko Regarding clang-19. Yes same problem.
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
clang++-19 -march=armv9-a main.cpp
Result:
$ clang++-19 -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-19/bin/clang -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -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 +bti -target-feature +ccidx -target-feature +complxnum -target-feature +crc -target-feature +dit -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +ssbs -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-19/lib/clang/19 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/aarch64-linux-gnu/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/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-226fbc.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 0x0000f90fb5115e7c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xeb5e7c)
#1 0x0000f90fb5113ec0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xeb3ec0)
#2 0x0000f90fb51165e0 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xeb65e0)
#3 0x0000f90fbfd009d0 (linux-vdso.so.1+0x9d0)
#4 0x0000f90fb5268a08 llvm::LLVMContext::shouldDiscardValueNames() const (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0x1008a08)
#5 0x0000f90fb52d1010 llvm::Value::setNameImpl(llvm::Twine const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0x1071010)
#6 0x0000f90fb52d13d0 llvm::Value::setName(llvm::Twine const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0x10713d0)
#7 0x0000f90fbdbe12c4 clang::CodeGen::CGBuilderInserter::InsertHelper(llvm::Instruction*, llvm::Twine const&, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, false>) const (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21e12c4)
#8 0x0000f90fbd8a2808 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ea2808)
#9 0x0000f90fbda61adc clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2061adc)
#10 0x0000f90fbda61d50 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2061d50)
#11 0x0000f90fbda50424 clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2050424)
#12 0x0000f90fbda35bd0 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2035bd0)
#13 0x0000f90fbda3a358 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x203a358)
#14 0x0000f90fbda37e30 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2037e30)
#15 0x0000f90fbda34188 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2034188)
#16 0x0000f90fbda33e8c clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2033e8c)
#17 0x0000f90fbdb81454 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2181454)
#18 0x0000f90fbdb800f0 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21800f0)
#19 0x0000f90fbdb8af6c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x218af6c)
#20 0x0000f90fbdbdd74c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21dd74c)
#21 0x0000f90fbdbfdc1c clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21fdc1c)
#22 0x0000f90fbdbf6b20 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21f6b20)
#23 0x0000f90fbdbfa598 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21fa598)
#24 0x0000f90fbdbf586c clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21f586c)
#25 0x0000f90fbdc999d8 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x22999d8)
#26 0x0000f90fbdbcf37c clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x21cf37c)
#27 0x0000f90fbc641840 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc41840)
#28 0x0000f90fbe6933c0 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2c933c0)
#29 0x0000f90fbe61c554 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2c1c554)
#30 0x0000f90fbe7108f8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2d108f8)
#31 0x0000c01920cb0fd4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x10fd4)
#32 0x0000c01920cae6b8 (/usr/lib/llvm-19/bin/clang+0xe6b8)
#33 0x0000c01920cad738 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xd738)
#34 0x0000c01920cba21c main (/usr/lib/llvm-19/bin/clang+0x1a21c)
#35 0x0000f90fb3d484c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
#36 0x0000f90fb3d48598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
#37 0x0000c01920cac4b0 _start (/usr/lib/llvm-19/bin/clang+0xc4b0)
clang++-19: error: unable to execute command: Segmentation fault (core dumped)
clang++-19: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 19.1.0 (++20240903073245+9b6180ed2ecb-1~exp1~20240903073259.29)
Target: aarch64-unknown-linux-gnu
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/main-d238cc.cpp
clang++-19: note: diagnostic msg: /tmp/main-d238cc.sh
clang++-19: note: diagnostic msg:
********************
Same issue in GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116595
I think it is the same issue can be reproduced with the RISC-V V intrinsic types too.
@pinskia Not sure. I compiles flawlessly on GCC-12, 13, and 14. Also, this doesn't happen with ARM Neon intrinsic types. Only with SVE intrinsic types.
The following compiles with clang++-16, clang++-17 and clang++18:
But, if you alias the vector type with
using
as in the following:and compile it:
both
clang++-18
andclang++-17
will just die with segfault.This code can be compiled with
clang++-16
though. So, something was somewhat recently changed that broke it.main-2c0338.cpp.txt main-2c0338.sh.txt