Beispiel #1
0
/////////////////////////
//dupFuncArgu()        //
/////////////////////////
void InsDuplica::dupFuncArgu(Function &F) {
   BasicBlock *firstBB = F.begin();
   Instruction *firstI = firstBB->begin();
   for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end();
         AI != E; ++AI) {
      arguSet.insert(AI);

      //if argument is used only once or all on the same block,
      //do not dup it.
      if (AI->hasOneUse()) {
         valueMap[AI] = AI;
      } else {
         //make copy of cast
         Type *arguType = AI->getType();
         //FIXME unknow signed or not
         CastInst* newCast = CastInst::CreateIntegerCast(AI, arguType, 1, AI->getName()+"_dup", firstI);
         //CastInst *newCast = new CastInst(AI, arguType, AI->getName()+"_dup", firstI);
         valueMap[AI] = newCast;
      }
   }
}