[cfe-commits] r142795 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/CodeGen/CGObjCGNU.cpp
David Chisnall
csdavec at swan.ac.uk
Mon Oct 24 07:07:04 PDT 2011
Author: theraven
Date: Mon Oct 24 09:07:03 2011
New Revision: 142795
URL: http://llvm.org/viewvc/llvm-project?rev=142795&view=rev
Log:
Enable experimental support for objc_msgSend with GNUstep ObjC runtime.
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=142795&r1=142794&r2=142795&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Oct 24 09:07:03 2011
@@ -131,7 +131,7 @@
/// IsObjCLegacyDispatchDefault - Does this tool chain set
/// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
/// ABI).
- virtual bool IsObjCLegacyDispatchDefault() const { return false; }
+ virtual bool IsObjCLegacyDispatchDefault() const { return true; }
/// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
/// mixed dispatch method be used?
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=142795&r1=142794&r2=142795&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon Oct 24 09:07:03 2011
@@ -1159,25 +1159,48 @@
};
llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);
- // Get the IMP to call
- llvm::Value *imp = LookupIMP(CGF, Receiver, cmd, node);
-
+ CodeGenTypes &Types = CGM.getTypes();
CallArgList ActualArgs;
ActualArgs.add(RValue::get(Receiver), ASTIdTy);
ActualArgs.add(RValue::get(cmd), CGF.getContext().getObjCSelType());
ActualArgs.addFrom(CallArgs);
-
- CodeGenTypes &Types = CGM.getTypes();
const CGFunctionInfo &FnInfo = Types.getFunctionInfo(ResultType, ActualArgs,
FunctionType::ExtInfo());
+ // Get the IMP to call
+ llvm::Value *imp;
+
+ // If we have non-legacy dispatch specified, we try using the objc_msgSend()
+ // functions. These are not supported on all platforms (or all runtimes on a
+ // given platform), so we
+ switch (CGM.getCodeGenOpts().getObjCDispatchMethod()) {
+ default:
+ llvm_unreachable("Invalid dispatch method!");
+ case CodeGenOptions::Legacy:
+ fprintf(stderr, "Legacy\n");
+ imp = LookupIMP(CGF, Receiver, cmd, node);
+ break;
+ case CodeGenOptions::Mixed:
+ fprintf(stderr, "Mixed\n");
+ case CodeGenOptions::NonLegacy:
+ fprintf(stderr, "NonLegacy\n");
+ if (CGM.ReturnTypeUsesFPRet(ResultType) || (Method && Method->isVariadic())) {
+ imp = LookupIMP(CGF, Receiver, cmd, node);
+ } else if (CGM.ReturnTypeUsesSRet(FnInfo)) {
+ // The actual types here don't matter - we're going to bitcast the
+ // function anyway
+ imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
+ "objc_msgSend_stret");
+ } else {
+ imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
+ "objc_msgSend");
+ }
+ }
+
+
llvm::FunctionType *impType =
Types.GetFunctionType(FnInfo, Method ? Method->isVariadic() : false);
imp = EnforceType(Builder, imp, llvm::PointerType::getUnqual(impType));
-
- // For sender-aware dispatch, we pass the sender as the third argument to a
- // lookup function. When sending messages from C code, the sender is nil.
- // objc_msg_lookup_sender(id *receiver, SEL selector, id sender);
llvm::Instruction *call;
RValue msgRet = CGF.EmitCall(FnInfo, imp, Return, ActualArgs,
0, &call);
More information about the cfe-commits
mailing list