SVF
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Static Private Attributes | List of all members
SVF::PAGEdge Class Reference

#include <PAGEdge.h>

Inheritance diagram for SVF::PAGEdge:
SVF::GenericEdge< NodeTy > SVF::AddrPE SVF::BinaryOPPE SVF::CallPE SVF::CmpPE SVF::CopyPE SVF::GepPE SVF::LoadPE SVF::RetPE SVF::StorePE SVF::UnaryOPPE

Public Types

enum  PEDGEK {
  Addr, Copy, Store, Load,
  Call, Ret, NormalGep, VariantGep,
  ThreadFork, ThreadJoin, Cmp, BinaryOp,
  UnaryOp
}
 
typedef GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
 
typedef Map< EdgeID, PAGEdgeSetTyPAGEdgeToSetMapTy
 
typedef PAGEdgeToSetMapTy PAGKindToEdgeSetMapTy
 
- Public Types inherited from SVF::GenericEdge< NodeTy >
typedef NodeTy NodeType
 Node type. More...
 
typedef u64_t GEdgeFlag
 
typedef s32_t GEdgeKind
 
typedef struct SVF::GenericEdge::equalGEdge equalGEdge
 Add the hash function for std::set (we also can overload operator< to implement this) More...
 

Public Member Functions

 PAGEdge (PAGNode *s, PAGNode *d, GEdgeFlag k)
 Constructor. More...
 
 ~PAGEdge ()
 Destructor. More...
 
EdgeID getEdgeID () const
 Return Edge ID. More...
 
bool isPTAEdge () const
 Whether src and dst nodes are both of pointer type. More...
 
virtual const std::string toString () const
 
const InstructiongetInst () const
 Get/set methods for llvm instruction. More...
 
void setValue (const Value *val)
 
const ValuegetValue () const
 
void setBB (const BasicBlock *bb)
 
const BasicBlockgetBB () const
 
void setICFGNode (ICFGNode *node)
 
ICFGNodegetICFGNode () const
 
- Public Member Functions inherited from SVF::GenericEdge< NodeTy >
 GenericEdge (NodeTy *s, NodeTy *d, GEdgeFlag k)
 Constructor. More...
 
virtual ~GenericEdge ()
 Destructor. More...
 
NodeID getSrcID () const
 get methods of the components More...
 
NodeID getDstID () const
 
GEdgeKind getEdgeKind () const
 
NodeTypegetSrcNode () const
 
NodeTypegetDstNode () const
 
bool operator== (const GenericEdge< NodeType > *rhs) const
 

Static Public Member Functions

static GEdgeFlag makeEdgeFlagWithCallInst (GEdgeKind k, const ICFGNode *cs)
 Compute the unique edgeFlag value from edge kind and call site Instruction. More...
 
static GEdgeFlag makeEdgeFlagWithStoreInst (GEdgeKind k, const ICFGNode *store)
 
static bool classof (const PAGEdge *)
 ClassOf. More...
 
static bool classof (const GenericPAGEdgeTy *edge)
 

Static Public Attributes

static Size_t totalEdgeNum
 Total edge number. More...
 

Private Types

typedef Map< const ICFGNode *, u32_tInst2LabelMap
 

Private Attributes

const Valuevalue
 LLVM value. More...
 
const BasicBlockbasicBlock
 LLVM BasicBlock. More...
 
ICFGNodeicfgNode
 ICFGNode. More...
 
EdgeID edgeId
 Edge ID. More...
 

Static Private Attributes

static Inst2LabelMap inst2LabelMap
 Call site Instruction to label map. More...
 
static u64_t callEdgeLabelCounter = 0
 Call site Instruction counter. More...
 
static u64_t storeEdgeLabelCounter = 0
 Store Instruction counter. More...
 

Friends

raw_ostreamoperator<< (raw_ostream &o, const PAGEdge &edge)
 Overloading operator << for dumping PAGNode value. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from SVF::GenericEdge< NodeTy >
static constexpr unsigned char EdgeKindMaskBits = 8
 We use the lower 8 bits to denote edge kind. More...
 
static constexpr u64_t EdgeKindMask = (~0ULL) >> (64 - EdgeKindMaskBits)
 

Detailed Description

Definition at line 47 of file PAGEdge.h.

Member Typedef Documentation

◆ Inst2LabelMap

typedef Map<const ICFGNode*, u32_t> SVF::PAGEdge::Inst2LabelMap
private

Definition at line 174 of file PAGEdge.h.

◆ PAGEdgeSetTy

Definition at line 169 of file PAGEdge.h.

◆ PAGEdgeToSetMapTy

Definition at line 170 of file PAGEdge.h.

◆ PAGKindToEdgeSetMapTy

Definition at line 171 of file PAGEdge.h.

Member Enumeration Documentation

◆ PEDGEK

Thirteen kinds of PAG edges Gep represents offset edge for field sensitivity ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.

Enumerator
Addr 
Copy 
Store 
Load 
Call 
Ret 
NormalGep 
VariantGep 
ThreadFork 
ThreadJoin 
Cmp 
BinaryOp 
UnaryOp 

Definition at line 54 of file PAGEdge.h.

Constructor & Destructor Documentation

◆ PAGEdge()

PAGEdge::PAGEdge ( PAGNode s,
PAGNode d,
GEdgeFlag  k 
)

Constructor.

PAGEdge constructor

Definition at line 1000 of file PAG.cpp.

1000  :
1001  GenericPAGEdgeTy(s,d,k),value(nullptr),basicBlock(nullptr),icfgNode(nullptr)
1002 {
1004  PAG::getPAG()->incEdgeNum();
1005 }
u32_t getTotalEdgeNum() const
Definition: GenericGraph.h:421
const BasicBlock * basicBlock
LLVM BasicBlock.
Definition: PAGEdge.h:61
GenericEdge< PAGNode > GenericPAGEdgeTy
Definition: PAGEdge.h:41
static PAG * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis. ...
Definition: PAG.h:160
ICFGNode * icfgNode
ICFGNode.
Definition: PAGEdge.h:62
EdgeID edgeId
Edge ID.
Definition: PAGEdge.h:63
const Value * value
LLVM value.
Definition: PAGEdge.h:60

◆ ~PAGEdge()

SVF::PAGEdge::~PAGEdge ( )
inline

Destructor.

Definition at line 70 of file PAGEdge.h.

71  {
72  }

Member Function Documentation

◆ classof() [1/2]

static bool SVF::PAGEdge::classof ( const PAGEdge )
inlinestatic

ClassOf.

Definition at line 76 of file PAGEdge.h.

77  {
78  return true;
79  }

◆ classof() [2/2]

static bool SVF::PAGEdge::classof ( const GenericPAGEdgeTy edge)
inlinestatic

Definition at line 80 of file PAGEdge.h.

81  {
82  return edge->getEdgeKind() == PAGEdge::Addr ||
83  edge->getEdgeKind() == PAGEdge::Copy ||
84  edge->getEdgeKind() == PAGEdge::Store ||
85  edge->getEdgeKind() == PAGEdge::Load ||
86  edge->getEdgeKind() == PAGEdge::Call ||
87  edge->getEdgeKind() == PAGEdge::Ret ||
88  edge->getEdgeKind() == PAGEdge::NormalGep ||
89  edge->getEdgeKind() == PAGEdge::VariantGep ||
90  edge->getEdgeKind() == PAGEdge::ThreadFork ||
91  edge->getEdgeKind() == PAGEdge::ThreadJoin ||
92  edge->getEdgeKind() == PAGEdge::Cmp ||
93  edge->getEdgeKind() == PAGEdge::BinaryOp ||
94  edge->getEdgeKind() == PAGEdge::UnaryOp;
95  }

◆ getBB()

const BasicBlock* SVF::PAGEdge::getBB ( ) const
inline

Definition at line 124 of file PAGEdge.h.

125  {
126  return basicBlock;
127  }
const BasicBlock * basicBlock
LLVM BasicBlock.
Definition: PAGEdge.h:61

◆ getEdgeID()

EdgeID SVF::PAGEdge::getEdgeID ( ) const
inline

Return Edge ID.

Definition at line 99 of file PAGEdge.h.

100  {
101  return edgeId;
102  }
EdgeID edgeId
Edge ID.
Definition: PAGEdge.h:63

◆ getICFGNode()

ICFGNode* SVF::PAGEdge::getICFGNode ( ) const
inline

Definition at line 132 of file PAGEdge.h.

133  {
134  return icfgNode;
135  }
ICFGNode * icfgNode
ICFGNode.
Definition: PAGEdge.h:62

◆ getInst()

const Instruction* SVF::PAGEdge::getInst ( ) const
inline

Get/set methods for llvm instruction.

Definition at line 108 of file PAGEdge.h.

109  {
111  }
llvm::Instruction Instruction
Definition: BasicTypes.h:79
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:343
const Value * value
LLVM value.
Definition: PAGEdge.h:60

◆ getValue()

const Value* SVF::PAGEdge::getValue ( ) const
inline

Definition at line 116 of file PAGEdge.h.

117  {
118  return value;
119  }
const Value * value
LLVM value.
Definition: PAGEdge.h:60

◆ isPTAEdge()

bool PAGEdge::isPTAEdge ( ) const

Whether src and dst nodes are both of pointer type.

Whether src and dst nodes are both pointer type

Definition at line 1010 of file PAG.cpp.

1011 {
1012  return getSrcNode()->isPointer() && getDstNode()->isPointer();
1013 }
NodeType * getDstNode() const
Definition: GenericGraph.h:89
NodeType * getSrcNode() const
Definition: GenericGraph.h:85

◆ makeEdgeFlagWithCallInst()

