Static Value-Flow Analysis
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
SVF::Annotator Class Reference

#include <Annotator.h>

Public Member Functions

 Annotator ()
 Constructor. More...
 
virtual ~Annotator ()
 Destructor. More...
 
bool hasSBSourceFlag (Instruction *inst) const
 SB Has flag methods. More...
 
bool hasSBSinkFlag (Instruction *inst) const
 
bool hasDRNotCheckFlag (Instruction *inst) const
 Race Detection Has flag methods. More...
 
bool hasDRNotCheckFlag (const Instruction *inst) const
 
bool hasDRCheckFlag (Instruction *inst) const
 
bool hasDRCheckFlag (const Instruction *inst) const
 
void addMDTag (Instruction *inst, std::string str)
 Simple add/remove meta data information. More...
 
void removeMDTag (Instruction *inst, std::string str)
 
void addMDTag (Instruction *inst, Value *val, std::string str)
 manipulate llvm meta data on instructions for a specific value More...
 
void removeMDTag (Instruction *inst, Value *val, std::string str)
 remove flag from llvm metadata More...
 

Protected Attributes

const char * SB_SLICESOURCE
 Saber annotations. More...
 
const char * SB_SLICESINK
 
const char * SB_FESIBLE
 
const char * SB_INFESIBLE
 
const char * DR_NOT_CHECK
 Race Detection annotations. More...
 
const char * DR_CHECK
 

Private Member Functions

bool evalMDTag (const Instruction *inst, const Value *val, std::string str, std::vector< Value * > &) const
 evaluate llvm metadata More...
 

Detailed Description

Program annotator to write meta data information on LLVM IR

Definition at line 21 of file Annotator.h.

Constructor & Destructor Documentation

◆ Annotator()

SVF::Annotator::Annotator ( )
inline

Constructor.

Definition at line 26 of file Annotator.h.

27  {
28  SB_SLICESOURCE = "SOURCE_";
29  SB_SLICESINK = "SINK_";
30  SB_FESIBLE = "FESIBLE_";
31  SB_INFESIBLE = "INFESIBLE_";
32 
33  DR_NOT_CHECK = "DRNOTCHECK_";
34  DR_CHECK = "DRCHECK_";
35  }
const char * SB_SLICESOURCE
Saber annotations.
Definition: Annotator.h:165
const char * SB_SLICESINK
Definition: Annotator.h:166
const char * SB_INFESIBLE
Definition: Annotator.h:168
const char * DR_CHECK
Definition: Annotator.h:174
const char * SB_FESIBLE
Definition: Annotator.h:167
const char * DR_NOT_CHECK
Race Detection annotations.
Definition: Annotator.h:173

◆ ~Annotator()

virtual SVF::Annotator::~Annotator ( )
inlinevirtual

Destructor.

Definition at line 38 of file Annotator.h.

39  {
40  }

Member Function Documentation

◆ addMDTag() [1/2]

void SVF::Annotator::addMDTag ( Instruction inst,
std::string  str 
)
inline

Simple add/remove meta data information.

Definition at line 90 of file Annotator.h.

91  {
92  addMDTag(inst, inst, str);
93  }
void addMDTag(Instruction *inst, std::string str)
Simple add/remove meta data information.
Definition: Annotator.h:90

◆ addMDTag() [2/2]

void SVF::Annotator::addMDTag ( Instruction inst,
Value val,
std::string  str 
)
inline

manipulate llvm meta data on instructions for a specific value

add flag to llvm metadata

Definition at line 103 of file Annotator.h.

104  {
105  assert(!val->getType()->isVoidTy() && "expecting non-void value for MD!");
106  std::vector<Value* > values;
107  //std::vector<llvm::Metadata *> metavalues;
108  // add the flag if we did not see it before
109  if (evalMDTag(inst, val, str, values) == false)
110  {
111 
112  values.push_back(val);
113  //llvm::ArrayRef<llvm::Metadata*> ar(metavalues);
114  // FIXME: delete the old MDNode
115  inst->setMetadata(str, MDNode::get(inst->getContext(), nullptr));
116  //inst->setMetadata(str, llvm::MDNode::get(inst->getContext(), ar));
117  }
118  }
bool evalMDTag(const Instruction *inst, const Value *val, std::string str, std::vector< Value * > &) const
evaluate llvm metadata
Definition: Annotator.h:139

◆ evalMDTag()

bool SVF::Annotator::evalMDTag ( const Instruction inst,
const Value val,
std::string  str,
std::vector< Value * > &   
) const
inlineprivate

evaluate llvm metadata

When mdNode has operands and value is not null

Definition at line 139 of file Annotator.h.

