diff options
author | John McCall <rjmccall@apple.com> | 2012-08-21 02:47:43 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-08-21 02:47:43 +0000 |
commit | 0a7dd788dbef975f35f273c7ab913f480f7edd60 (patch) | |
tree | 4ff726c6ed21d7c822a307b124bf4fec48ffc89a /lib/CodeGen | |
parent | eb8f2efb17c74620510a38cb437e792ea9c76021 (diff) |
Screw around with ObjCRuntime some more, changing the
diagnostics for bad deployment targets and adding a few
more predicates. Includes a patch by Jonathan Schleifer
to enable ARC for ObjFW.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 47 |
2 files changed, 43 insertions, 8 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index e0762846dc..4a8a07994a 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -1706,7 +1706,7 @@ static llvm::Constant *createARCRuntimeFunction(CodeGenModule &CGM, // references to the runtime support library. We don't really // permit this to fail, but we need a particular relocation style. if (llvm::Function *f = dyn_cast<llvm::Function>(fn)) { - if (!CGM.getLangOpts().ObjCRuntime.hasARC()) + if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC()) f->setLinkage(llvm::Function::ExternalWeakLinkage); // set nonlazybind attribute for these APIs for performance. if (fnName == "objc_retain" || fnName == "objc_release") @@ -2739,7 +2739,7 @@ void CodeGenFunction::EmitObjCAutoreleasePoolStmt( // Keep track of the current cleanup stack depth. RunCleanupsScope Scope(*this); - if (CGM.getLangOpts().ObjCRuntime.hasARC()) { + if (CGM.getLangOpts().ObjCRuntime.hasNativeARC()) { llvm::Value *token = EmitObjCAutoreleasePoolPush(); EHStack.pushCleanup<CallObjCAutoreleasePoolObject>(NormalCleanup, token); } else { diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 6d129d02a5..f1c5f19ffa 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -653,11 +653,40 @@ class CGObjCGNUstep : public CGObjCGNU { } }; -/// The ObjFW runtime, which closely follows the GCC runtime's -/// compiler ABI. Support here is due to Jonathan Schleifer, the -/// ObjFW maintainer. -class CGObjCObjFW : public CGObjCGCC { - /// Emit class references unconditionally as direct symbol references. +/// Support for the ObjFW runtime. Support here is due to +/// Jonathan Schleifer <js@webkeks.org>, the ObjFW maintainer. +class CGObjCObjFW: public CGObjCGNU { +protected: + /// The GCC ABI message lookup function. Returns an IMP pointing to the + /// method implementation for this message. + LazyRuntimeFunction MsgLookupFn; + /// The GCC ABI superclass message lookup function. Takes a pointer to a + /// structure describing the receiver and the class, and a selector as + /// arguments. Returns the IMP for the corresponding method. + LazyRuntimeFunction MsgLookupSuperFn; + + virtual llvm::Value *LookupIMP(CodeGenFunction &CGF, + llvm::Value *&Receiver, + llvm::Value *cmd, + llvm::MDNode *node) { + CGBuilderTy &Builder = CGF.Builder; + llvm::Value *args[] = { + EnforceType(Builder, Receiver, IdTy), + EnforceType(Builder, cmd, SelectorTy) }; + llvm::CallSite imp = CGF.EmitCallOrInvoke(MsgLookupFn, args); + imp->setMetadata(msgSendMDKind, node); + return imp.getInstruction(); + } + + virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF, + llvm::Value *ObjCSuper, + llvm::Value *cmd) { + CGBuilderTy &Builder = CGF.Builder; + llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper, + PtrToObjCSuperTy), cmd}; + return Builder.CreateCall(MsgLookupSuperFn, lookupArgs); + } + virtual llvm::Value *GetClassNamed(CGBuilderTy &Builder, const std::string &Name, bool isWeak) { if (isWeak) @@ -678,7 +707,13 @@ class CGObjCObjFW : public CGObjCGCC { } public: - CGObjCObjFW(CodeGenModule &Mod): CGObjCGCC(Mod) {} + CGObjCObjFW(CodeGenModule &Mod): CGObjCGNU(Mod, 9, 3) { + // IMP objc_msg_lookup(id, SEL); + MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, NULL); + // IMP objc_msg_lookup_super(struct objc_super*, SEL); + MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy, + PtrToObjCSuperTy, SelectorTy, NULL); + } }; } // end anonymous namespace |