bool LLPE::searchForStoreInstruction(BasicBlock *BB, vector<int> argv) { bool GEPIFlag = false; //Iterate through each instruction in the basic block //Search for GEPI. The next store after a GEPI, indicates the location for inserting a new alloca instruction. for(BasicBlock::iterator BI = BB->begin(), BI_end = BB->end(); BI != BI_end; ++BI) { if ( isa<GetElementPtrInst>(BI) ) { GEPIFlag = true; } if (GEPIFlag) { if ( StoreInst *SI = dyn_cast<StoreInst>(BI)) { AllocaInst *constAlloca = dyn_cast<AllocaInst>(SI->getOperand(1)); constAlloca->print(errs()); StoreInst *constSI = new StoreInst(ConstantInt::get(Type::getInt32Ty(SI->getContext()), argv.at(0)), constAlloca, SI); SI->eraseFromParent(); return true; } } } //End BasicBlock loop return false; }