Static Value-Flow Analysis
MTAAnnotator.h
Go to the documentation of this file.
1 /*
2  * MTAAnnotator.h
3  *
4  * Created on: May 4, 2014
5  * Author: Peng Di
6  */
7 
8 #ifndef MTAANNOTATOR_H_
9 #define MTAANNOTATOR_H_
10 
11 #include "SVF-LLVM/BasicTypes.h"
12 #include "SVF-LLVM/LLVMModule.h"
13 #include "SVFIR/SVFValue.h"
14 #include "Util/Annotator.h"
15 #include "MTA/MHP.h"
16 
17 namespace SVF
18 {
19 
23 class MTAAnnotator: public Annotator
24 {
25 
26 public:
29  MTAAnnotator(): mhp(nullptr),lsa(nullptr)
30  {
31  numOfAllSt = 0;
32  numOfAllLd = 0;
33  numOfNonLocalSt = 0;
34  numOfNonLocalLd = 0;
35  numOfAliasSt = 0;
36  numOfAliasLd = 0;
37  numOfMHPSt = 0;
38  numOfMHPLd = 0;
39  numOfAnnotatedSt = 0;
40  numOfAnnotatedLd = 0;
41  }
43  virtual ~MTAAnnotator()
44  {
45 
46  }
48 
49  void annotateDRCheck(Instruction* inst);
51 
54 
57 
59  void pruneAliasMHP(PointerAnalysis* pta);
60 
62  void performAnnotate();
63 
66 
68  const Value* getStoreOperand(const Instruction* inst);
69  const Value* getLoadOperand(const Instruction* inst);
70 
71 
73  inline bool isMemset(const Instruction* I)
74  {
76  const SVFFunction* F =SVFUtil::getCallee(svfInst);
77  return F && F->getName().find("llvm.memset") != std::string::npos;
78  }
79 
81  inline bool isMemcpy(const Instruction* I)
82  {
84  const SVFFunction* F = SVFUtil::getCallee(svfInst);
85  return F && F->getName().find("llvm.memcpy") != std::string::npos;
86  }
87 
88 private:
89  MHP* mhp;
93 
94 
95 // RCMemoryPartitioning mp;
96 
97 public:
98 
109 
111 
112  static const u32_t ANNO_MHP= 0x04;
113  static const u32_t ANNO_ALIAS= 0x02;
114  static const u32_t ANNO_LOCAL= 0x01;
116 };
117 
118 } // End namespace SVF
119 
120 #endif /* MTAANNOTATOR_H_ */
#define F(f)
static LLVMModuleSet * getLLVMModuleSet()
Definition: LLVMModule.h:105
SVFInstruction * getSVFInstruction(const Instruction *inst) const
Definition: LLVMModule.h:224
Definition: MHP.h:46
void pruneAliasMHP(PointerAnalysis *pta)
Prune candidate instructions that non-mhp and non-alias with others.
void initialize(MHP *mhp, LockAnalysis *lsa)
Initialize.
virtual ~MTAAnnotator()
Destructor.
Definition: MTAAnnotator.h:43
static const u32_t ANNO_ALIAS
Definition: MTAAnnotator.h:113
bool isMemset(const Instruction *I)
Check if Function "F" is memset.
Definition: MTAAnnotator.h:73
MTAAnnotator()
Constructor.
Definition: MTAAnnotator.h:29
const Value * getLoadOperand(const Instruction *inst)
LockAnalysis * lsa
Definition: MTAAnnotator.h:90
const Value * getStoreOperand(const Instruction *inst)
Get operand of store and load.
static const u32_t ANNO_MHP
Constant INTERLEV_FLAG values.
Definition: MTAAnnotator.h:112
void performAnnotate()
Perform annotation.
void annotateDRCheck(Instruction *inst)
Annotation.
Set< const Instruction * > InstSet
Definition: MTAAnnotator.h:27
void collectLoadStoreInst(SVFModule *mod)
Collect all load and store instruction.
static const u32_t ANNO_LOCAL
Definition: MTAAnnotator.h:114
bool isMemcpy(const Instruction *I)
Check if Function "F" is memcpy.
Definition: MTAAnnotator.h:81
void pruneThreadLocal(PointerAnalysis *pta)
Prune candidate instructions that are thread local.
const SVFFunction * getCallee(const CallSite cs)
Return callee of a callsite. Return null if this is an indirect call.
Definition: SVFUtil.h:241
for isBitcode
Definition: BasicTypes.h:68
llvm::Instruction Instruction
Definition: BasicTypes.h:87
llvm::Value Value
LLVM Basic classes.
Definition: BasicTypes.h:82
unsigned u32_t
Definition: GeneralType.h:46
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96