diff --git a/opts/ClassLookupCache.cpp b/opts/ClassLookupCache.cpp index dde9ffb..b5d4fce 100644 --- a/opts/ClassLookupCache.cpp +++ b/opts/ClassLookupCache.cpp @@ -49,7 +49,7 @@ namespace for (BasicBlock::iterator b=i->begin(), last=i->end() ; b != last ; ++b) { if (CallInst *call = dyn_cast(b)) { - if (Function *func = call->getCalledFunction()) { + if (Function *func = dyn_cast(call->getCalledValue()->stripPointerCasts())) { if (func->getName() == "objc_lookup_class") { ClassLookup lookup; GlobalVariable *classNameVar = dyn_cast( @@ -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) {