Implementation Details - mehul11jain/libPointsToDump GitHub Wiki
Implementation Details of libPointsToDump
- All the classes are enums are defined inside a namespace named PTDump.
- There are two main classes in the PointsToDump library.
- PTReader: Used to query information out of .pt dump.
class PTReader { json reader; std::string fileName; std::string PathToFile; public: PTReader(std::string); PTReader(std::string, std::string); void init(); ~PTReader(); std::vector<std::pair<std::string, std::string>> getMustPointsToPairsAt(llvm::Instruction*); std::vector<std::pair<std::string, std::string>> getMayPointsToPairsAt(llvm::Instruction*); void printPointsToDump(); void printToDot(llvm::Instruction*); bool isMustPointee(llvm::Instruction*, llvm::Value*, llvm::Value*); bool isMayPointee(llvm::Instruction*, llvm::Value*, llvm::Value*); std::vector<std::string> getPointeesOf(llvm::Instruction*, llvm::Value*); };
- PTWriter: Used to dump the Points-to information in .pt format.
class PTWriter { json writer; AnalysisType Atype; std::string fileName; std::stack<llvm::BasicBlock*> latestBB; std::stack<llvm::Function*> latestFunction; std::stack<llvm::Instruction*> latestInst; public: PTWriter(); ~PTWriter(); PTWriter(AnalysisType, std::string); bool addPointsTo(const llvm::Value *,const llvm::Value *, PointeeType); bool PointsToInfoAt(llvm::Instruction *); bool AddPointsToinfoAt(llvm::Function*, llvm::BasicBlock*, llvm::Instruction*, const llvm::Value*, const llvm::Value*, PointeeType); bool AddProcedureInfo(llvm::Function *); bool AddBasicBlockInfo(llvm::BasicBlock *); bool isValidPTFormat(json); void WriteToJson(std::string); };
- PTReader: Used to query information out of .pt dump.
-
There are two enums defined in the PTDump namespace.
- AnalysisType: Specifies the Type of Analysis for which we are storing the points-to information for.
enum AnalysisType { FlowInsensitive, FlowSensitive, ContextSensitive };
- PointeeType: Specifies the Type of Pointee i.e Either may/must.
enum PointeeType { MayPointee, MustPointee };
-
To parse the standard json file we have used the nlohmann/json library.