summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-26 04:24:57 +0000
committerChris Lattner <sabre@nondot.org>2008-06-26 04:24:57 +0000
commit42587147d41fe5c2446ba95ca9a72637937f170b (patch)
tree2e30c739dc6a86b3bdb2f993f5d6361542c2befe /clang/lib
parent87ab27d42fd78139031bcc873537a8608408c7fe (diff)
downloadbcm5719-llvm-42587147d41fe5c2446ba95ca9a72637937f170b.tar.gz
bcm5719-llvm-42587147d41fe5c2446ba95ca9a72637937f170b.zip
improve indentation, avoid thrashing on maps and recalculating strings as much.
llvm-svn: 52757
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp53
-rw-r--r--clang/lib/CodeGen/CGObjCRuntime.h4
2 files changed, 24 insertions, 33 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 7d9a6aa21ea..2b8f7edc051 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -222,62 +222,53 @@ llvm::Value *CGObjCGNU::LookupClass(llvm::IRBuilder &Builder,
/// 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,
- llvm::Value *SelName,
- llvm::Value *SelTypes) {
+ llvm::Value *SelName,
+ llvm::Value *SelTypes) {
// For static selectors, we return an alias for now then store them all in a
// list that the runtime will initialise later.
if (llvm::Constant *CName = dyn_cast<llvm::Constant>(SelName)) {
// Untyped selector
if (SelTypes == 0) {
// If it's already cached, return it.
- if (UntypedSelectors[getStringValue(CName)]) {
- // FIXME: Volatility
- return Builder.CreateLoad(UntypedSelectors[getStringValue(CName)]);
+ llvm::GlobalAlias *&US = UntypedSelectors[getStringValue(CName)];
+ if (US == 0) {
+ // If it isn't, cache it.
+ US = new llvm::GlobalAlias(llvm::PointerType::getUnqual(SelectorTy),
+ llvm::GlobalValue::InternalLinkage,
+ ".objc_untyped_selector_alias",
+ NULL, &TheModule);
}
- // If it isn't, cache it.
- llvm::GlobalAlias *Sel = new llvm::GlobalAlias(
- llvm::PointerType::getUnqual(SelectorTy),
- llvm::GlobalValue::InternalLinkage, ".objc_untyped_selector_alias",
- NULL, &TheModule);
- UntypedSelectors[getStringValue(CName)] = Sel;
- // FIXME: Volatility
- return Builder.CreateLoad(Sel);
+ return Builder.CreateLoad(US);
}
// Typed selectors
if (llvm::Constant *CTypes = dyn_cast<llvm::Constant>(SelTypes)) {
TypedSelector Selector = TypedSelector(getStringValue(CName),
getStringValue(CTypes));
// If it's already cached, return it.
- if (TypedSelectors[Selector]) {
- // FIXME: Volatility
- return Builder.CreateLoad(TypedSelectors[Selector]);
+ llvm::GlobalAlias *&TS = TypedSelectors[Selector];
+ if (TS == 0) {
+ // If it isn't, cache it.
+ TS = new llvm::GlobalAlias(llvm::PointerType::getUnqual(SelectorTy),
+ llvm::GlobalValue::InternalLinkage,
+ ".objc_typed_selector_alias",
+ NULL, &TheModule);
}
- // If it isn't, cache it.
- llvm::GlobalAlias *Sel = new llvm::GlobalAlias(
- llvm::PointerType::getUnqual(SelectorTy),
- llvm::GlobalValue::InternalLinkage, ".objc_typed_selector_alias",
- NULL, &TheModule);
- TypedSelectors[Selector] = Sel;
- // FIXME: Volatility
- return Builder.CreateLoad(Sel);
+ return Builder.CreateLoad(TS);
}
}
// Dynamically look up selectors from non-constant sources
llvm::Value *cmd;
if (SelTypes == 0) {
llvm::Constant *SelFunction = TheModule.getOrInsertFunction("sel_get_uid",
- SelectorTy,
- PtrToInt8Ty,
- NULL);
+ SelectorTy,
+ PtrToInt8Ty,
+ NULL);
cmd = Builder.CreateCall(SelFunction, SelName);
}
else {
llvm::Constant *SelFunction =
TheModule.getOrInsertFunction("sel_get_typed_uid",
- SelectorTy,
- PtrToInt8Ty,
- PtrToInt8Ty,
- NULL);
+ SelectorTy, PtrToInt8Ty, PtrToInt8Ty, NULL);
cmd = Builder.CreateCall2(SelFunction, SelName, SelTypes);
}
return cmd;
diff --git a/clang/lib/CodeGen/CGObjCRuntime.h b/clang/lib/CodeGen/CGObjCRuntime.h
index 53753695fc7..cc33982e475 100644
--- a/clang/lib/CodeGen/CGObjCRuntime.h
+++ b/clang/lib/CodeGen/CGObjCRuntime.h
@@ -52,8 +52,8 @@ public:
virtual llvm::Function *ModuleInitFunction() =0;
/// Get a selector for the specified name and type values
virtual llvm::Value *GetSelector(llvm::IRBuilder &Builder,
- llvm::Value *SelName,
- llvm::Value *SelTypes) =0;
+ llvm::Value *SelName,
+ llvm::Value *SelTypes) = 0;
/// Generate a constant string object
virtual llvm::Constant *GenerateConstantString(const char *String, const size_t
length) =0;
OpenPOWER on IntegriCloud