aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-09-10 07:00:50 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-09-10 07:00:50 +0000
commit62d5c1b5038cdaa4a887a03c37fe1e8d00166ea0 (patch)
treec78895f289418d46af0c29fc930caf0315338231 /lib/CodeGen/CGCall.cpp
parent45c25ba11cbf8c9a461def5b03f6ee9481e06769 (diff)
Add CodeGenTypes::GetFunctionType overload for getting the effective
type of a call. Change NeXT runtime to use this instead of trying to bitcasting internally (which doesn't respect the ABI). Fix subtle bug, use of ConvertTypeRecursive instead of ConvertType is bad inside GetFunctionType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56050 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r--lib/CodeGen/CGCall.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index b684b4463e..473abd5d8b 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -144,12 +144,22 @@ static ABIArgInfo classifyReturnType(QualType RetTy) {
/***/
const llvm::FunctionType *
+CodeGenTypes::GetFunctionType(const CGCallInfo &CI, bool IsVariadic) {
+ return GetFunctionType(CI.argtypes_begin(), CI.argtypes_end(), IsVariadic);
+}
+
+const llvm::FunctionType *
CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
+ return GetFunctionType(FI.argtypes_begin(), FI.argtypes_end(), FI.isVariadic());
+}
+
+const llvm::FunctionType *
+CodeGenTypes::GetFunctionType(ArgTypeIterator begin, ArgTypeIterator end,
+ bool IsVariadic) {
std::vector<const llvm::Type*> ArgTys;
const llvm::Type *ResultType = 0;
- ArgTypeIterator begin = FI.argtypes_begin(), end = FI.argtypes_end();
QualType RetTy = *begin;
ABIArgInfo RetAI = classifyReturnType(RetTy);
switch (RetAI.getKind()) {
@@ -157,25 +167,25 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
if (RetTy->isVoidType()) {
ResultType = llvm::Type::VoidTy;
} else {
- ResultType = ConvertTypeRecursive(RetTy);
+ ResultType = ConvertType(RetTy);
}
break;
case ABIArgInfo::StructRet: {
ResultType = llvm::Type::VoidTy;
- const llvm::Type *STy = ConvertTypeRecursive(RetTy);
+ const llvm::Type *STy = ConvertType(RetTy);
ArgTys.push_back(llvm::PointerType::get(STy, RetTy.getAddressSpace()));
break;
}
case ABIArgInfo::Coerce:
ResultType = llvm::Type::VoidTy;
- ArgTys.push_back(ConvertTypeRecursive(RetAI.getCoerceToType()));
+ ArgTys.push_back(ConvertType(RetAI.getCoerceToType()));
break;
}
for (++begin; begin != end; ++begin) {
- const llvm::Type *Ty = ConvertTypeRecursive(*begin);
+ const llvm::Type *Ty = ConvertType(*begin);
if (Ty->isSingleValueType())
ArgTys.push_back(Ty);
else
@@ -183,9 +193,10 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
ArgTys.push_back(llvm::PointerType::getUnqual(Ty));
}
- return llvm::FunctionType::get(ResultType, ArgTys, FI.isVariadic());
+ return llvm::FunctionType::get(ResultType, ArgTys, IsVariadic);
}
+// FIXME: This can die now?
bool CodeGenModule::ReturnTypeUsesSret(QualType RetTy) {
return classifyReturnType(RetTy).isStructRet();
}