[clang] fix: compatible C++ empty record with align UB with gcc (PR #72197)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 14:21:21 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.
----------------
efriedma-quic wrote:

"to avoid va_list out of sync" doesn't really make sense; the important thing is that this follows the ABI rule.

Maybe take another look at the suggested comment inhttps://github.com/llvm/llvm-project/pull/72197#issuecomment-1815284976 .

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


More information about the cfe-commits mailing list