Skip to content

__attribute__((preserve_all)) crashes with "Unsupported calling convention" on ARMv8 #58145

@mkeeter

Description

@mkeeter

Compiling this trivial program using Homebrew clang version 15.0.0, I see a crash:

__attribute__((preserve_all)) float bar(float a);

float run(float foo) {
    return bar(foo);
}

with the error

fatal error: error in backend: Unsupported calling convention.

Godbolt crashes as well, so it's hopefully easy to reproduce!

Full backtrace

Stack dump:
0.	Program arguments: /opt/homebrew/Cellar/llvm/15.0.0/bin/clang -c lol.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'lol.c'.
4.	Running pass 'IRTranslator' on function '@run'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.dylib      0x0000000115b7c6fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  libLLVM.dylib      0x0000000115b7ba58 llvm::sys::CleanupOnSignal(unsigned long) + 252
2  libLLVM.dylib      0x0000000118f08ff0 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 96
3  libLLVM.dylib      0x0000000118f09050 llvm::CrashRecoveryContext::HandleExit(int) + 20
4  libLLVM.dylib      0x0000000118f1c2f0 llvm::sys::Process::Exit(int, bool) + 48
5  clang-15           0x0000000104e6e0d8 LLVMErrorHandler(void*, char const*, bool) + 200
6  libLLVM.dylib      0x0000000115ab1acc llvm::report_fatal_error(llvm::Twine const&, bool) + 268
7  libLLVM.dylib      0x0000000118f0b968 llvm::report_fatal_error(llvm::StringRef, bool) + 0
8  libLLVM.dylib      0x000000011779be48 llvm::AArch64CallLowering::lowerCall(llvm::MachineIRBuilder&, llvm::CallLowering::CallLoweringInfo&) const + 3056
9  libLLVM.dylib      0x000000011656a598 llvm::CallLowering::lowerCall(llvm::MachineIRBuilder&, llvm::CallBase const&, llvm::ArrayRef<llvm::Register>, llvm::ArrayRef<llvm::ArrayRef<llvm::Register>>, llvm::Register, std::__1::function<unsigned int ()>) const + 1716
10 libLLVM.dylib      0x0000000116596628 llvm::IRTranslator::translateCallBase(llvm::CallBase const&, llvm::MachineIRBuilder&) + 1096
11 libLLVM.dylib      0x000000011658aa3c llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) + 3188
12 libLLVM.dylib      0x0000000115fa19ec llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 556
13 libLLVM.dylib      0x0000000115d09588 llvm::FPPassManager::runOnModule(llvm::Module&) + 2796
14 libLLVM.dylib      0x0000000115d30a7c llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1028
15 libclang-cpp.dylib 0x000000010ab1d3a8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>) + 3332
16 libclang-cpp.dylib 0x000000010ae579dc clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1600
17 libclang-cpp.dylib 0x00000001099e7058 clang::ParseAST(clang::Sema&, bool, bool) + 768
18 libclang-cpp.dylib 0x000000010b4b6744 clang::FrontendAction::Execute() + 96
19 libclang-cpp.dylib 0x000000010b43f8ac clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 592
20 libclang-cpp.dylib 0x000000010b4fde18 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 512
21 clang-15           0x0000000104e6d648 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1776
22 clang-15           0x0000000104e6c024 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 788
23 libclang-cpp.dylib 0x000000010b0f26ac void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_1>(long) + 28

Preprocessed source

# 1 "<built-in>"
# 1 "lol.c"
__attribute__((preserve_all)) float bar(float a);

float run(float foo) {
    return bar(foo);
}

Run script

# Crash reproducer for Homebrew clang version 15.0.0
# Driver args: "-c" "lol.c"
# Original command:  "/opt/homebrew/Cellar/llvm/15.0.0/bin/clang-15" "-cc1" "-triple" "arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "lol.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=2" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" "-target-feature" "+crc" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes" "-target-abi" "darwinpcs" "-fallow-half-arguments-and-returns" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=lldb" "-target-linker-version" "819.6" "-fcoverage-compilation-dir=/Users/mkeeter" "-resource-dir" "/opt/homebrew/Cellar/llvm/15.0.0/lib/clang/15.0.0" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk" "-internal-isystem" "/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/local/include" "-internal-isystem" "/opt/homebrew/Cellar/llvm/15.0.0/lib/clang/15.0.0/include" "-internal-externc-isystem" "/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include" "-fdebug-compilation-dir=/Users/mkeeter" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-fcolor-diagnostics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "lol.o" "-x" "c" "lol.c"
 "/opt/homebrew/Cellar/llvm/15.0.0/bin/clang-15" "-cc1" "-triple" "arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "lol.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=2" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" "-target-feature" "+crc" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes" "-target-abi" "darwinpcs" "-fallow-half-arguments-and-returns" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=lldb" "-target-linker-version" "819.6" "-fcoverage-compilation-dir=/Users/mkeeter" "-fdebug-compilation-dir=/Users/mkeeter" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-fcolor-diagnostics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "lol-de1abc.c"

Metadata

Metadata

Labels

backend:AArch64confirmedVerified by a second partycrashPrefer [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