Static Value-Flow Analysis
Loading...
Searching...
No Matches
NodeIDAllocator.h
Go to the documentation of this file.
1//===- NodeIDAllocator.h -- Allocates node IDs on request ------------------------//
2
3#ifndef NODEIDALLOCATOR_H_
4#define NODEIDALLOCATOR_H_
5
7#include "SVFIR/SVFType.h"
9
10namespace SVF
11{
12
13// Forward declare for the Clusterer.
14class BVDataPTAImpl;
15
21{
22
23public:
42
51 static const NodeID nullPointerId;
53
55 static NodeIDAllocator *get(void);
56
58 static void unset(void);
59
62
65
73
76
79
82 {
83 return numObjects;
84 }
85
87 {
88 ++numObjects;
89 ++numNodes;
90 }
91
92 inline void increaseNumOfValues()
93 {
94 ++numValues;
95 ++numNodes;
96 }
97
98 inline int getNumOfNodes()
99 {
100 return numNodes;
101 }
102
103private:
105 NodeIDAllocator(void);
106
107private:
121
124
127
128public:
132 {
133 private:
137
140 static const std::string NumObjects;
141 static const std::string RegioningTime;
142 static const std::string DistanceMatrixTime;
143 static const std::string FastClusterTime;
144 static const std::string DendrogramTraversalTime;
145 static const std::string EvalTime;
146 static const std::string TotalTime;
147 static const std::string TheoreticalNumWords;
148 static const std::string OriginalBvNumWords;
149 static const std::string OriginalSbvNumWords;
150 static const std::string NewBvNumWords;
151 static const std::string NewSbvNumWords;
152 static const std::string NumRegions;
153 static const std::string NumGtIntRegions;
154 static const std::string LargestRegion;
155 static const std::string BestCandidate;
156 static const std::string NumNonTrivialRegionObjects;
158
159 public:
166 static std::vector<NodeID> cluster(BVDataPTAImpl *pta, const std::vector<std::pair<NodeID, unsigned>> keys, std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates, std::string evalSubtitle="");
167
168 // Returns a reverse node mapping for mapping generated by cluster().
169 static std::vector<NodeID> getReverseNodeMapping(const std::vector<NodeID> &nodeMapping);
170
172 static void evaluate(const std::vector<NodeID> &nodeMap, const Map<PointsTo, unsigned> pointsToSets, Map<std::string, std::string> &stats, bool accountForOcc);
173
176 static void printStats(std::string title, Map<std::string, std::string> &stats);
177
178 private:
181 static inline size_t condensedIndex(size_t n, size_t i, size_t j);
182
184 static inline unsigned requiredBits(const PointsTo &pts);
185
187 static inline unsigned requiredBits(const size_t n);
188
192 static inline double *getDistanceMatrix(const std::vector<std::pair<const PointsTo *, unsigned>> pointsToSets,
193 const size_t numObjects, const Map<NodeID, unsigned> &nodeMap,
194 double &distanceMatrixTime);
195
199 static inline void traverseDendrogram(std::vector<NodeID> &nodeMap, const int *dendrogram, const size_t numObjects, unsigned &allocCounter, Set<int> &visited, const int index, const std::vector<NodeID> &regionNodeMap);
200
205 static inline std::vector<unsigned> regionObjects(const Map<NodeID, Set<NodeID>> &graph, size_t numObjects, size_t &numLabels);
206
207 // From all the candidates, returns the best mapping for pointsToSets (points-to set -> # occurrences).
208 static inline std::pair<hclust_fast_methods, std::vector<NodeID>> determineBestMapping(
209 const std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates,
210 Map<PointsTo, unsigned> pointsToSets, const std::string &evalSubtitle, double &evalTime);
211
212 };
213};
214
215} // namespace SVF
216
217#endif // ifdef NODEIDALLOCATOR_H_
buffer offset
Definition cJSON.cpp:1113
cJSON * n
Definition cJSON.cpp:2558
int index
Definition cJSON.h:170
static const std::string DistanceMatrixTime
static std::vector< NodeID > cluster(BVDataPTAImpl *pta, const std::vector< std::pair< NodeID, unsigned > > keys, std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > &candidates, std::string evalSubtitle="")
static const std::string LargestRegion
static const std::string NumNonTrivialRegionObjects
static const std::string EvalTime
Map< NodePair, std::pair< unsigned, unsigned > > DistOccMap
static std::vector< unsigned > regionObjects(const Map< NodeID, Set< NodeID > > &graph, size_t numObjects, size_t &numLabels)
static const std::string TheoreticalNumWords
static std::pair< hclust_fast_methods, std::vector< NodeID > > determineBestMapping(const std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > &candidates, Map< PointsTo, unsigned > pointsToSets, const std::string &evalSubtitle, double &evalTime)
static const std::string BestCandidate
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
static const std::string OriginalSbvNumWords
static const std::string DendrogramTraversalTime
static const std::string NewSbvNumWords
static double * getDistanceMatrix(const std::vector< std::pair< const PointsTo *, unsigned > > pointsToSets, const size_t numObjects, const Map< NodeID, unsigned > &nodeMap, double &distanceMatrixTime)
static unsigned requiredBits(const PointsTo &pts)
Returns the minimum number of bits required to represent pts in a perfect world.
static void traverseDendrogram(std::vector< NodeID > &nodeMap, const int *dendrogram, const size_t numObjects, unsigned &allocCounter, Set< int > &visited, const int index, const std::vector< NodeID > &regionNodeMap)
static void printStats(std::string title, Map< std::string, std::string > &stats)
static const std::string NumRegions
static size_t condensedIndex(size_t n, size_t i, size_t j)
static void evaluate(const std::vector< NodeID > &nodeMap, const Map< PointsTo, unsigned > pointsToSets, Map< std::string, std::string > &stats, bool accountForOcc)
Fills in *NumWords statistics in stats..
static const std::string RegioningTime
static const std::string NumGtIntRegions
static const std::string FastClusterTime
static const std::string OriginalBvNumWords
static const std::string NewBvNumWords
static const std::string NumObjects
static const std::string TotalTime
NodeID numValues
Number of values allocated, including specials.
static const NodeID nullPointerId
NodeID allocateValueId(void)
Allocate a value ID as determined by the strategy.
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID numSymbols
Number of explicit symbols allocated (e.g., llvm::Values), including specials.
enum Strategy strategy
Strategy to allocate with.
static const NodeID blackHolePointerId
NodeID numType
Total number of svftypes.
static NodeIDAllocator * allocator
Single allocator.
static const NodeID constantObjectId
NodeID allocateTypeId(void)
Allocate an type ID as determined by the strategy.
NodeID allocateObjectId(void)
Allocate an object ID as determined by the strategy.
static const NodeID blackHoleObjectId
Strategy
Allocation strategy to use.
@ SEQ
Allocate objects objects and values sequentially, intermixed.
NodeID numNodes
Total number of objects and values allocated.
NodeID endSymbolAllocation(void)
Notify the allocator that all symbols have had IDs allocated.
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
NodeIDAllocator(void)
Builds a node ID allocator with the strategy specified on the command line.
NodeID getNumObjects(void) const
Returns the total number of memory objects.
static void unset(void)
Deletes the (singleton) allocator.
hclust_fast_methods
Definition fastcluster.h:66
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:56
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
unsigned u32_t
Definition GeneralType.h:47