Static Value-Flow Analysis
Loading...
Searching...
No Matches
NodeIDAllocator.cpp
Go to the documentation of this file.
1//===- NodeIDAllocator.cpp -- Allocates node IDs on request ------------------------//
2
3#include <iomanip>
4#include <iostream>
5#include <queue>
6#include <cmath>
7
10#include "Util/PTAStat.h"
12#include "Util/SVFUtil.h"
13#include "Util/Options.h"
14
15namespace SVF
16{
21
22NodeIDAllocator *NodeIDAllocator::allocator = nullptr;
23
25{
26 if (allocator == nullptr)
27 {
29 }
30
31 return allocator;
32}
33
35{
36 if (allocator != nullptr)
37 {
38 delete allocator;
39 allocator = nullptr;
40 }
41}
42
43// Initialise counts to 4 because that's how many special nodes we have.
45 : numObjects(4), numValues(4), numSymbols(4), numNodes(4), numType(0), strategy(Options::NodeAllocStrat())
46{ }
47
49{
50 NodeID id = 0;
52 {
53 // We allocate objects from 0(-ish, considering the special nodes) to # of objects.
54 id = numObjects;
55 }
57 {
58 id = UINT_MAX - numObjects;
59 }
60 else if (strategy == Strategy::SEQ)
61 {
62 // Everything is sequential and intermixed.
63 id = numNodes;
64 }
65 else if (strategy == Strategy::DBUG)
66 {
67 // Non-GEPs just grab the next available ID.
68 // We may have "holes" because GEPs increment the total
69 // but allocate far away. This is not a problem because
70 // we don't care about the relative distances between nodes.
71 id = numNodes;
72 }
73 else
74 {
75 assert(false && "NodeIDAllocator::allocateObjectId: unimplemented node allocation strategy.");
76 }
77
79
80 assert(id != 0 && "NodeIDAllocator::allocateObjectId: ID not allocated");
81 return id;
82}
83
84
89
91{
92 NodeID id = 0;
94 {
95 // Nothing different to the other case.
96 id = numObjects;
97 }
99 {
100 id = UINT_MAX - numObjects;
101 }
102 else if (strategy == Strategy::SEQ)
103 {
104 // Everything is sequential and intermixed.
105 id = numNodes;
106 }
107 else if (strategy == Strategy::DBUG)
108 {
109 // For a gep id, base id is set at lower bits, and offset is set at higher bits
110 // e.g., 1100050 denotes base=50 and offset=10
111 // The offset is 10, not 11, because we add 1 to the offset to ensure that the
112 // high bits are never 0. For example, we do not want the gep id to be 50 when
113 // the base is 50 and the offset is 0.
117 )));
118 id = (offset + 1) * gepMultiplier + base;
119 assert(id > numSymbols && "NodeIDAllocator::allocateGepObjectId: GEP allocation clashing with other nodes");
120 }
121 else
122 {
123 assert(false && "NodeIDAllocator::allocateGepObjectId: unimplemented node allocation strategy");
124 }
125
127
128 assert(id != 0 && "NodeIDAllocator::allocateGepObjectId: ID not allocated");
129 return id;
130}
131
133{
134 NodeID id = 0;
136 {
137 // We allocate values from UINT_MAX to UINT_MAX - # of values.
138 // TODO: UINT_MAX does not allow for an easily changeable type
139 // of NodeID (though it is already in use elsewhere).
140 id = UINT_MAX - numValues;
141 }
143 {
144 id = numValues;
145 }
146 else if (strategy == Strategy::SEQ)
147 {
148 // Everything is sequential and intermixed.
149 id = numNodes;
150 }
151 else if (strategy == Strategy::DBUG)
152 {
153 id = numNodes;
154 }
155 else
156 {
157 assert(false && "NodeIDAllocator::allocateValueId: unimplemented node allocation strategy");
158 }
159
160 ++numValues;
161 ++numNodes;
162
163 assert(id != 0 && "NodeIDAllocator::allocateValueId: ID not allocated");
164 return id;
165}
166
172
173const std::string NodeIDAllocator::Clusterer::NumObjects = "NumObjects";
174const std::string NodeIDAllocator::Clusterer::RegioningTime = "RegioningTime";
175const std::string NodeIDAllocator::Clusterer::DistanceMatrixTime = "DistanceMatrixTime";
176const std::string NodeIDAllocator::Clusterer::FastClusterTime = "FastClusterTime";
177const std::string NodeIDAllocator::Clusterer::DendrogramTraversalTime = "DendrogramTravTime";
178const std::string NodeIDAllocator::Clusterer::EvalTime = "EvalTime";
179const std::string NodeIDAllocator::Clusterer::TotalTime = "TotalTime";
180const std::string NodeIDAllocator::Clusterer::TheoreticalNumWords = "TheoreticalWords";
181const std::string NodeIDAllocator::Clusterer::OriginalBvNumWords = "OriginalBvWords";
182const std::string NodeIDAllocator::Clusterer::OriginalSbvNumWords = "OriginalSbvWords";
183const std::string NodeIDAllocator::Clusterer::NewBvNumWords = "NewBvWords";
184const std::string NodeIDAllocator::Clusterer::NewSbvNumWords = "NewSbvWords";
185const std::string NodeIDAllocator::Clusterer::NumRegions = "NumRegions";
186const std::string NodeIDAllocator::Clusterer::NumGtIntRegions = "NumGtIntRegions";
187const std::string NodeIDAllocator::Clusterer::LargestRegion = "LargestRegion";
188const std::string NodeIDAllocator::Clusterer::BestCandidate = "BestCandidate";
189const std::string NodeIDAllocator::Clusterer::NumNonTrivialRegionObjects = "NumNonTrivObj";
190
192 BVDataPTAImpl *pta,
193 const std::vector<std::pair<NodeID, unsigned>> keys,
194 std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates,
195 std::string evalSubtitle,
196 bool printStat
197)
198{
199 assert(pta != nullptr && "Clusterer::cluster: given null BVDataPTAImpl");
200 assert(Options::NodeAllocStrat() == Strategy::DENSE && "Clusterer::cluster: only dense allocation clustering currently supported");
201
203 double fastClusterTime = 0.0;
204 double distanceMatrixTime = 0.0;
205 double dendrogramTraversalTime = 0.0;
206 double regioningTime = 0.0;
207 double evalTime = 0.0;
208
209 // Pair of nodes to their (minimum) distance and the number of occurrences of that distance.
210 Map<std::pair<NodeID, NodeID>, std::pair<unsigned, unsigned>> distances;
211
212 double clkStart = PTAStat::getClk(true);
213
214 // Map points-to sets to occurrences.
216
217 // Objects each object shares at least a points-to set with.
219 for (const std::pair<NodeID, unsigned> &keyOcc : keys)
220 {
221 const PointsTo &pts = pta->getPts(keyOcc.first);
222 const size_t oldSize = pointsToSets.size();
223 pointsToSets[pts] += keyOcc.second;;
224
225 // Edges in this graph have no weight or uniqueness, so we only need to
226 // do this for each points-to set once.
227 if (oldSize != pointsToSets.size())
228 {
229 NodeID firstO = !pts.empty() ? *(pts.begin()) : 0;
231 for (const NodeID o : pts)
232 {
233 if (o != firstO)
234 {
235 firstOsNeighbours.insert(o);
236 coPointeeGraph[o].insert(firstO);
237 }
238 }
239 }
240 }
241
243 overallStats[NumObjects] = std::to_string(numObjects);
244
245 size_t numRegions = 0;
246 std::vector<unsigned> objectsRegion;
248 {
250 }
251 else
252 {
253 // Just a single big region (0).
254 objectsRegion.insert(objectsRegion.end(), numObjects, 0);
255 numRegions = 1;
256 }
257
258 // Set needs to be ordered because getDistanceMatrix, in its n^2 iteration, expects
259 // sets to be ordered (we are building a condensed matrix, not a full matrix, so it
260 // matters). In getDistanceMatrix, doing regionReverseMapping for oi and oj, where
261 // oi < oj, and getting a result moi > moj gives incorrect results.
262 // In the condensed matrix, [b][a] where b >= a, is incorrect.
263 std::vector<OrderedSet<NodeID>> regionsObjects(numRegions);
264 for (NodeID o = 0; o < numObjects; ++o) regionsObjects[objectsRegion[o]].insert(o);
265
266 // Size of the return node mapping. It is potentially larger than the number of
267 // objects because we align each region to NATIVE_INT_SIZE.
268 // size_t numMappings = 0;
269
270 // Maps a region to a mapping which maps 0 to n to all objects
271 // in that region.
272 std::vector<std::vector<NodeID>> regionMappings(numRegions);
273 // The reverse: region to mapping of objects to a 0 to n from above.
274 std::vector<Map<NodeID, unsigned>> regionReverseMappings(numRegions);
275 // We can thus use 0 to n for each region to create smaller distance matrices.
276 for (unsigned region = 0; region < numRegions; ++region)
277 {
278 size_t curr = 0;
279 // With the OrderedSet above, o1 < o2 => map[o1] < map[o2].
281 {
282 // push_back here is just like p...[region][curr] = o.
283 regionMappings[region].push_back(o);
285 }
286
287 // curr is the number of objects. A region with no objects makes no sense.
288 assert(curr != 0);
289
290 // Number of bits needed for this region if we were
291 // to start assigning from 0 rounded up to the fewest needed
292 // native ints. This is added to the number of mappings since
293 // we align each region to a native int.
294 // numMappings += requiredBits(regionsObjects[region].size());
295 }
296
297 // Points-to sets which are relevant to a region, i.e., those whose elements
298 // belong to that region. Pair is for occurrences.
299 std::vector<std::vector<std::pair<const PointsTo *, unsigned>>> regionsPointsTos(numRegions);
301 {
302 const PointsTo &pt = ptocc.first;
303 const unsigned occ = ptocc.second;
304 if (pt.empty()) continue;
305 // Guaranteed that begin() != end() because of the continue above. All objects in pt
306 // will be relevant to the same region.
307 unsigned region = objectsRegion[*(pt.begin())];
308 // In our "graph", objects in the same points-to set have an edge between them,
309 // so they are all in the same connected component/region.
310 regionsPointsTos[region].push_back(std::make_pair(&pt, occ));
311 }
312
313 double clkEnd = PTAStat::getClk(true);
315 overallStats[RegioningTime] = std::to_string(regioningTime);
316 overallStats[NumRegions] = std::to_string(numRegions);
317
318 std::vector<hclust_fast_methods> methods;
320 {
321 methods.push_back(HCLUST_METHOD_SINGLE);
324 }
325 else
326 {
328 }
329
331 {
332 std::vector<NodeID> nodeMap(numObjects, UINT_MAX);
333
334 unsigned numGtIntRegions = 0;
335 unsigned largestRegion = 0;
336 unsigned nonTrivialRegionObjects = 0;
337 unsigned allocCounter = 0;
338 for (unsigned region = 0; region < numRegions; ++region)
339 {
340 const size_t regionNumObjects = regionsObjects[region].size();
341 // Round up to next Word: ceiling of current allocation to get how
342 // many words and multiply to get the number of bits; if we're aligning.
344 {
347 }
348
350
351 // For regions with fewer than 64 objects, we can just allocate them
352 // however as they will be in the one int regardless..
354 {
356 continue;
357 }
358
361
364
366 int *dendrogram = new int[2 * (regionNumObjects - 1)];
367 double *height = new double[regionNumObjects - 1];
369 delete[] distMatrix;
370 delete[] height;
371 clkEnd = PTAStat::getClk(true);
373
375 Set<int> visited;
377 visited, regionNumObjects - 1, regionMappings[region]);
378 delete[] dendrogram;
379 clkEnd = PTAStat::getClk(true);
381 }
382
383 candidates.push_back(std::make_pair(method, nodeMap));
384
385 // Though we "update" these in the loop, they will be the same every iteration.
387 overallStats[LargestRegion] = std::to_string(largestRegion);
389 }
390
391 // Work out which of the mappings we generated looks best.
392 std::pair<hclust_fast_methods, std::vector<NodeID>> bestMapping =
393 determineBestMapping(candidates, pointsToSets, evalSubtitle, evalTime, printStat);
394
398 overallStats[EvalTime] = std::to_string(evalTime);
400
402 if (printStat)
403 {
404 printStats(evalSubtitle + ": overall", overallStats);
405 }
406
407 return bestMapping.second;
408}
409
410std::vector<NodeID> NodeIDAllocator::Clusterer::getReverseNodeMapping(const std::vector<NodeID> &nodeMapping)
411{
412 // nodeMapping.size() may not be big enough because we leave some gaps, but it's a start.
413 std::vector<NodeID> reverseNodeMapping(nodeMapping.size(), UINT_MAX);
414 for (size_t i = 0; i < nodeMapping.size(); ++i)
415 {
416 const NodeID mapsTo = nodeMapping.at(i);
417 if (mapsTo >= reverseNodeMapping.size()) reverseNodeMapping.resize(mapsTo + 1, UINT_MAX);
418 reverseNodeMapping.at(mapsTo) = i;
419 }
420
421 return reverseNodeMapping;
422}
423
424size_t NodeIDAllocator::Clusterer::condensedIndex(size_t n, size_t i, size_t j)
425{
426 // From https://stackoverflow.com/a/14839010
427 return n*(n-1)/2 - (n-i)*(n-i-1)/2 + j - i - 1;
428}
429
431{
432 return requiredBits(pts.count());
433}
434
436{
437 if (n == 0) return 0;
438 // Ceiling of number of bits amongst each native integer gives needed native ints,
439 // so we then multiply again by the number of bits in each native int.
440 return ((n - 1) / NATIVE_INT_SIZE + 1) * NATIVE_INT_SIZE;
441}
442
443double *NodeIDAllocator::Clusterer::getDistanceMatrix(const std::vector<std::pair<const PointsTo *, unsigned>> pointsToSets,
444 const size_t numObjects, const Map<NodeID, unsigned> &nodeMap,
445 double &distanceMatrixTime)
446{
447 const double clkStart = PTAStat::getClk(true);
448 size_t condensedSize = (numObjects * (numObjects - 1)) / 2;
449 double *distMatrix = new double[condensedSize];
450 for (size_t i = 0; i < condensedSize; ++i) distMatrix[i] = numObjects * numObjects;
451
452 // TODO: maybe use machine epsilon?
453 // For reducing distance due to extra occurrences.
454 // Can differentiate ~9999 occurrences.
455 double occurrenceEpsilon = 0.0001;
456
457 for (const std::pair<const PointsTo *, unsigned> &ptsOcc : pointsToSets)
458 {
459 const PointsTo *pts = ptsOcc.first;
460 assert(pts != nullptr);
461 const unsigned occ = ptsOcc.second;
462
463 // Distance between each element of pts.
464 unsigned distance = requiredBits(*pts) / NATIVE_INT_SIZE;
465
466 // Use a vector so we can index into pts.
467 std::vector<NodeID> ptsVec;
468 for (const NodeID o : *pts) ptsVec.push_back(o);
469 for (size_t i = 0; i < ptsVec.size(); ++i)
470 {
471 const NodeID oi = ptsVec[i];
473 assert(moi != nodeMap.end());
474 for (size_t j = i + 1; j < ptsVec.size(); ++j)
475 {
476 const NodeID oj = ptsVec[j];
478 assert(moj != nodeMap.end());
479 double &existingDistance = distMatrix[condensedIndex(numObjects, moi->second, moj->second)];
480
481 // Subtract extra occurrenceEpsilon to make upcoming logic simpler.
482 // When existingDistance is never whole, it is always between two distances.
484
485 if (distance == std::ceil(existingDistance))
486 {
487 // We have something like distance == x, existingDistance == x - e, for some e < 1
488 // (potentially even set during this iteration).
489 // So, the new distance is an occurrence the existingDistance being tracked, it just
490 // had some reductions because of multiple occurrences.
491 // If there is not room within this distance to reduce more (increase priority),
492 // just ignore it. TODO: maybe warn?
494 {
496 }
497 else
498 {
499 // Reached minimum.
501 }
502 }
503 }
504 }
505
506 }
507
508 const double clkEnd = PTAStat::getClk(true);
510
511 return distMatrix;
512}
513
514void NodeIDAllocator::Clusterer::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)
515{
516 if (visited.find(index) != visited.end()) return;
517 visited.insert(index);
518
519 int left = dendrogram[index - 1];
520 if (left < 0)
521 {
522 // Reached a leaf.
523 // -1 because the items start from 1 per fastcluster (TODO).
524 nodeMap[regionNodeMap[std::abs(left) - 1]] = allocCounter;
525 ++allocCounter;
526 }
527 else
528 {
529 traverseDendrogram(nodeMap, dendrogram, numObjects, allocCounter, visited, left, regionNodeMap);
530 }
531
532 // Repeat for the right child.
533 int right = dendrogram[(numObjects - 1) + index - 1];
534 if (right < 0)
535 {
536 nodeMap[regionNodeMap[std::abs(right) - 1]] = allocCounter;
537 ++allocCounter;
538 }
539 else
540 {
541 traverseDendrogram(nodeMap, dendrogram, numObjects, allocCounter, visited, right, regionNodeMap);
542 }
543}
544
545std::vector<NodeID> NodeIDAllocator::Clusterer::regionObjects(const Map<NodeID, Set<NodeID>> &graph, size_t numObjects, size_t &numLabels)
546{
547 unsigned label = UINT_MAX;
548 std::vector<NodeID> labels(numObjects, UINT_MAX);
550 for (const Map<NodeID, Set<NodeID>>::value_type &oos : graph)
551 {
552 const NodeID o = oos.first;
553 if (labels[o] != UINT_MAX) continue;
554 std::queue<NodeID> bfsQueue;
555 bfsQueue.push(o);
556 ++label;
557 while (!bfsQueue.empty())
558 {
559 const NodeID o = bfsQueue.front();
560 bfsQueue.pop();
561 if (labels[o] != UINT_MAX)
562 {
563 assert(labels[o] == label);
564 continue;
565 }
566
567 labels[o] = label;
568 Map<NodeID, Set<NodeID>>::const_iterator neighboursIt = graph.find(o);
569 assert(neighboursIt != graph.end());
570 for (const NodeID neighbour : neighboursIt->second) bfsQueue.push(neighbour);
571 }
572 }
573
574 // The remaining objects have no relation with others: they get their own label.
575 for (size_t o = 0; o < numObjects; ++o)
576 {
577 if (labels[o] == UINT_MAX) labels[o] = ++label;
578 }
579
580 numLabels = label + 1;
581
582 return labels;
583}
584
586{
590 u64_t totalNewSbv = 0;
591 u64_t totalNewBv = 0;
592
594 {
595 const PointsTo &pts = ptsOcc.first;
596 const unsigned occ = ptsOcc.second;
597 if (pts.count() == 0) continue;
598
599 u64_t theoretical = requiredBits(pts) / NATIVE_INT_SIZE;
601
602 // Check number of words for original SBV.
603 Set<unsigned> words;
604 // TODO: nasty hardcoding.
605 for (const NodeID o : pts) words.insert(o / 128);
606 u64_t originalSbv = words.size() * 2;
608
609 // Check number of words for original BV.
610 NodeID min = UINT_MAX;
611 NodeID max = 0;
612 for (NodeID o : pts)
613 {
614 if (o < min) min = o;
615 if (o > max) max = o;
616 }
617 words.clear();
618 for (NodeID b = min; b <= max; ++b)
619 {
620 words.insert(b / NATIVE_INT_SIZE);
621 }
622 u64_t originalBv = words.size();
624
625 // Check number of words for new SBV.
626 words.clear();
627 // TODO: nasty hardcoding.
628 for (const NodeID o : pts) words.insert(nodeMap[o] / 128);
629 u64_t newSbv = words.size() * 2;
630 if (accountForOcc) newSbv *= occ;
631
632 // Check number of words for new BV.
633 min = UINT_MAX;
634 max = 0;
635 for (const NodeID o : pts)
636 {
637 const NodeID mappedO = nodeMap[o];
638 if (mappedO < min) min = mappedO;
639 if (mappedO > max) max = mappedO;
640 }
641
642 words.clear();
643 // No nodeMap[b] because min and max and from nodeMap.
644 for (NodeID b = min; b <= max; ++b) words.insert(b / NATIVE_INT_SIZE);
645 u64_t newBv = words.size();
646 if (accountForOcc) newBv *= occ;
647
652 totalNewBv += newBv;
653 }
654
655 stats[TheoreticalNumWords] = std::to_string(totalTheoretical);
656 stats[OriginalSbvNumWords] = std::to_string(totalOriginalSbv);
657 stats[OriginalBvNumWords] = std::to_string(totalOriginalBv);
658 stats[NewSbvNumWords] = std::to_string(totalNewSbv);
659 stats[NewBvNumWords] = std::to_string(totalNewBv);
660}
661
662// Work out which of the mappings we generated looks best.
663std::pair<hclust_fast_methods, std::vector<NodeID>> NodeIDAllocator::Clusterer::determineBestMapping(
664 const std::vector<std::pair<hclust_fast_methods, std::vector<NodeID>>> &candidates,
666 const std::string &evalSubtitle,
667 double &evalTime,
668 bool printStat
669 )
670{
671 // In case we're not comparing anything, set to first "candidate".
672 std::pair<hclust_fast_methods, std::vector<NodeID>> bestMapping = candidates[0];
673 // Number of bits required for the best candidate.
674 size_t bestWords = std::numeric_limits<size_t>::max();
676 {
677 for (const std::pair<hclust_fast_methods, std::vector<NodeID>> &candidate : candidates)
678 {
682 std::vector<NodeID> candidateMapping = candidate.second;
683
684 // TODO: parameterise final arg.
685 const double clkStart = PTAStat::getClk(true);
687 const double clkEnd = PTAStat::getClk(true);
689 if (printStat)
690 {
691 printStats(evalSubtitle + ": candidate " + candidateMethodName, candidateStats);
692 }
693
694 size_t candidateWords = 0;
695 if (Options::PtType() == PointsTo::SBV) candidateWords = std::stoull(candidateStats[NewSbvNumWords]);
696 else if (Options::PtType() == PointsTo::CBV) candidateWords = std::stoull(candidateStats[NewBvNumWords]);
697 else assert(false && "Clusterer::cluster: unsupported BV type for clustering.");
698
700 {
703 }
704 }
705 }
706
707 return bestMapping;
708}
709
711{
712 // When not in order, it is too hard to compare original/new SBV/BV words, so this array forces an order.
713 static const std::string statKeys[] =
714 {
715 NumObjects, TheoreticalNumWords, OriginalSbvNumWords, OriginalBvNumWords,
716 NewSbvNumWords, NewBvNumWords, NumRegions, NumGtIntRegions,
717 NumNonTrivialRegionObjects, LargestRegion, RegioningTime,
718 DistanceMatrixTime, FastClusterTime, DendrogramTraversalTime,
719 EvalTime, TotalTime, BestCandidate
720 };
721
722 const unsigned fieldWidth = 20;
723 SVFUtil::outs().flags(std::ios::left);
724 SVFUtil::outs() << "****Clusterer Statistics: " << subtitle << "****\n";
725 for (const std::string& statKey : statKeys)
726 {
728 if (stat != stats.end())
729 {
730 SVFUtil::outs() << std::setw(fieldWidth) << statKey << " " << stat->second << "\n";
731 }
732 }
733
734 SVFUtil::outs().flush();
735}
736
737}; // namespace SVF.
#define TIMEINTERVAL
Definition SVFType.h:604
#define NATIVE_INT_SIZE
Size of native integer that we'll use for bit vectors, in bits.
Definition SVFType.h:608
buffer offset
Definition cJSON.cpp:1113
cJSON * n
Definition cJSON.cpp:2558
const cJSON *const b
Definition cJSON.h:255
int index
Definition cJSON.h:170
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 > &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
@ 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.
static void unset(void)
Deletes the (singleton) allocator.
Carries around command line options.
Definition Options.h:16
static const OptionMap< SVF::NodeIDAllocator::Strategy > NodeAllocStrat
Definition Options.h:31
static const OptionMap< PointsTo::Type > PtType
Type of points-to set to use for all analyses.
Definition Options.h:46
static const Option< bool > RegionAlign
Align identifiers in each region to a word.
Definition Options.h:58
static const Option< bool > RegionedClustering
Cluster partitions separately.
Definition Options.h:55
static const OptionMap< u32_t > ClusterMethod
Definition Options.h:52
bool empty() const
Returns true if set is empty.
Definition PointsTo.cpp:98
void clear()
Empty the set.
Definition PointsTo.cpp:123
const_iterator begin() const
Definition PointsTo.h:129
static double getClk(bool mark=false)
Definition SVFStat.cpp:51
hclust_fast_methods
Definition fastcluster.h:66
@ HCLUST_METHOD_AVERAGE
Definition fastcluster.h:72
@ HCLUST_METHOD_COMPLETE
Definition fastcluster.h:70
@ HCLUST_METHOD_SVF_BEST
Definition fastcluster.h:76
@ HCLUST_METHOD_SINGLE
Definition fastcluster.h:68
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.
Definition SVFUtil.cpp:252
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
for isBitcode
Definition BasicTypes.h:70
unsigned long long u64_t
Definition GeneralType.h:69
u32_t NodeID
Definition GeneralType.h:76
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition GeneralType.h:56
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
unsigned u32_t
Definition GeneralType.h:67