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 {
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,
}
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);
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.