Small improvements to class lookup cache pass.

main
theraven 14 years ago
parent 31149afd20
commit 3b5e00b995

@ -49,7 +49,7 @@ namespace
for (BasicBlock::iterator b=i->begin(), last=i->end() ;
b != last ; ++b) {
if (CallInst *call = dyn_cast<CallInst>(b)) {
if (Function *func = call->getCalledFunction()) {
if (Function *func = dyn_cast<Function>(call->getCalledValue()->stripPointerCasts())) {
if (func->getName() == "objc_lookup_class") {
ClassLookup lookup;
GlobalVariable *classNameVar = dyn_cast<GlobalVariable>(
@ -78,7 +78,6 @@ namespace
std::string &cls = i->second;
LLVMType *clsTy = lookup->getType();
Value *global = M->getGlobalVariable(("_OBJC_CLASS_" + i->second).c_str(), true);
global = 0;
// If we can see the class reference for this, then reference it
// directly. If not, then do the lookup and cache it.
if (global) {
@ -87,6 +86,7 @@ namespace
Value *cls = new BitCastInst(global, clsTy, "class", lookup);
lookup->replaceAllUsesWith(cls);
lookup->removeFromParent();
delete lookup;
} else {
GlobalVariable *cache = statics[cls];
if (!cache) {

Loading…
Cancel
Save