[cfe-commits] r56034 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGObjCMac.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Tue Sep 9 16:48:29 PDT 2008
Author: ddunbar
Date: Tue Sep 9 18:48:28 2008
New Revision: 56034
URL: http://llvm.org/viewvc/llvm-project?rev=56034&view=rev
Log:
Add CodeGenFunction::ReturnTypeUsesSret
- Hook so NeXT runtime doesn't depend on ABI.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=56034&r1=56033&r2=56034&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep 9 18:48:28 2008
@@ -117,6 +117,10 @@
/***/
+bool CodeGenFunction::ReturnTypeUsesSret(QualType RetTy) {
+ return hasAggregateLLVMType(RetTy);
+}
+
void CodeGenFunction::EmitFunctionProlog(llvm::Function *Fn,
QualType RetTy,
const FunctionArgList &Args) {
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=56034&r1=56033&r2=56034&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Sep 9 18:48:28 2008
@@ -158,7 +158,8 @@
ObjCTypesHelper(CodeGen::CodeGenModule &cgm);
~ObjCTypesHelper();
- llvm::Value *getMessageSendFn(bool IsSuper, const llvm::Type *ReturnTy);
+ llvm::Value *getMessageSendFn(bool IsSuper, bool isStret,
+ const llvm::Type *ReturnTy);
};
class CGObjCMac : public CodeGen::CGObjCRuntime {
@@ -528,13 +529,11 @@
CGF.getContext().getObjCSelType()));
ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end());
- // FIXME: This is a hack, we are implicitly coordinating with
- // EmitCall, which will move the return type to the first parameter
- // and set the structure return flag. See getMessageSendFn().
-
- const llvm::Type *ReturnTy = CGM.getTypes().ConvertType(ResultType);
- return CGF.EmitCall(ObjCTypes.getMessageSendFn(IsSuper, ReturnTy),
- ResultType, ActualArgs);
+ llvm::Value *Fn =
+ ObjCTypes.getMessageSendFn(IsSuper,
+ CGF.ReturnTypeUsesSret(ResultType),
+ CGM.getTypes().ConvertType(ResultType));
+ return CGF.EmitCall(Fn, ResultType, ActualArgs);
}
llvm::Value *CGObjCMac::GenerateProtocolRef(llvm::IRBuilder<> &Builder,
@@ -2249,12 +2248,13 @@
}
llvm::Value *ObjCTypesHelper::getMessageSendFn(bool IsSuper,
+ bool IsStret,
const llvm::Type *ReturnTy) {
llvm::Function *F;
llvm::FunctionType *CallFTy;
// FIXME: Should we be caching any of this?
- if (!ReturnTy->isSingleValueType()) {
+ if (IsStret) {
F = IsSuper ? MessageSendSuperStretFn : MessageSendStretFn;
std::vector<const llvm::Type*> Params(3);
Params[0] = llvm::PointerType::getUnqual(ReturnTy);
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=56034&r1=56033&r2=56034&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Sep 9 18:48:28 2008
@@ -138,6 +138,10 @@
const FunctionArgList &Args);
void FinishFunction(SourceLocation EndLoc=SourceLocation());
+ /// ReturnTypeUsesSret - Return true iff the given type uses 'sret'
+ /// when used as a return type.
+ bool ReturnTypeUsesSret(QualType RetTy);
+
/// EmitFunctionProlog - Emit the target specific LLVM code to load
/// the arguments for the given function. This is also responsible
/// for naming the LLVM function arguments.
More information about the cfe-commits
mailing list