Assertion failure in AArch64ABIInfo::shouldPassInCapabilityRegisters with packed struct containing underaligned capability
Purecap Morello LLVM crashes on the following C testcase (see https://cheri-compiler-explorer.cl.cam.ac.uk/z/sfjcY8):
struct __attribute((packed)) S {
unsigned short b;
__uintcap_t a;
};
__uintcap_t f(struct S s) {
return s.a;
}
with the backtrace:
clang: /local/scratch/jenkins/workspace/orello-LLVM-linux_morello_master/morello-llvm-project/clang/lib/CodeGen/TargetInfo.cpp:5858: llvm::Type *(anonymous namespace)::AArch64ABIInfo::shouldPassInCapabilityRegisters(clang::QualType) const: Assertion `(First || Second) && "Should have at least one capability"' failed.
PLEASE submit a bug report to https://github.com/CTSRD-CHERI/llvm-project/issues and include the crash backtrace, preprocessed source, and associated run script.
If you built clang from source, please provide a reduced test case by running:
$LLVM_BUILD_DIR/bin/creduce_crash_testcase.py <reproducer>.sh
Stack dump:
0. Program arguments: /morello-sdk/bin/clang -g -o /tmp/compiler-explorer-compiler20211016-64-on8nxj.xny6r/output.s -mllvm --x86-asm-syntax=intel -S -target aarch64-unknown-freebsd13 --sysroot=/morello-sdk/sysroot-morello-purecap -Wall -march=morello+c64 -mabi=purecap -fcolor-diagnostics -fno-crash-diagnostics -O2 <source>
1. <eof> parser at end of file
2. <source>:5:13: LLVM IR generation of declaration 'f'
3. <source>:5:13: Generating code for declaration 'f'
#0 0x000000000419eddd (/morello-sdk/bin/clang+0x419eddd)
#1 0x000000000419c5ce llvm::sys::RunSignalHandlers() (/morello-sdk/bin/clang+0x419c5ce)
#2 0x000000000419ddbd llvm::sys::CleanupOnSignal(unsigned long) (/morello-sdk/bin/clang+0x419ddbd)
#3 0x0000000004118881 (/morello-sdk/bin/clang+0x4118881)
#4 0x0000000004118b1a (/morello-sdk/bin/clang+0x4118b1a)
#5 0x00007f4761c313c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#6 0x00007f47618a918b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
#7 0x00007f4761888859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
#8 0x00007f4761888729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
#9 0x00007f4761899f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#10 0x00000000049f1258 (/morello-sdk/bin/clang+0x49f1258)
#11 0x00000000049f0778 (/morello-sdk/bin/clang+0x49f0778)
#12 0x00000000049ee51e (/morello-sdk/bin/clang+0x49ee51e)
#13 0x00000000045cc554 clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, bool, bool, llvm::ArrayRef<clang::CanQual<clang::Type> >, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) (/morello-sdk/bin/clang+0x45cc554)
#14 0x00000000045ccbda (/morello-sdk/bin/clang+0x45ccbda)
#15 0x00000000045ceaf4 clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(clang::FunctionDecl const*) (/morello-sdk/bin/clang+0x45ceaf4)
#16 0x00000000044363a4 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/morello-sdk/bin/clang+0x44363a4)
#17 0x000000000442d129 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/morello-sdk/bin/clang+0x442d129)
#18 0x000000000443b9da clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/morello-sdk/bin/clang+0x443b9da)
#19 0x0000000004d4b0e0 (/morello-sdk/bin/clang+0x4d4b0e0)
#20 0x0000000004d48776 (/morello-sdk/bin/clang+0x4d48776)
#21 0x00000000055f65f4 clang::ParseAST(clang::Sema&, bool, bool) (/morello-sdk/bin/clang+0x55f65f4)
#22 0x0000000004c86bb2 clang::FrontendAction::Execute() (/morello-sdk/bin/clang+0x4c86bb2)
#23 0x0000000004bd1e52 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/morello-sdk/bin/clang+0x4bd1e52)
#24 0x0000000004d42606 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/morello-sdk/bin/clang+0x4d42606)
#25 0x000000000292e14b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/morello-sdk/bin/clang+0x292e14b)
#26 0x000000000292c1ad (/morello-sdk/bin/clang+0x292c1ad)
#27 0x0000000004a5cf62 (/morello-sdk/bin/clang+0x4a5cf62)
#28 0x00000000041186e8 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/morello-sdk/bin/clang+0x41186e8)
#29 0x0000000004a5c53c clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/morello-sdk/bin/clang+0x4a5c53c)
#30 0x0000000004a20b79 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/morello-sdk/bin/clang+0x4a20b79)
#31 0x0000000004a20fb7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/morello-sdk/bin/clang+0x4a20fb7)
#32 0x0000000004a3dc2b clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/morello-sdk/bin/clang+0x4a3dc2b)
#33 0x000000000292b80a main (/morello-sdk/bin/clang+0x292b80a)
#34 0x00007f476188a0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#35 0x0000000002882c0a _start (/morello-sdk/bin/clang+0x2882c0a)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information