diff options
| author | hstk30-hw <hanwei62@huawei.com> | 2025-11-08 21:52:13 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-08 21:52:13 +0800 |
| commit | 21c1b7845b05fb126631b91e7c978a51c3f9eb9a (patch) | |
| tree | eb99438cf9a81f202c22e3457cee04d052480dec /clang/lib | |
| parent | a0e222f7c7bc7b6de43391fbbdada8d511004b9c (diff) | |
| download | llvm-21c1b7845b05fb126631b91e7c978a51c3f9eb9a.zip llvm-21c1b7845b05fb126631b91e7c978a51c3f9eb9a.tar.gz llvm-21c1b7845b05fb126631b91e7c978a51c3f9eb9a.tar.bz2 | |
fix: C++ empty record with align lead to va_list out of sync (#72197)
Fix AArch64 argument passing for C++ empty classes with large explicitly specified alignment
reproducer: https://godbolt.org/z/qsze8fqra
rel issue: https://github.com/llvm/llvm-project/issues/69872
rel commit: https://github.com/llvm/llvm-project/commit/1711cc930bda8d27e87a2092bd220c18e4600c98
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/Targets/AArch64.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index bb41a14..d42fcd8 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -422,6 +422,12 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn, } // Empty records: + // AAPCS64 does not say that empty records are ignored as arguments, + // but other compilers do so in certain situations, and we copy that behavior. + // Those situations are in fact language-mode-specific, which seems really + // unfortunate, but it's something we just have to accept. If this doesn't + // apply, just fall through to the standard argument-handling path. + // Darwin overrides the psABI here to ignore all empty records in all modes. uint64_t Size = getContext().getTypeSize(Ty); bool IsEmpty = isEmptyRecord(getContext(), Ty, true); if (!Ty->isSVESizelessBuiltinType() && (IsEmpty || Size == 0)) { @@ -434,9 +440,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn, // behaviour here. if (Size == 0) return ABIArgInfo::getIgnore(); - - // Otherwise, they are passed as if they have a size of 1 byte. - return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext())); } // Homogeneous Floating-point Aggregates (HFAs) need to be expanded. |
