예제 #1
0
  ProgramStructure::ProgramStructure(Module &M) {
    for (Module::iterator f = M.begin(); f != M.end(); ++f)
      if (!f->isDeclaration() && !memoryManStuff(&*f))
        for (inst_iterator i = inst_begin(*f); i != inst_end(*f); ++i)
          if (const StoreInst *s = dyn_cast<StoreInst>(&*i)) {
            const Value *l = elimConstExpr(s->getPointerOperand());
	    this->getContainer()[&*f].push_back(ProgramStructure::Command(
		  hasExtraReference(l) ? CMD_VAR : CMD_DREF_VAR, l));
          }
  }
예제 #2
0
 const Value *elimConstExpr(const Value *V) {
   if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
     if (Instruction::isBinaryOp(CE->getOpcode()))
       return V;
     assert((CE->getOpcode() == llvm::Instruction::GetElementPtr ||
             CE->isCast()) &&
       "Only GEP or CAST const expressions are supported for now.");
     return elimConstExpr(CE->getOperand(0));
   }
   return V;
 }