]> granicus.if.org Git - clang/commitdiff
Add CodeGenFunction::ReturnTypeUsesSret
authorDaniel Dunbar <daniel@zuster.org>
Tue, 9 Sep 2008 23:48:28 +0000 (23:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 9 Sep 2008 23:48:28 +0000 (23:48 +0000)
 - Hook so NeXT runtime doesn't depend on ABI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56034 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenFunction.h

index 89004325c16d4f6c88cce804657cac893f1a19e2..8b7400af566b607ee64732f6ce9274030a551a45 100644 (file)
@@ -117,6 +117,10 @@ void CGCallInfo::constructParamAttrList(ParamAttrListType &PAL) const {
 
 /***/
 
+bool CodeGenFunction::ReturnTypeUsesSret(QualType RetTy) {
+  return hasAggregateLLVMType(RetTy);
+}
+
 void CodeGenFunction::EmitFunctionProlog(llvm::Function *Fn,
                                          QualType RetTy, 
                                          const FunctionArgList &Args) {
index a64b16041a6be809975ebadd6dcfcb117a35f89f..ff7717dad33bffadb053c69ec143e1a8bf5ccc61 100644 (file)
@@ -158,7 +158,8 @@ public:
   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 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
                                       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 @@ ObjCTypesHelper::~ObjCTypesHelper() {
 }
 
 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);
index 5054b56d212c09aa902858c03f25b3479a9950ef..f5eba15a244da9e05eac163ea8c0f156afe0c359 100644 (file)
@@ -138,6 +138,10 @@ public:
                      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.