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

Oliver Stannard via All-commits all-commits at lists.llvm.org
Fri Jan 31 01:03:29 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 97b066f4e92a0df46b9d10721e988210f0d1afb6
      https://github.com/llvm/llvm-project/commit/97b066f4e92a0df46b9d10721e988210f0d1afb6
  Author: Oliver Stannard <oliver.stannard at arm.com>
  Date:   2025-01-31 (Fri, 31 Jan 2025)

  Changed paths:
    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