static GEdgeFlag SVF::PAGEdge::makeEdgeFlagWithCallInst ( GEdgeKind  k,
const ICFGNode cs 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and call site Instruction.

Definition at line 139 of file PAGEdge.h.

140  {
141  Inst2LabelMap::const_iterator iter = inst2LabelMap.find(cs);
142  u64_t label = (iter != inst2LabelMap.end()) ?
143  iter->second : callEdgeLabelCounter++;
144  return (label << EdgeKindMaskBits) | k;
145  }
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.
Definition: PAGEdge.h:175
static u64_t callEdgeLabelCounter
Call site Instruction counter.
Definition: PAGEdge.h:176
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
Definition: GenericGraph.h:119
unsigned long long u64_t
Definition: SVFBasicTypes.h:76

◆ makeEdgeFlagWithStoreInst()

static GEdgeFlag SVF::PAGEdge::makeEdgeFlagWithStoreInst ( GEdgeKind  k,
const ICFGNode store 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and store Instruction. Two store instructions may share the same StorePAGEdge

Definition at line 149 of file PAGEdge.h.

150  {
151  Inst2LabelMap::const_iterator iter = inst2LabelMap.find(store);
152  u64_t label = (iter != inst2LabelMap.end()) ?
153  iter->second : storeEdgeLabelCounter++;
154  return (label << EdgeKindMaskBits) | k;
155  }
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.
Definition: PAGEdge.h:175
static u64_t storeEdgeLabelCounter
Store Instruction counter.
Definition: PAGEdge.h:177
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
Definition: GenericGraph.h:119
unsigned long long u64_t
Definition: SVFBasicTypes.h:76

◆ setBB()

void SVF::PAGEdge::setBB ( const BasicBlock bb)
inline

Definition at line 120 of file PAGEdge.h.

121  {
122  basicBlock = bb;
123  }
const BasicBlock * basicBlock
LLVM BasicBlock.
Definition: PAGEdge.h:61

◆ setICFGNode()

void SVF::PAGEdge::setICFGNode ( ICFGNode node)
inline

Definition at line 128 of file PAGEdge.h.

129  {
130  icfgNode = node;
131  }
ICFGNode * icfgNode
ICFGNode.
Definition: PAGEdge.h:62

◆ setValue()

void SVF::PAGEdge::setValue ( const Value val)
inline

Definition at line 112 of file PAGEdge.h.

113  {
114  value = val;
115  }
const Value * value
LLVM value.
Definition: PAGEdge.h:60

◆ toString()

const std::string PAGEdge::toString ( ) const
virtual

Reimplemented in SVF::TDJoinPE, SVF::TDForkPE, SVF::RetPE, SVF::CallPE, SVF::VariantGepPE, SVF::NormalGepPE, SVF::GepPE, SVF::LoadPE, SVF::StorePE, SVF::UnaryOPPE, SVF::BinaryOPPE, SVF::CmpPE, SVF::CopyPE, and SVF::AddrPE.

Definition at line 200 of file PAG.cpp.

200  {
201  std::string str;
202  raw_string_ostream rawstr(str);
203  rawstr << "PAGEdge: [" << getDstID() << "<--" << getSrcID() << "]\t";
204  return rawstr.str();
205 }
NodeID getDstID() const
Definition: GenericGraph.h:77
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100

Friends And Related Function Documentation

◆ operator<<

raw_ostream& operator<< ( raw_ostream o,
const PAGEdge edge 
)
friend

Overloading operator << for dumping PAGNode value.

Definition at line 162 of file PAGEdge.h.

163  {
164  o << edge.toString();
165  return o;
166  }

Member Data Documentation

◆ basicBlock

const BasicBlock* SVF::PAGEdge::basicBlock
private

LLVM BasicBlock.

Definition at line 61 of file PAGEdge.h.

◆ callEdgeLabelCounter

u64_t PAGEdge::callEdgeLabelCounter = 0
staticprivate

Call site Instruction counter.

Definition at line 176 of file PAGEdge.h.

◆ edgeId

EdgeID SVF::PAGEdge::edgeId
private

Edge ID.

Definition at line 63 of file PAGEdge.h.

◆ icfgNode

ICFGNode* SVF::PAGEdge::icfgNode
private

ICFGNode.

Definition at line 62 of file PAGEdge.h.

◆ inst2LabelMap

PAGEdge::Inst2LabelMap PAGEdge::inst2LabelMap
staticprivate

Call site Instruction to label map.

Definition at line 175 of file PAGEdge.h.

◆ storeEdgeLabelCounter

u64_t PAGEdge::storeEdgeLabelCounter = 0
staticprivate

Store Instruction counter.

Definition at line 177 of file PAGEdge.h.

◆ totalEdgeNum

Size_t SVF::PAGEdge::totalEdgeNum
static

Total edge number.

Definition at line 65 of file PAGEdge.h.

◆ value

const Value* SVF::PAGEdge::value
private

LLVM value.

Definition at line 60 of file PAGEdge.h.


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