141  {
142 
143  assert(val && "value should not be null");
144 
145  bool hasFlag = false;
146  if (MDNode *mdNode = inst->getMetadata(str))
147  {
149  for (unsigned k = 0; k < mdNode->getNumOperands(); ++k)
150  {
151  //Value* v = mdNode->getOperand(k);
152  // if (v == val)
153  // hasFlag = true;
154  //else
155  // values.push_back(v);
156  }
157  }
158  return hasFlag;
159  }
llvm::MDNode MDNode
Definition: BasicTypes.h:112

◆ hasDRCheckFlag() [1/2]

bool SVF::Annotator::hasDRCheckFlag ( const Instruction inst) const
inline

Definition at line 80 of file Annotator.h.

81  {
82  //std::vector<Value* > values;
83  //return evalMDTag(inst, inst, DR_CHECK, values);
84  return inst->getMetadata(DR_CHECK);
85  }

◆ hasDRCheckFlag() [2/2]

bool SVF::Annotator::hasDRCheckFlag ( Instruction inst) const
inline

Definition at line 73 of file Annotator.h.

74  {
75  //std::vector<Value* > values;
76  //return evalMDTag(inst, inst, DR_CHECK, values);
77  return inst->getMetadata(DR_CHECK);
78  }

◆ hasDRNotCheckFlag() [1/2]

bool SVF::Annotator::hasDRNotCheckFlag ( const Instruction inst) const
inline

Definition at line 66 of file Annotator.h.

67  {
68  //std::vector<Value* > values;
69  //return evalMDTag(inst, inst, DR_NOT_CHECK, values);
70  return inst->getMetadata(DR_NOT_CHECK);
71  }

◆ hasDRNotCheckFlag() [2/2]

bool SVF::Annotator::hasDRNotCheckFlag ( Instruction inst) const
inline

Race Detection Has flag methods.

Definition at line 59 of file Annotator.h.

60  {
61  //std::vector<Value* > values;
62  //return evalMDTag(inst, inst, DR_NOT_CHECK, values);
63  return inst->getMetadata(DR_NOT_CHECK);
64  }

◆ hasSBSinkFlag()

bool SVF::Annotator::hasSBSinkFlag ( Instruction inst) const
inline

Definition at line 50 of file Annotator.h.

51  {
52  std::vector<Value* > values;
53  return evalMDTag(inst, inst, SB_SLICESINK, values);
54  }

◆ hasSBSourceFlag()

bool SVF::Annotator::hasSBSourceFlag ( Instruction inst) const
inline

SB Has flag methods.

Definition at line 44 of file Annotator.h.

45  {
46  std::vector<Value* > values;
47  return evalMDTag(inst, inst, SB_SLICESOURCE, values);
48  }

◆ removeMDTag() [1/2]

void SVF::Annotator::removeMDTag ( Instruction inst,
std::string  str 
)
inline

Definition at line 94 of file Annotator.h.

95  {
96  removeMDTag(inst, inst, str);
97  }
void removeMDTag(Instruction *inst, std::string str)
Definition: Annotator.h:94

◆ removeMDTag() [2/2]

void SVF::Annotator::removeMDTag ( Instruction inst,
Value val,
std::string  str 
)
inline

remove flag from llvm metadata

Definition at line 121 of file Annotator.h.

122  {
123  assert(!val->getType()->isVoidTy() && "expecting non-void value for MD!");
124  std::vector<Value* > values;
125 
126  // remove the flag if it is there
127  if (evalMDTag(inst, val, str, values) == true)
128  {
129  llvm::ArrayRef<Value* > ar(values);
130  // FIXME: delete the old MDNode
131  //inst->setMetadata(str, llvm::MDNode::get(inst->getContext(), ar));
132  }
133  }

Member Data Documentation

◆ DR_CHECK

const char* SVF::Annotator::DR_CHECK
protected

Definition at line 174 of file Annotator.h.

◆ DR_NOT_CHECK

const char* SVF::Annotator::DR_NOT_CHECK
protected

Race Detection annotations.

Definition at line 173 of file Annotator.h.

◆ SB_FESIBLE

const char* SVF::Annotator::SB_FESIBLE
protected

Definition at line 167 of file Annotator.h.

◆ SB_INFESIBLE

const char* SVF::Annotator::SB_INFESIBLE
protected

Definition at line 168 of file Annotator.h.

◆ SB_SLICESINK

const char* SVF::Annotator::SB_SLICESINK
protected

Definition at line 166 of file Annotator.h.

◆ SB_SLICESOURCE

const char* SVF::Annotator::SB_SLICESOURCE
protected

Saber annotations.

Definition at line 165 of file Annotator.h.


The documentation for this class was generated from the following file: