45 : numObjects(4), numValues(4), numSymbols(4), numNodes(4), numType(0), strategy(
Options::NodeAllocStrat())
75 assert(
false &&
"NodeIDAllocator::allocateObjectId: unimplemented node allocation strategy.");
80 assert(
id != 0 &&
"NodeIDAllocator::allocateObjectId: ID not allocated");
119 assert(
id >
numSymbols &&
"NodeIDAllocator::allocateGepObjectId: GEP allocation clashing with other nodes");
123 assert(
false &&
"NodeIDAllocator::allocateGepObjectId: unimplemented node allocation strategy");
128 assert(
id != 0 &&
"NodeIDAllocator::allocateGepObjectId: ID not allocated");
157 assert(
false &&
"NodeIDAllocator::allocateValueId: unimplemented node allocation strategy");
163 assert(
id != 0 &&
"NodeIDAllocator::allocateValueId: ID not allocated");
193 const std::vector<std::pair<NodeID, unsigned>>
keys,
199 assert(pta !=
nullptr &&
"Clusterer::cluster: given null BVDataPTAImpl");
219 for (
const std::pair<NodeID, unsigned> &
keyOcc :
keys)
304 if (pt.
empty())
continue;
318 std::vector<hclust_fast_methods>
methods;
392 std::pair<hclust_fast_methods, std::vector<NodeID>>
bestMapping =
413 std::vector<NodeID> reverseNodeMapping(nodeMapping.size(),
UINT_MAX);
414 for (
size_t i = 0;
i < nodeMapping.size(); ++
i)
418 reverseNodeMapping.at(
mapsTo) =
i;
421 return reverseNodeMapping;
427 return n*(
n-1)/2 - (
n-
i)*(
n-
i-1)/2 +
j -
i - 1;
432 return requiredBits(
pts.count());
437 if (
n == 0)
return 0;
467 std::vector<NodeID>
ptsVec;
469 for (
size_t i = 0;
i <
ptsVec.size(); ++
i)
474 for (
size_t j =
i + 1;
j <
ptsVec.size(); ++
j)
516 if (visited.find(
index) != visited.end())
return;
517 visited.insert(
index);
597 if (
pts.count() == 0)
continue;
614 if (
o < min) min =
o;
615 if (
o > max) max =
o;
672 std::pair<hclust_fast_methods, std::vector<NodeID>>
bestMapping = candidates[0];
674 size_t bestWords = std::numeric_limits<size_t>::max();
697 else assert(
false &&
"Clusterer::cluster: unsupported BV type for clustering.");
713 static const std::string
statKeys[] =
715 NumObjects, TheoreticalNumWords, OriginalSbvNumWords, OriginalBvNumWords,
716 NewSbvNumWords, NewBvNumWords, NumRegions, NumGtIntRegions,
717 NumNonTrivialRegionObjects, LargestRegion, RegioningTime,
718 DistanceMatrixTime, FastClusterTime, DendrogramTraversalTime,
719 EvalTime, TotalTime, BestCandidate
728 if (stat !=
stats.end())
#define NATIVE_INT_SIZE
Size of native integer that we'll use for bit vectors, in bits.
const PointsTo & getPts(NodeID id) override
static const std::string DistanceMatrixTime
static const std::string LargestRegion
static const std::string NumNonTrivialRegionObjects
static const std::string EvalTime
static std::vector< unsigned > regionObjects(const Map< NodeID, Set< NodeID > > &graph, size_t numObjects, size_t &numLabels)
static const std::string TheoreticalNumWords
static const std::string BestCandidate
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
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, bool printStat)
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 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="", bool printStat=true)
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 > ®ionNodeMap)
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
@ 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.
void increaseNumOfObjAndNodes()
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.
static void unset(void)
Deletes the (singleton) allocator.
Carries around command line options.
static const OptionMap< SVF::NodeIDAllocator::Strategy > NodeAllocStrat
static const OptionMap< PointsTo::Type > PtType
Type of points-to set to use for all analyses.
static const Option< bool > RegionAlign
Align identifiers in each region to a word.
static const Option< bool > RegionedClustering
Cluster partitions separately.
static const OptionMap< u32_t > ClusterMethod
bool empty() const
Returns true if set is empty.
void clear()
Empty the set.
const_iterator begin() const
static double getClk(bool mark=false)
int hclust_fast(int n, double *distmat, int method, int *merge, double *height)
std::string hclustMethodToString(hclust_fast_methods method)
Returns a string representation of a hclust method.
std::ostream & outs()
Overwrite llvm::outs()
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder