SVF
Public Member Functions | Private Attributes | List of all members
SVF::SaberAnnotator Class Reference

#include <SaberAnnotator.h>

Inheritance diagram for SVF::SaberAnnotator:
SVF::Annotator

Public Member Functions

 SaberAnnotator (ProgSlice *slice)
 Constructor. More...
 
virtual ~SaberAnnotator ()
 Destructor. More...
 
void annotateSource ()
 Annotation. More...
 
void annotateSinks ()
 
void annotateFeasibleBranch (const BranchInst *brInst, u32_t succPos)
 
void annotateInfeasibleBranch (const BranchInst *brInst, u32_t succPos)
 
void annotateSwitch (SwitchInst *brInst, u32_t succPos)
 
- Public Member Functions inherited from SVF::Annotator
 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...
 

Private Attributes

const ProgSlice_curSlice
 

Additional Inherited Members

- Protected Attributes inherited from SVF::Annotator
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
 

Detailed Description

Saber annotation

Definition at line 43 of file SaberAnnotator.h.

Constructor & Destructor Documentation

◆ SaberAnnotator()

SVF::SaberAnnotator::SaberAnnotator ( ProgSlice slice)
inline

Constructor.

Definition at line 50 of file SaberAnnotator.h.

50  : _curSlice(slice)
51  {
52 
53  }
const ProgSlice * _curSlice

◆ ~SaberAnnotator()

virtual SVF::SaberAnnotator::~SaberAnnotator ( )
inlinevirtual

Destructor.

Definition at line 55 of file SaberAnnotator.h.

56  {
57 
58  }

Member Function Documentation

◆ annotateFeasibleBranch()

void SaberAnnotator::annotateFeasibleBranch ( const BranchInst brInst,
u32_t  succPos 
)

Annotate branch instruction and its corresponding feasible path

Definition at line 78 of file SaberAnnotator.cpp.

79 {
80 
81  assert((succPos == 0 || succPos == 1) && "branch instruction should only have two successors");
82 
83  std::string str;
84  raw_string_ostream rawstr(str);
85  rawstr << SB_FESIBLE << _curSlice->getSource()->getId();
86  BranchInst* br = const_cast<BranchInst*>(brInst);
87  addMDTag(br,br->getCondition(),rawstr.str());
88 }
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:112
llvm::BranchInst BranchInst
Definition: BasicTypes.h:157
const char * SB_FESIBLE
Definition: Annotator.h:176
#define assert(ex)
Definition: util.h:141
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
const ProgSlice * _curSlice
void addMDTag(Instruction *inst, std::string str)
Simple add/remove meta data information.
Definition: Annotator.h:99
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164

◆ annotateInfeasibleBranch()

void SaberAnnotator::annotateInfeasibleBranch ( const BranchInst brInst,
u32_t  succPos 
)

Annotate branch instruction and its corresponding infeasible path

Definition at line 93 of file SaberAnnotator.cpp.

94 {
95 
96  assert((succPos == 0 || succPos == 1) && "branch instruction should only have two successors");
97 
98  std::string str;
99  raw_string_ostream rawstr(str);
100  rawstr << SB_INFESIBLE << _curSlice->getSource()->getId();
101  BranchInst* br = const_cast<BranchInst*>(brInst);
102  addMDTag(br,br->getCondition(),rawstr.str());
103 }
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:112
llvm::BranchInst BranchInst
Definition: BasicTypes.h:157
#define assert(ex)
Definition: util.h:141
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
const char * SB_INFESIBLE
Definition: Annotator.h:177
const ProgSlice * _curSlice
void addMDTag(Instruction *inst, std::string str)
Simple add/remove meta data information.
Definition: Annotator.h:99
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164

◆ annotateSinks()

void SaberAnnotator::annotateSinks ( )

Definition at line 55 of file SaberAnnotator.cpp.

56 {
57  for(ProgSlice::SVFGNodeSet::const_iterator it = _curSlice->getSinks().begin(),
58  eit = _curSlice->getSinks().end(); it!=eit; ++it)
59  {
60  if(const ActualParmSVFGNode* ap = SVFUtil::dyn_cast<ActualParmSVFGNode>(*it))
61  {
62  const Instruction* sinkinst = ap->getCallSite()->getCallSite();
63  assert(SVFUtil::isa<CallInst>(sinkinst) && "not a call instruction?");
64  const CallInst* sink = SVFUtil::cast<CallInst>(sinkinst);
65  std::string str;
66  raw_string_ostream rawstr(str);
67  rawstr << SB_SLICESINK << _curSlice->getSource()->getId();
68  addMDTag(const_cast<CallInst*>(sink),sink->getArgOperand(0),rawstr.str());
69  }
70  else
71  assert(false && "sink node is not a actual parameter?");
72  }
73 }
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:112
#define assert(ex)
Definition: util.h:141
llvm::CallInst CallInst
Definition: BasicTypes.h:143
llvm::Instruction Instruction
Definition: BasicTypes.h:79
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
const ProgSlice * _curSlice
void addMDTag(Instruction *inst, std::string str)
Simple add/remove meta data information.
Definition: Annotator.h:99
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164
const char * SB_SLICESINK
Definition: Annotator.h:175
const SVFGNodeSet & getSinks() const
Definition: ProgSlice.h:120

◆ annotateSource()

void SaberAnnotator::annotateSource ( )

Annotation.

Definition at line 38 of file SaberAnnotator.cpp.

39 {
40  std::string str;
41  raw_string_ostream rawstr(str);
42  rawstr << SB_SLICESOURCE ; //<< _curSlice->getSource()->getId();
43  if(const Instruction* sourceinst = SVFUtil::dyn_cast<Instruction>(_curSlice->getLLVMValue(_curSlice->getSource())))
44  {
45  addMDTag(const_cast<Instruction*>(sourceinst),rawstr.str());
46  }
47  else
48  assert(false && "instruction of source node not found");
49 
50 }
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:112
#define assert(ex)
Definition: util.h:141
const char * SB_SLICESOURCE
Saber annotations.
Definition: Annotator.h:174
const Value * getLLVMValue(const SVFGNode *node) const
Get llvm value from a SVFGNode.
Definition: ProgSlice.cpp:154
llvm::Instruction Instruction
Definition: BasicTypes.h:79
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
const ProgSlice * _curSlice
void addMDTag(Instruction *inst, std::string str)
Simple add/remove meta data information.
Definition: Annotator.h:99

◆ annotateSwitch()

void SaberAnnotator::annotateSwitch ( SwitchInst switchInst,
u32_t  succPos 
)

Annotate switch instruction and its corresponding feasible path

Definition at line 109 of file SaberAnnotator.cpp.

110 {
111  assert(succPos < switchInst->getNumSuccessors() && "successor position not correct!");
112 }
#define assert(ex)
Definition: util.h:141

Member Data Documentation

◆ _curSlice

const ProgSlice* SVF::SaberAnnotator::_curSlice
private

Definition at line 47 of file SaberAnnotator.h.


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