From f2caea7f28b7d50369252862f88199c235edeb05 Mon Sep 17 00:00:00 2001 From: theraven Date: Sat, 19 Nov 2011 11:19:25 +0000 Subject: [PATCH] It turns out that allocating one word on stack every loop iteration doesn't scale very well. It also turns out that if you test the cache every loop iteration but never write to it that this doesn't really make things any faster... --- opts/IMPCacher.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opts/IMPCacher.cpp b/opts/IMPCacher.cpp index c3bb0d1..b6b5f49 100644 --- a/opts/IMPCacher.cpp +++ b/opts/IMPCacher.cpp @@ -139,7 +139,7 @@ void GNUstep::IMPCacher::CacheLookup(Instruction *lookup, Value *slot, Value // version is not 0 at the start and an occasional redundant store is // probably better than a branch every time. B.CreateStore(lookup, slot); - //B.CreateStore(B.CreateLoad(B.CreateStructGEP(lookup, 3)), version); + B.CreateStore(B.CreateLoad(B.CreateStructGEP(lookup, 3)), version); cls = B.CreateLoad(B.CreateBitCast(receiver, IdTy)); B.CreateStore(cls, B.CreateStructGEP(lookup, 1)); B.CreateBr(afterLookupBB); @@ -232,7 +232,8 @@ void GNUstep::IMPCacher::SpeculativelyInline(Instruction *call, Function CallSite GNUstep::IMPCacher::SplitSend(CallSite msgSend) { BasicBlock *lookupBB = msgSend->getParent(); - Module *M = lookupBB->getParent()->getParent(); + Function *F = lookupBB->getParent(); + Module *M = F->getParent(); Function *send = M->getFunction("objc_msgSend"); Function *send_stret = M->getFunction("objc_msgSend_stret"); Function *send_fpret = M->getFunction("objc_msgSend_fpret"); @@ -251,8 +252,9 @@ CallSite GNUstep::IMPCacher::SplitSend(CallSite msgSend) abort(); return CallSite(); } - CGBuilder B(msgSend.getInstruction()); + CGBuilder B(&F->getEntryBlock(), F->getEntryBlock().begin()); Value *selfPtr = B.CreateAlloca(self->getType()); + B.SetInsertPoint(msgSend.getInstruction()); B.CreateStore(self, selfPtr, true); LLVMType *impTy = msgSend.getCalledValue()->getType(); LLVMType *slotTy = PointerType::getUnqual(StructType::get(PtrTy, PtrTy, PtrTy,