[clang] fix: C++ empty record with align lead to va_list out of sync (PR #72197)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 25 09:36:45 PST 2023


================
@@ -307,7 +307,12 @@ AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,
     // 0.
     if (IsEmpty && Size == 0)
       return ABIArgInfo::getIgnore();
-    return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));
+    // An empty struct can have size greater than one byte if alignment is
+    // involved.
+    // When size <= 64, we still hold it by i8 in IR and lowering to registers.
+    // When Size > 64, just fall through to avoid va_list out of sync.
----------------
rjmccall wrote:

It looks like Tim is just implementing the standard rule from the PCS here and just didn't think about the fact that he could let the handling fall through to the main path.

`va_arg` would not require empty structs to occupy space for parameter passing; at worst, it would require us to recognize empty structs in the `va_arg` logic.  Even if it were unimplementable, though, that'd be a psABI problem, not a compiler one.

https://github.com/llvm/llvm-project/pull/72197


More information about the cfe-commits mailing list