diff options
| author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2022-03-24 12:41:34 +0100 |
|---|---|---|
| committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2022-04-26 17:16:14 +0200 |
| commit | 9b38e2efa0f0c819ec696d13731ac1ce08f81930 (patch) | |
| tree | be24a9aaaf166b509773e068d0c2196f9f72804f | |
| parent | f9d56572174a83008cbaa4c92f2b34a1c88d348f (diff) | |
| download | llvm-9b38e2efa0f0c819ec696d13731ac1ce08f81930.zip llvm-9b38e2efa0f0c819ec696d13731ac1ce08f81930.tar.gz llvm-9b38e2efa0f0c819ec696d13731ac1ce08f81930.tar.bz2 | |
[SystemZ] Fix C++ ABI for passing args of structs containing zero width bitfield.
A struct like { float a; int :0; } should per the SystemZ ABI be passed in a
GPR, but to match a bug in GCC it has been passed in an FPR (see 759449c).
GCC has now corrected the C++ ABI for this case, and this patch for clang
follows suit.
Reviewed By: Ulrich Weigand
Differential Revision: https://reviews.llvm.org/D122388
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CodeGen/SystemZ/systemz-abi.cpp | 6 |
2 files changed, 3 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index c5a031d..ecbb350 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -7514,12 +7514,9 @@ QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const { // Check the fields. for (const auto *FD : RD->fields()) { - // For compatibility with GCC, ignore empty bitfields in C++ mode. // Unlike isSingleElementStruct(), empty structure and array fields // do count. So do anonymous bitfields that aren't zero-sized. - if (getContext().getLangOpts().CPlusPlus && - FD->isZeroLengthBitField(getContext())) - continue; + // Like isSingleElementStruct(), ignore C++20 empty data members. if (FD->hasAttr<NoUniqueAddressAttr>() && isEmptyRecord(getContext(), FD->getType(), true)) diff --git a/clang/test/CodeGen/SystemZ/systemz-abi.cpp b/clang/test/CodeGen/SystemZ/systemz-abi.cpp index 9a0b2e3..a76bba3 100644 --- a/clang/test/CodeGen/SystemZ/systemz-abi.cpp +++ b/clang/test/CodeGen/SystemZ/systemz-abi.cpp @@ -15,12 +15,10 @@ class agg_double_class pass_agg_double_class(class agg_double_class arg) { retur // SOFT-FLOAT-LABEL: define{{.*}} void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret(%class.agg_double_class) align 8 %{{.*}}, i64 %{{.*}}) -// For compatibility with GCC, this structure is passed in an FPR in C++, -// but passed in a GPR in C (checked in systemz-abi.c). - +// This structure is passed in a GPR in C++ (and C, checked in systemz-abi.c). struct agg_float_cpp { float a; int : 0; }; struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return arg; } -// CHECK-LABEL: define{{.*}} void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret(%struct.agg_float_cpp) align 4 %{{.*}}, float %{{.*}}) +// CHECK-LABEL: define{{.*}} void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret(%struct.agg_float_cpp) align 4 %{{.*}}, i32 %{{.*}}) // SOFT-FLOAT-LABEL: define{{.*}} void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret(%struct.agg_float_cpp) align 4 %{{.*}}, i32 %{{.*}}) |
