Skip to content

[FMV] The compiler crashes in the absence of default target version. #84015

Closed
@labrinea

Description

@labrinea

I believe we should be diagnosing the lack of default definition instead of crashing.
I can only reproduce this if a declaration if followed by a definition as below:

fmv.c

int __attribute__((target_version("sm4"))) def(void);
int __attribute__((target_version("sha1"))) def(void) { return 1; }

$ clang --target=aarch64-linux-gnu --rtlib=compiler-rt fmv.c -S -o -

llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:2796: void clang::CodeGen::CodeGenFunction::EmitAArch64MultiVersionResolver(llvm::Function*, llvm::ArrayRef<clang::CodeGen::CodeGenFunction::MultiVersionResolverOption>): Assertion `Options.back().Conditions.Features.size() == 0 && "Default case must be last"' failed.
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: ./bin/clang --target=aarch64-linux-gnu --rtlib=compiler-rt ../llvm-project/fmv.c -S -o -
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
 #0 0x00005644724ee8df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./bin/clang+0x81cb8df)
 #1 0x00005644724ec41c llvm::sys::CleanupOnSignal(unsigned long) (./bin/clang+0x81c941c)
 #2 0x0000564472425dc8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f8dfd333420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f8dfcdd000b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f8dfcdaf859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f8dfcdaf729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f8dfcdaf729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f8dfcdc0fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x0000564472950e53 clang::CodeGen::CodeGenFunction::EmitAArch64MultiVersionResolver(llvm::Function*, llvm::ArrayRef<clang::CodeGen::CodeGenFunction::MultiVersionResolverOption>) (./bin/clang+0x862de53)
#10 0x000056447285f3c7 clang::CodeGen::CodeGenModule::emitMultiVersionFunctions() (./bin/clang+0x853c3c7)
#11 0x0000564472861d01 clang::CodeGen::CodeGenModule::Release() (./bin/clang+0x853ed01)
#12 0x0000564472d9c352 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#13 0x0000564472d9bb85 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (./bin/clang+0x8a78b85)
#14 0x0000564474eff8d9 clang::ParseAST(clang::Sema&, bool, bool) (./bin/clang+0xabdc8d9)
#15 0x0000564472d9b418 clang::CodeGenAction::ExecuteAction() (./bin/clang+0x8a78418)
#16 0x00005644732bafa9 clang::FrontendAction::Execute() (./bin/clang+0x8f97fa9)
#17 0x0000564473234c2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (./bin/clang+0x8f11c2e)
#18 0x00005644733b2796 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (./bin/clang+0x908f796)
#19 0x000056446f6ab256 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (./bin/clang+0x5388256)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions