Experiment with using first-class aggregates to represent member function
pointers. I find the resulting code to be substantially cleaner, and it
makes it very easy to use the same APIs for data member pointers (which I have
conscientiously avoided here), and it avoids a plethora of potential
inefficiencies due to excessive memory copying, but we'll have to see if it
actually works.
llvm-svn: 111776
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 5ea77be..b98b219 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -36,6 +36,11 @@
}
}
+static bool isAggregateTypeForABI(QualType T) {
+ return CodeGenFunction::hasAggregateLLVMType(T) ||
+ T->isMemberFunctionPointerType();
+}
+
ABIInfo::~ABIInfo() {}
ASTContext &ABIInfo::getContext() const {
@@ -218,7 +223,7 @@
FT = AT->getElementType();
}
- if (!CodeGenFunction::hasAggregateLLVMType(FT)) {
+ if (!isAggregateTypeForABI(FT)) {
Found = FT.getTypePtr();
} else {
Found = isSingleElementStruct(FT, Context);
@@ -314,7 +319,7 @@
}
ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
- if (CodeGenFunction::hasAggregateLLVMType(Ty))
+ if (isAggregateTypeForABI(Ty))
return ABIArgInfo::getIndirect(0);
// Treat an enum type as its underlying type.
@@ -467,7 +472,7 @@
return ABIArgInfo::getDirect();
}
- if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
+ if (isAggregateTypeForABI(RetTy)) {
if (const RecordType *RT = RetTy->getAs<RecordType>()) {
// Structures with either a non-trivial destructor or a non-trivial
// copy constructor are always indirect.
@@ -557,7 +562,7 @@
ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const {
// FIXME: Set alignment on indirect arguments.
- if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
+ if (isAggregateTypeForABI(Ty)) {
// Structures with flexible arrays are always indirect.
if (const RecordType *RT = Ty->getAs<RecordType>()) {
// Structures with either a non-trivial destructor or a non-trivial
@@ -1094,7 +1099,7 @@
ABIArgInfo X86_64ABIInfo::getIndirectReturnResult(QualType Ty) const {
// If this is a scalar LLVM value then assume LLVM will pass it in the right
// place naturally.
- if (!CodeGenFunction::hasAggregateLLVMType(Ty)) {
+ if (!isAggregateTypeForABI(Ty)) {
// Treat an enum type as its underlying type.
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
Ty = EnumTy->getDecl()->getIntegerType();
@@ -1109,7 +1114,7 @@
ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty) const {
// If this is a scalar LLVM value then assume LLVM will pass it in the right
// place naturally.
- if (!CodeGenFunction::hasAggregateLLVMType(Ty)) {
+ if (!isAggregateTypeForABI(Ty)) {
// Treat an enum type as its underlying type.
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
Ty = EnumTy->getDecl()->getIntegerType();
@@ -2079,7 +2084,7 @@
}
ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty) const {
- if (!CodeGenFunction::hasAggregateLLVMType(Ty)) {
+ if (!isAggregateTypeForABI(Ty)) {
// Treat an enum type as its underlying type.
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
Ty = EnumTy->getDecl()->getIntegerType();
@@ -2205,7 +2210,7 @@
if (RetTy->isVoidType())
return ABIArgInfo::getIgnore();
- if (!CodeGenFunction::hasAggregateLLVMType(RetTy)) {
+ if (!isAggregateTypeForABI(RetTy)) {
// Treat an enum type as its underlying type.
if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
RetTy = EnumTy->getDecl()->getIntegerType();
@@ -2295,7 +2300,7 @@
if (RetTy->isVoidType())
return ABIArgInfo::getIgnore();
- if (CodeGenFunction::hasAggregateLLVMType(RetTy))
+ if (isAggregateTypeForABI(RetTy))
return ABIArgInfo::getIndirect(0);
// Treat an enum type as its underlying type.
@@ -2370,7 +2375,7 @@
ABIArgInfo SystemZABIInfo::classifyReturnType(QualType RetTy) const {
if (RetTy->isVoidType())
return ABIArgInfo::getIgnore();
- if (CodeGenFunction::hasAggregateLLVMType(RetTy))
+ if (isAggregateTypeForABI(RetTy))
return ABIArgInfo::getIndirect(0);
return (isPromotableIntegerType(RetTy) ?
@@ -2378,7 +2383,7 @@
}
ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {
- if (CodeGenFunction::hasAggregateLLVMType(Ty))
+ if (isAggregateTypeForABI(Ty))
return ABIArgInfo::getIndirect(0);
return (isPromotableIntegerType(Ty) ?