Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64][SVE] __SVFloat32_t results in Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!") #63223

Closed
DimitryAndric opened this issue Jun 9, 2023 · 6 comments
Assignees
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] SVE ARM Scalable Vector Extensions

Comments

@DimitryAndric
Copy link
Collaborator

DimitryAndric commented Jun 9, 2023

Test case (in C++):

// clang -cc1 -triple aarch64-- -S sve.cpp
void a() { __SVFloat32_t{}; }

Backtrace:

Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /home/dim/src/llvm/llvm-project/llvm/include/llvm/Support/Casting.h, line 578.
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: /home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang -cc1 -triple aarch64-- -S sve.cpp
1.      <eof> parser at end of file
2.      sve.cpp:1:6: LLVM IR generation of declaration 'a'
3.      sve.cpp:1:6: Generating code for declaration 'a'
 #0 0x00000000042e39a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x42e39a7)
 #1 0x00000000042e18b8 llvm::sys::RunSignalHandlers() (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x42e18b8)
 #2 0x00000000042e4140 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000000829364a3e handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
 #4 0x0000000829363ff9 thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1
 #5 0x0000000827d5d903 ([vdso]+0x2d3)
 #6 0x000000082f59897a __sys_thr_kill /usr/obj/usr/src/lib/libc/thr_kill.S:4:0
 #7 0x000000082f511954 __raise /usr/src/lib/libc/gen/raise.c:0:10
 #8 0x000000082f5c23e9 abort /usr/src/lib/libc/stdlib/abort.c:73:17
 #9 0x000000082f4f4a41 (/lib/libc.so.7+0x93a41)
#10 0x00000000046680af (anonymous namespace)::ScalarExprEmitter::VisitInitListExpr(clang::InitListExpr*) CGExprScalar.cpp:0:0
#11 0x00000000046556f0 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#12 0x0000000004670402 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#13 0x000000000465567b clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x465567b)
#14 0x000000000456b5fb clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x456b5fb)
#15 0x000000000456b578 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x456b578)
#16 0x00000000045aa6c2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x45aa6c2)
#17 0x00000000045b7380 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x45b7380)
#18 0x0000000004599fd9 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x4599fd9)
#19 0x00000000044d48f5 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x44d48f5)
#20 0x00000000044ccbda clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x44ccbda)
#21 0x00000000044d130e clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x44d130e)
#22 0x00000000044cb755 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x44cb755)
#23 0x0000000004e4572f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#24 0x0000000004e42965 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) CodeGenAction.cpp:0:0
#25 0x0000000005beaca8 clang::ParseAST(clang::Sema&, bool, bool) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x5beaca8)
#26 0x0000000004d68fe3 clang::FrontendAction::Execute() (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x4d68fe3)
#27 0x0000000004cec5df clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x4cec5df)
#28 0x0000000004e3ba38 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x4e3ba38)
#29 0x00000000028abb15 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x28abb15)
#30 0x00000000028a7a95 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x00000000028a6979 clang_main(int, char**, llvm::ToolContext const&) (/home/dim/ins/llvmorg-17-init-12643-ge821db39d22/bin/clang+0x28a6979)

Interestingly, the same type of test case in plain C works without asserting:

// clang -cc1 -triple aarch64-- -S sve.c
void a() { __SVFloat32_t x; }

gives:

$ clang -cc1 -triple aarch64-- -S sve.c
sve.c:2:26: error: SVE vector type '__SVFloat32_t' cannot be used in a target without sve
void a() { __SVFloat32_t x; }
                         ^
1 error generated.

and when enabling SVE explicitly, no problems at all:

$ clang -cc1 -triple aarch64-- -target-feature +sve -S sve.c
<nothing>
@DimitryAndric DimitryAndric added clang:frontend Language frontend issues, e.g. anything involving "Sema" SVE ARM Scalable Vector Extensions labels Jun 9, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 9, 2023

@llvm/issue-subscribers-clang-frontend

@DimitryAndric
Copy link
Collaborator Author

Note: this was noticed by @zxombie when building https://github.com/ARM-software/ComputeLibrary/

@EugeneZelenko EugeneZelenko added clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 9, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 9, 2023

@llvm/issue-subscribers-clang-codegen

@vfdff
Copy link
Contributor

vfdff commented Jun 10, 2023

works fine, https://gcc.godbolt.org/z/a1benvEMq

@DimitryAndric
Copy link
Collaborator Author

works fine, https://gcc.godbolt.org/z/a1benvEMq

Godbolt's compiler binaries do not have assertions enabled.

@paulwalker-arm paulwalker-arm self-assigned this Jun 22, 2023
@paulwalker-arm
Copy link
Collaborator

Candidate fix: https://reviews.llvm.org/D153560

freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Dec 4, 2023
  [Clang] Allow C++11 style initialisation of SVE types.

  Fixes llvm/llvm-project#63223

  Differential Revision: https://reviews.llvm.org/D153560

Requested by:	andrew
MFC after:	3 days
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Dec 24, 2023
  [Clang] Allow C++11 style initialisation of SVE types.

  Fixes llvm/llvm-project#63223

  Differential Revision: https://reviews.llvm.org/D153560

Requested by:	andrew
MFC after:	3 days

(cherry picked from commit 641efdd)
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Dec 24, 2023
  [Clang] Allow C++11 style initialisation of SVE types.

  Fixes llvm/llvm-project#63223

  Differential Revision: https://reviews.llvm.org/D153560

Requested by:	andrew
MFC after:	3 days

(cherry picked from commit 641efdd)
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this issue Mar 5, 2024
  [Clang] Allow C++11 style initialisation of SVE types.

  Fixes llvm/llvm-project#63223

  Differential Revision: https://reviews.llvm.org/D153560

Requested by:	andrew
MFC after:	3 days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] SVE ARM Scalable Vector Extensions
Projects
None yet
Development

No branches or pull requests

5 participants