Пример #1
0
RuleCode argPassRuleCode(Value const* const l,
			 Value const* const r)
{
    if (isa<ConstantPointerNull const>(r))
	return ruleCode(ruleVar(l) = ruleNull(r));
    if (hasExtraReference(l))
	if (hasExtraReference(r))
	    return ruleCode(ruleVar(l) = ruleVar(r));
	else
	    return ruleCode(ruleVar(l) = *ruleVar(r));
    else
	if (hasExtraReference(r))
	    return ruleCode(ruleVar(l) = &ruleVar(r));
	else
	    return ruleCode(ruleVar(l) = ruleVar(r));
}
Пример #2
0
 llvm::Type const* getPointedType(llvm::Value const* const V)
 {
     const Type *t = getPointedType(V->getType());
     if (hasExtraReference(V))
         t = getPointedType(t);
     return t;
 }
Пример #3
0
 bool isPointerValue(llvm::Value const* const V)
 {
     if (!V->getType()->isPointerTy())
         return false;
     if (!hasExtraReference(V))
         return true;
     return llvm::dyn_cast<llvm::PointerType const>(V->getType())
                 ->getElementType()->isPointerTy();
 }
Пример #4
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));
          }
  }
Пример #5
0
 bool isGlobalPointerInitialization(llvm::GlobalVariable const* const G)
 {
     if (G->isDeclaration())
         return false;
     llvm::Value const* const op = G->getOperand(0);
     return op->getType()->isPointerTy() && (
                 hasExtraReference(op) ||
                 llvm::dyn_cast<llvm::PointerType const>(op->getType())
                         ->getElementType()->isFunctionTy()
                 );
 }
Пример #6
0
void buildCallMaps(Module const& M, FunctionsMap& F,
		CallsMap& C) {
    for (Module::const_iterator f = M.begin(); f != M.end(); ++f) {
	if (!f->isDeclaration())
	    F.insert(std::make_pair(f->getFunctionType(), &*f));
	for (Function::const_iterator b = f->begin(); b != f->end(); ++b) {
	    for (BasicBlock::const_iterator i = b->begin(); i != b->end(); ++i)
		if (const CallInst *CI = dyn_cast<CallInst>(&*i)) {
		    if (!isInlineAssembly(CI) && !callToMemoryManStuff(CI))
			C.insert(std::make_pair(getCalleePrototype(CI), CI));
		} else if (const StoreInst *SI = dyn_cast<StoreInst>(&*i)) {
		    const Value *r = SI->getValueOperand();
		    if (hasExtraReference(r) && memoryManStuff(r)) {
			const Function *fn = dyn_cast<Function>(r);
			F.insert(std::make_pair(fn->getFunctionType(), fn));
		    }
		}
	}
    }
}