Skip to content

"Type punning" some aarch64 SVE via pointers causes an internal compiler error #82859

@pinskia

Description

@pinskia

Take:

#include <arm_sve.h>

svint8_t f(svuint8x4_t s) {
	return *reinterpret_cast<svint8_t*>(&s);
}

Will cause an internal compile error:

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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -S -target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics -march=armv9-a+sve2 -O1 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'AArch64 Instruction Selection' on function '@_Z1f11svuint8x4_t'
 #0 0x0000000003624838 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3624838)
 #1 0x0000000003622984 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3622984)
 #2 0x0000000003570323 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3570323)
 #3 0x000000000361a36e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x361a36e)
 #4 0x0000000000c22476 (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc22476)
 #5 0x0000000003579373 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3579373)
 #6 0x00000000035794d8 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35794d8)
 #7 0x00000000035c8a4d (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35c8a4d)
 #8 0x00000000035c8a6c llvm::TypeSize::operator unsigned long() const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35c8a6c)
 #9 0x000000000465b796 llvm::SelectionDAGBuilder::EmitFuncArgumentDbgValue(llvm::Value const*, llvm::DILocalVariable*, llvm::DIExpression*, llvm::DILocation*, llvm::SelectionDAGBuilder::FuncArgumentDbgValueKind, llvm::SDValue const&)::'lambda0'(llvm::ArrayRef<std::pair<unsigned int, llvm::TypeSize>>)::operator()(llvm::ArrayRef<std::pair<unsigned int, llvm::TypeSize>>) const SelectionDAGBuilder.cpp:0:0
#10 0x0000000004674246 llvm::SelectionDAGBuilder::EmitFuncArgumentDbgValue(llvm::Value const*, llvm::DILocalVariable*, llvm::DIExpression*, llvm::DILocation*, llvm::SelectionDAGBuilder::FuncArgumentDbgValueKind, llvm::SDValue const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4674246)
#11 0x00000000046750e1 llvm::SelectionDAGBuilder::handleDebugValue(llvm::ArrayRef<llvm::Value const*>, llvm::DILocalVariable*, llvm::DIExpression*, llvm::DebugLoc, unsigned int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46750e1)
#12 0x0000000004679567 llvm::SelectionDAGBuilder::visitDbgInfo(llvm::Instruction const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4679567)
#13 0x00000000046b48d9 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46b48d9)
#14 0x000000000472dd16 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, true>, bool&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x472dd16)
#15 0x000000000472f348 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x472f348)
#16 0x0000000004731b29 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#17 0x0000000002ab83b0 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x0000000002fe9a52 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fe9a52)
#19 0x0000000002fe9bd1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2fe9bd1)
#20 0x0000000002feb7f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2feb7f0)
#21 0x0000000003892149 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3892149)
#22 0x0000000003e6cfb1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e6cfb1)
#23 0x0000000005cf7719 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5cf7719)
#24 0x0000000003e6c415 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e6c415)
#25 0x0000000004100a51 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4100a51)
#26 0x000000000407d00b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x407d00b)
#27 0x00000000041e2c33 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x41e2c33)
#28 0x0000000000c242a6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc242a6)
#29 0x0000000000c1cbdd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x0000000003eb39f9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x0000000003570223 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3570223)
#32 0x0000000003eb3c19 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x0000000003e7b9f7 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e7b9f7)
#34 0x0000000003e7c3ad clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e7c3ad)
#35 0x0000000003e8610c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e8610c)
#36 0x0000000000c21521 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc21521)
#37 0x0000000000b18064 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xb18064)

Metadata

Metadata

Labels

SVEARM Scalable Vector Extensionsbackend:AArch64crashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions