From 6cfec78e48498a0f61196c033295ec5cba753857 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Jun 2008 04:42:20 +0000 Subject: [PATCH] avoid a lot of unneeded selector processing work by passing around selectors instead of Value*'s. llvm-svn: 52760 --- clang/lib/CodeGen/CGExprScalar.cpp | 7 +------ clang/lib/CodeGen/CGObjC.cpp | 11 +++-------- clang/lib/CodeGen/CGObjCGNU.cpp | 10 +++++----- clang/lib/CodeGen/CGObjCRuntime.h | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 47bbd8827d48..ce49cb20d356 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -490,14 +490,9 @@ Value *ScalarExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) { } } - // Get the selector string - std::string SelStr = E->getSelector().getName(); - llvm::Constant *Selector = CGF.CGM.GetAddrOfConstantString(SelStr); - - llvm::Value *SelPtr = Builder.CreateStructGEP(Selector, 0); return Runtime->GenerateMessageSend(Builder, ConvertType(E->getType()), CGF.LoadObjCSelf(), - Receiver, SelPtr, + Receiver, E->getSelector(), &Args[0], Args.size()); } diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index e9d20640b782..9bf53d9700d8 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -86,14 +86,9 @@ llvm::Value *CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) { } } - // Get the selector string - std::string SelStr = E->getSelector().getName(); - llvm::Constant *Selector = CGM.GetAddrOfConstantString(SelStr); - - llvm::Value *SelPtr = Builder.CreateStructGEP(Selector, 0); if (isSuperMessage) { - const ObjCMethodDecl *OMD = dyn_cast(CurFuncDecl); - assert(OMD && "super is only valid in an Objective-C method"); + // super is only valid in an Objective-C method + const ObjCMethodDecl *OMD = cast(CurFuncDecl); const char *SuperClass = OMD->getClassInterface()->getSuperClass()->getName(); return Runtime->GenerateMessageSendSuper(Builder, ConvertType(E->getType()), @@ -103,7 +98,7 @@ llvm::Value *CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) { } return Runtime->GenerateMessageSend(Builder, ConvertType(E->getType()), LoadObjCSelf(), - Receiver, SelPtr, + Receiver, E->getSelector(), &Args[0], Args.size()); } diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 565167dc6f54..5fe182019f4d 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -105,7 +105,7 @@ public: const llvm::Type *ReturnTy, llvm::Value *Sender, llvm::Value *Receiver, - llvm::Value *Selector, + Selector Sel, llvm::Value** ArgV, unsigned ArgC); virtual llvm::Value *GenerateMessageSendSuper(llvm::IRBuilder &Builder, @@ -116,8 +116,8 @@ public: Selector Sel, llvm::Value** ArgV, unsigned ArgC); - virtual llvm::Value *LookupClass(llvm::IRBuilder &Builder, llvm::Value - *ClassName); + virtual llvm::Value *LookupClass(llvm::IRBuilder &Builder, + llvm::Value *ClassName); virtual llvm::Value *GetSelector(llvm::IRBuilder &Builder, Selector Sel); virtual llvm::Value *GetSelector(llvm::IRBuilder &Builder, llvm::Value *SelName, @@ -385,10 +385,10 @@ llvm::Value *CGObjCGNU::GenerateMessageSend(llvm::IRBuilder &Builder, const llvm::Type *ReturnTy, llvm::Value *Sender, llvm::Value *Receiver, - llvm::Value *Selector, + Selector Sel, llvm::Value** ArgV, unsigned ArgC) { - llvm::Value *cmd = GetSelector(Builder, Selector, 0); + llvm::Value *cmd = GetSelector(Builder, Sel); // Look up the method implementation. std::vector impArgTypes; diff --git a/clang/lib/CodeGen/CGObjCRuntime.h b/clang/lib/CodeGen/CGObjCRuntime.h index 07d89620965d..f9b029736dee 100644 --- a/clang/lib/CodeGen/CGObjCRuntime.h +++ b/clang/lib/CodeGen/CGObjCRuntime.h @@ -46,7 +46,7 @@ public: const llvm::Type *ReturnTy, llvm::Value *Sender, llvm::Value *Receiver, - llvm::Value *Selector, + Selector Sel, llvm::Value** ArgV, unsigned ArgC) =0; /// Generate the function required to register all Objective-C components in -- GitLab