-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from MingshanJia/stage-IFDS
Mingshan's IFDS
- Loading branch information
Showing
8 changed files
with
766 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,168 @@ | ||
/* | ||
* SICFG.h | ||
* IFDS.h | ||
* | ||
*/ | ||
|
||
#ifndef INCLUDE_UTIL_SICFG_H_ | ||
#define INCLUDE_UTIL_SICFG_H_ | ||
#ifndef INCLUDE_WPA_IFDS_H_ | ||
#define INCLUDE_WPA_IFDS_H_ | ||
|
||
|
||
#include "Util/ICFG.h" | ||
#include "WPA/Andersen.h" | ||
#include <iostream> | ||
|
||
class IFDS { | ||
|
||
private: | ||
ICFG* icfg; | ||
ICFG *icfg; | ||
PointerAnalysis *pta; | ||
|
||
public: | ||
inline VFG* getVFG() const{ | ||
return icfg->getVFG(); | ||
} | ||
class PathNode; | ||
class PathEdge; | ||
|
||
inline ICFG* getICFG() const{ | ||
return icfg; | ||
} | ||
typedef std::set<const PAGNode *> Datafact; //set of uninitialized variables at ICFGNode | ||
typedef std::set<Datafact> Facts; //different datafacts from different path | ||
typedef std::set<const ICFGNode *> ICFGNodeSet; | ||
typedef std::list<PathEdge *> PathEdgeSet; //to do : list -> vector (faster) | ||
typedef std::map<const ICFGNode *, Facts> ICFGNodeToDataFactsMap; | ||
|
||
IFDS(ICFG* i): icfg(i){ | ||
} | ||
protected: | ||
PathEdgeSet WorkList; //worklist used during the tabulation algorithm | ||
PathEdgeSet PathEdgeList; //used to restore all PathEdges (result) | ||
PathEdgeSet SummaryEdgeList; //used to restore all SummaryEdges | ||
ICFGNodeSet ICFGDstNodeSet; | ||
ICFGNodeSet SummaryICFGDstNodeSet; | ||
ICFGNodeToDataFactsMap ICFGNodeToFacts; | ||
ICFGNodeToDataFactsMap SummaryICFGNodeToFacts; | ||
ICFGNode *mainEntryNode; | ||
Facts MainExitFacts; | ||
int32_t estimatedDatafacts; | ||
|
||
}; | ||
public: | ||
inline VFG *getVFG() const { | ||
return icfg->getVFG(); | ||
} | ||
|
||
inline ICFG *getICFG() const { | ||
return icfg; | ||
} | ||
|
||
inline PAG *getPAG() const { | ||
return icfg->getPAG(); | ||
} | ||
|
||
//constructor | ||
IFDS(ICFG *i); | ||
|
||
//procedures in Tabulation Algorithm | ||
void initialize(); | ||
|
||
void forwardTabulate(); | ||
|
||
//add new PathEdge components into PathEdgeList and WorkList | ||
void propagate(PathNode *srcPN, ICFGNode *succ, Datafact& d); | ||
void PEPropagate(PathNode *srcPN, ICFGNode *succ, Datafact& d); | ||
void SEPropagate(const ICFGNode *caller, Datafact& d4, ICFGNode *ret, Datafact& d5); | ||
|
||
bool isNotInSummaryEdgeList(const ICFGNode *n1, Datafact& d1, ICFGNode *n2, Datafact& d2); | ||
|
||
//transfer function of given ICFGNode | ||
Datafact& transferFun(const ICFGNode *icfgNode, Datafact& fact); | ||
|
||
Datafact& getCalleeDatafact(const ICFGNode *icfgNode, Datafact& fact); | ||
Datafact& getCallToRetDatafact(Datafact& fact); | ||
void delDatafact(Datafact& d, s32_t kind); | ||
|
||
//whether the variable is initialized | ||
bool isInitialized(const PAGNode *pagNode, Datafact& datafact); | ||
|
||
//print ICFGNodes and theirs datafacts | ||
void getIFDSStat(); | ||
void printRes(); | ||
void printPathEdgeList(); | ||
void printSummaryEdgeList(); | ||
void validateTests(const char *fun); | ||
|
||
void printFacts(Facts facts, bool ObjNodeOnly = false); | ||
Datafact concernedDatafact(); | ||
|
||
//Get points-to set of given PAGNode | ||
inline PointsTo &getPts(NodeID id) { | ||
return pta->getPts(id); | ||
} | ||
|
||
// in order to denote : <node, d> , d here is datafact before the execution of node | ||
class PathNode { | ||
const ICFGNode *icfgNode; | ||
Datafact datafact; | ||
PathNode *caller; // for sp node | ||
|
||
//Constructor | ||
public: | ||
PathNode(){ | ||
} | ||
|
||
PathNode(const ICFGNode *node, const Datafact& fact) : caller (NULL){ | ||
icfgNode = node; | ||
datafact = fact; | ||
} | ||
|
||
void setCaller(PathNode *caller){ | ||
this->caller = caller; | ||
} | ||
|
||
PathNode* getCaller(){ | ||
return this->caller; | ||
} | ||
|
||
void setICFGNode(ICFGNode *node) { | ||
icfgNode = node; | ||
} | ||
|
||
void setDataFact(Datafact &fact) { | ||
datafact = fact; | ||
} | ||
|
||
const ICFGNode *getICFGNode() const { | ||
return icfgNode; | ||
} | ||
|
||
Datafact &getDataFact() { | ||
return datafact; | ||
} | ||
|
||
}; | ||
|
||
// in order to denote : <node1, d1> --> <node2, d2> | ||
class PathEdge { | ||
PathNode *srcNode; | ||
PathNode *dstNode; | ||
|
||
public: | ||
PathEdge(); | ||
|
||
PathEdge(PathNode *src, PathNode *dst) { | ||
srcNode = src; | ||
dstNode = dst; | ||
} | ||
|
||
void setStartPathNode(PathNode *node) { | ||
srcNode = node; | ||
} | ||
|
||
void setEndPathNode(PathNode *node) { | ||
dstNode = node; | ||
} | ||
|
||
PathNode *getDstPathNode() const { | ||
return dstNode; | ||
} | ||
|
||
PathNode *getSrcPathNode() const { | ||
return srcNode; | ||
} | ||
}; | ||
}; | ||
|
||
#endif /* INCLUDE_UTIL_SICFG_H_ */ | ||
#endif /* INCLUDE_WPA_IFDS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.