15 using namespace SVFUtil;
21 std::stringstream rawstr(str);
25 if (
StoreInst* st = SVFUtil::dyn_cast<StoreInst>(inst))
28 addMDTag(inst, st->getPointerOperand(), rawstr.str());
30 else if (
LoadInst* ld = SVFUtil::dyn_cast<LoadInst>(inst))
33 addMDTag(inst, ld->getPointerOperand(), rawstr.str());
42 for (Module::const_iterator
F = M.begin(), E = M.end();
F != E; ++
F)
49 if (SVFUtil::isa<LoadInst>(inst))
53 else if (SVFUtil::isa<StoreInst>(inst))
55 storeset.insert(inst);
57 else if (isMemset(inst))
59 storeset.insert(inst);
61 else if (isMemcpy(inst))
63 storeset.insert(inst);
70 numOfAllSt = storeset.size();
71 numOfAllLd = loadset.size();
76 if (
const StoreInst* st = SVFUtil::dyn_cast<StoreInst>(inst))
78 return st->getPointerOperand();
80 else if (isMemset(inst))
82 return inst->getOperand(0);
84 else if (isMemcpy(inst))
86 return inst->getOperand(0);
94 if (
const LoadInst* ld = SVFUtil::dyn_cast<LoadInst>(inst))
96 return ld->getPointerOperand();
98 else if (isMemcpy(inst))
100 return inst->getOperand(1);
113 collectLoadStoreInst(mhp->getTCT()->getPTA()->getModule());
129 for (SVFStmt::SVFStmtSetTy::const_iterator it = forkedges.begin(), eit = forkedges.end(); it != eit; ++it)
138 for (SVFIR::SVFStmtSet::const_iterator it = globaledges.begin(), eit = globaledges.end(); it != eit; ++it)
148 while (!worklist.
empty())
151 nonlocalobjs.
set(obj);
156 if (!nonlocalobjs.
test(*pit))
162 if (!nonlocalobjs.
test(*pit))
170 for (InstSet::iterator it = storeset.begin(), eit = storeset.end(); it != eit; ++it)
175 if (nonlocalobjs.
test(*pit))
177 needannost.insert(*it);
183 for (InstSet::iterator it = loadset.begin(), eit = loadset.end(); it != eit; ++it)
188 if (nonlocalobjs.
test(*pit))
190 needannold.insert(*it);
196 storeset = needannost;
197 loadset = needannold;
199 numOfNonLocalSt = storeset.size();
200 numOfNonLocalLd = loadset.size();
208 if (!AnnoMHP && !AnnoAlias)
214 for (InstSet::iterator it1 = storeset.begin(), eit1 = storeset.end(); it1 != eit1; ++it1)
217 for (InstSet::iterator it2 = it1, eit2 = storeset.end(); it2 != eit2; ++it2)
223 if(!pta->
alias(v1, v2))
228 if (mhp->mayHappenInParallel(inst1, inst2) && !lsa->isProtectedByCommonLock(inst1, inst2))
230 needannost.insert(*it1);
231 needannost.insert(*it2);
239 needannost.insert(*it1);
240 needannost.insert(*it2);
243 for (InstSet::iterator it2 = loadset.begin(), eit2 = loadset.end(); it2 != eit2; ++it2)
249 if(!pta->
alias(v1,v2))
254 if (mhp->mayHappenInParallel(inst1, inst2) && !lsa->isProtectedByCommonLock(inst1, inst2))
256 needannost.insert(*it1);
257 needannold.insert(*it2);
262 needannost.insert(*it1);
263 needannold.insert(*it2);
267 storeset = needannost;
268 loadset = needannold;
272 numOfMHPSt = storeset.size();
273 numOfMHPLd = loadset.size();
277 numOfAliasSt = storeset.size();
278 numOfAliasLd = loadset.size();
285 for (InstSet::iterator it = storeset.begin(), eit = storeset.end(); it != eit; ++it)
289 for (InstSet::iterator it = loadset.begin(), eit = loadset.end(); it != eit; ++it)
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
GEdgeKind getEdgeKind() const
NodeID getSrcID() const
get methods of the components
Set< const SVFStmt * > SVFStmtSet
NodeID getValueNode(const SVFValue *V)
static LLVMModuleSet * getLLVMModuleSet()
SVFInstruction * getSVFInstruction(const Instruction *inst) const
SVFValue * getSVFValue(const Value *value)
void pruneAliasMHP(PointerAnalysis *pta)
Prune candidate instructions that non-mhp and non-alias with others.
void initialize(MHP *mhp, LockAnalysis *lsa)
Initialize.
const Value * getLoadOperand(const Instruction *inst)
const Value * getStoreOperand(const Instruction *inst)
Get operand of store and load.
void performAnnotate()
Perform annotation.
void annotateDRCheck(Instruction *inst)
Annotation.
Set< const Instruction * > InstSet
void collectLoadStoreInst(SVFModule *mod)
Collect all load and store instruction.
void pruneThreadLocal(PointerAnalysis *pta)
Prune candidate instructions that are thread local.
static const Option< u32_t > AnnoFlag
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
bool empty() const
Returns true if set is empty.
void reset(u32_t n)
Removes n from the set.
const_iterator end() const
void set(u32_t n)
Inserts n in the set.
const_iterator begin() const
bool test(u32_t n) const
Returns true if n is in this set.
SVFStmtSet & getGlobalSVFStmtSet()
Get global PAGEdges (not in a procedure)
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
bool isExtCall(const SVFFunction *fun)
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::ostream & outs()
Overwrite llvm::outs()
llvm::const_inst_iterator const_inst_iterator
llvm::Instruction Instruction
llvm::Value Value
LLVM Basic classes.
llvm::StoreInst StoreInst