mirror of
https://github.com/intel/llvm.git
synced 2026-02-09 01:34:21 +08:00
[SystemZ ABI] Allow class types in GetSingleElementType
The SystemZ ABI specifies that aggregate types with just a single member of floating-point type shall be passed as if they were just a scalar of that type. This applies to both struct and class types (but not unions). However, the current ABI support code in clang only checks this case for struct types, which means that for class types, generated code does not adhere to the platform ABI. Fixed by accepting both struct and class types in the SystemZABIInfo::GetSingleElementType routine.
This commit is contained in:
@@ -7208,7 +7208,9 @@ bool SystemZABIInfo::isFPArgumentType(QualType Ty) const {
|
||||
}
|
||||
|
||||
QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const {
|
||||
if (const RecordType *RT = Ty->getAsStructureType()) {
|
||||
const RecordType *RT = Ty->getAs<RecordType>();
|
||||
|
||||
if (RT && RT->isStructureOrClassType()) {
|
||||
const RecordDecl *RD = RT->getDecl();
|
||||
QualType Found;
|
||||
|
||||
|
||||
@@ -155,6 +155,17 @@ struct agg_nofloat3 pass_agg_nofloat3(struct agg_nofloat3 arg) { return arg; }
|
||||
// CHECK-LABEL: define void @pass_agg_nofloat3(%struct.agg_nofloat3* noalias sret align 4 %{{.*}}, i32 %{{.*}})
|
||||
|
||||
|
||||
// Union types likewise are *not* float-like aggregate types
|
||||
|
||||
union union_float { float a; };
|
||||
union union_float pass_union_float(union union_float arg) { return arg; }
|
||||
// CHECK-LABEL: define void @pass_union_float(%union.union_float* noalias sret align 4 %{{.*}}, i32 %{{.*}})
|
||||
|
||||
union union_double { double a; };
|
||||
union union_double pass_union_double(union union_double arg) { return arg; }
|
||||
// CHECK-LABEL: define void @pass_union_double(%union.union_double* noalias sret align 8 %{{.*}}, i64 %{{.*}})
|
||||
|
||||
|
||||
// Accessing variable argument lists
|
||||
|
||||
int va_int(__builtin_va_list l) { return __builtin_va_arg(l, int); }
|
||||
|
||||
@@ -2,10 +2,24 @@
|
||||
// RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s -mfloat-abi soft \
|
||||
// RUN: | FileCheck %s --check-prefix=SOFT-FLOAT
|
||||
|
||||
// Verify that class types are also recognized as float-like aggregate types
|
||||
|
||||
class agg_float_class { float a; };
|
||||
class agg_float_class pass_agg_float_class(class agg_float_class arg) { return arg; }
|
||||
// CHECK-LABEL: define void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret align 4 %{{.*}}, float %{{.*}})
|
||||
// SOFT-FLOAT-LABEL: define void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret align 4 %{{.*}}, i32 %{{.*}})
|
||||
|
||||
class agg_double_class { double a; };
|
||||
class agg_double_class pass_agg_double_class(class agg_double_class arg) { return arg; }
|
||||
// CHECK-LABEL: define void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret align 8 %{{.*}}, double %{{.*}})
|
||||
// SOFT-FLOAT-LABEL: define void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret 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).
|
||||
|
||||
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 align 4 %{{.*}}, float %{{.*}})
|
||||
// SOFT-FLOAT: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
|
||||
// SOFT-FLOAT-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user