[cfe-commits] r52758 - in /cfe/trunk/lib/CodeGen: CGObjC.cpp CGObjCGNU.cpp CGObjCRuntime.h
Chris Lattner
sabre at nondot.org
Wed Jun 25 21:37:12 PDT 2008
Author: lattner
Date: Wed Jun 25 23:37:12 2008
New Revision: 52758
URL: http://llvm.org/viewvc/llvm-project?rev=52758&view=rev
Log:
start avoid doing lots of unneeded work handling selectors
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=52758&r1=52757&r2=52758&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Jun 25 23:37:12 2008
@@ -99,7 +99,7 @@
OMD->getClassInterface()->getSuperClass()->getName();
return Runtime->GenerateMessageSendSuper(Builder, ConvertType(E->getType()),
Receiver, SuperClass,
- Receiver, SelPtr,
+ Receiver, E->getSelector(),
&Args[0], Args.size());
}
return Runtime->GenerateMessageSend(Builder, ConvertType(E->getType()),
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=52758&r1=52757&r2=52758&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Jun 25 23:37:12 2008
@@ -109,18 +109,20 @@
llvm::Value** ArgV,
unsigned ArgC);
virtual llvm::Value *GenerateMessageSendSuper(llvm::IRBuilder &Builder,
- const llvm::Type *ReturnTy,
- llvm::Value *Sender,
- const char *SuperClassName,
- llvm::Value *Receiver,
- llvm::Value *Selector,
- llvm::Value** ArgV,
- unsigned ArgC);
+ const llvm::Type *ReturnTy,
+ llvm::Value *Sender,
+ const char *SuperClassName,
+ llvm::Value *Receiver,
+ Selector Sel,
+ llvm::Value** ArgV,
+ unsigned ArgC);
virtual llvm::Value *LookupClass(llvm::IRBuilder &Builder, llvm::Value
*ClassName);
virtual llvm::Value *GetSelector(llvm::IRBuilder &Builder,
- llvm::Value *SelName,
- llvm::Value *SelTypes);
+ llvm::Value *SelName,
+ llvm::Value *SelTypes);
+ llvm::Value *GetSelector(llvm::IRBuilder &Builder, Selector Sel);
+
virtual llvm::Function *MethodPreamble(
const std::string &ClassName,
const std::string &CategoryName,
@@ -219,6 +221,20 @@
return Builder.CreateCall(ClassLookupFn, ClassName);
}
+/// GetSelector - Return the pointer to the unique'd string for this selector.
+llvm::Value *CGObjCGNU::GetSelector(llvm::IRBuilder &Builder, Selector Sel) {
+ // FIXME: uniquing on the string is wasteful, unique on Sel instead!
+ llvm::GlobalAlias *&US = UntypedSelectors[Sel.getName()];
+ if (US == 0)
+ US = new llvm::GlobalAlias(llvm::PointerType::getUnqual(SelectorTy),
+ llvm::GlobalValue::InternalLinkage,
+ ".objc_untyped_selector_alias",
+ NULL, &TheModule);
+
+ return Builder.CreateLoad(US);
+
+}
+
/// Looks up the selector for the specified name / type pair.
// FIXME: Selectors should be statically cached, not looked up on every call.
llvm::Value *CGObjCGNU::GetSelector(llvm::IRBuilder &Builder,
@@ -319,17 +335,17 @@
///send to self with special delivery semantics indicating which class's method
///should be called.
llvm::Value *CGObjCGNU::GenerateMessageSendSuper(llvm::IRBuilder &Builder,
- const llvm::Type *ReturnTy,
- llvm::Value *Sender,
- const char *SuperClassName,
- llvm::Value *Receiver,
- llvm::Value *Selector,
- llvm::Value** ArgV,
- unsigned ArgC) {
+ const llvm::Type *ReturnTy,
+ llvm::Value *Sender,
+ const char *SuperClassName,
+ llvm::Value *Receiver,
+ Selector Sel,
+ llvm::Value** ArgV,
+ unsigned ArgC) {
// TODO: This should be cached, not looked up every time.
llvm::Value *ReceiverClass = LookupClass(Builder,
MakeConstantString(SuperClassName));
- llvm::Value *cmd = GetSelector(Builder, Selector, 0);
+ llvm::Value *cmd = GetSelector(Builder, Sel);
std::vector<const llvm::Type*> impArgTypes;
impArgTypes.push_back(Receiver->getType());
impArgTypes.push_back(SelectorTy);
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=52758&r1=52757&r2=52758&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Wed Jun 25 23:37:12 2008
@@ -28,6 +28,8 @@
}
namespace clang {
+ class Selector;
+
namespace CodeGen {
class CodeGenModule;
@@ -82,13 +84,13 @@
virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder &Builder, const char
*ProtocolName) =0;
virtual llvm::Value *GenerateMessageSendSuper(llvm::IRBuilder &Builder,
- const llvm::Type *ReturnTy,
- llvm::Value *Sender,
- const char *SuperClassName,
- llvm::Value *Receiver,
- llvm::Value *Selector,
- llvm::Value** ArgV,
- unsigned ArgC) {return NULL;};
+ const llvm::Type *ReturnTy,
+ llvm::Value *Sender,
+ const char *SuperClassName,
+ llvm::Value *Receiver,
+ Selector Sel,
+ llvm::Value** ArgV,
+ unsigned ArgC) = 0;
/// Generate the named protocol. Protocols contain method metadata but no
/// implementations.
virtual void GenerateProtocol(const char *ProtocolName,
More information about the cfe-commits
mailing list