[all-commits] [llvm/llvm-project] 38333d: [ARM] Empty structs are 1-byte for C++ ABI (#124762)

Oliver Stannard via All-commits all-commits at lists.llvm.org
Mon Feb 10 13:32:35 PST 2025


  Branch: refs/heads/release/20.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 38333d5e4258edaaaf449b720391d8bf2888e096
      https://github.com/llvm/llvm-project/commit/38333d5e4258edaaaf449b720391d8bf2888e096
  Author: Oliver Stannard <oliver.stannard at arm.com>
  Date:   2025-02-10 (Mon, 10 Feb 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/LangOptions.h
    M clang/lib/CodeGen/Targets/ARM.cpp
    A clang/test/CodeGen/arm-empty-args.cpp

  Log Message:
  -----------
  [ARM] Empty structs are 1-byte for C++ ABI (#124762)

For C++ (but not C), empty structs should be passed to functions as if
they are a 1 byte object with 1 byte alignment.

This is defined in Arm's CPPABI32:
  https://github.com/ARM-software/abi-aa/blob/main/cppabi32/cppabi32.rst
  For the purposes of parameter passing in AAPCS32, a parameter whose
  type is an empty class shall be treated as if its type were an
  aggregate with a single member of type unsigned byte.

The AArch64 equivalent of this has an exception for structs containing
an array of size zero, I've kept that logic for ARM. I've not found a
reason for this exception, but I've checked that GCC does have the same
behaviour for ARM as it does for AArch64.

The AArch64 version has an Apple ABI with different rules, which ignores
empty structs in both C and C++. This is documented at
https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms.
The ARM equivalent of that appears to be AAPCS16_VFP, used for WatchOS,
but I can't find any documentation for that ABI, so I'm not sure what
rules it should follow. For now I've left it following the AArch64 Apple
rules.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list