26 :
type(
Options::PtType()), nodeMapping(currentBestNodeMapping),
27 reverseNodeMapping(currentBestReverseNodeMapping)
32 else assert(
false &&
"PointsTo::PointsTo: unknown type");
36 :
type(pt.
type), nodeMapping(pt.nodeMapping),
37 reverseNodeMapping(pt.reverseNodeMapping)
42 else assert(
false &&
"PointsTo::PointsTo&: unknown type");
46noexcept :
type(pt.type), nodeMapping(std::move(pt.nodeMapping)),
47 reverseNodeMapping(std::move(pt.reverseNodeMapping))
52 else assert(
false &&
"PointsTo::PointsTo&&: unknown type");
59 else if (
type ==
BV)
bv.~BitVector();
60 else assert(
false &&
"PointsTo::destroyBacking: unknown type");
87 else assert(
false &&
"PointsTo::PointsTo=&: unknown type");
100 this->nodeMapping =
rhs.nodeMapping;
101 this->reverseNodeMapping =
rhs.reverseNodeMapping;
105 else assert(
false &&
"PointsTo::PointsTo=&&: unknown type");
117 assert(
false &&
"PointsTo::empty: unknown type");
130 assert(
false &&
"PointsTo::count: unknown type");
140 else assert(
false &&
"PointsTo::clear: unknown type");
151 assert(
false &&
"PointsTo::test: unknown type");
164 assert(
false &&
"PointsTo::test_and_set: unknown type");
175 else assert(
false &&
"PointsTo::set: unknown type");
184 else assert(
false &&
"PointsTo::reset: unknown type");
189 assert(
metaSame(
rhs) &&
"PointsTo::contains: mappings of operands do not match!");
196 assert(
false &&
"PointsTo::contains: unknown type");
203 assert(
metaSame(
rhs) &&
"PointsTo::intersects: mappings of operands do not match!");
210 assert(
false &&
"PointsTo::intersects: unknown type");
217 if (
count() == 0)
return -1;
230 assert(
false &&
"PointsTo::==: unknown type");
240 return !(*
this ==
rhs);
252 assert(
false &&
"PointsTo::|=: unknown type");
279 assert(
false &&
"PointsTo::&=: unknown type");
293 assert(
false &&
"PointsTo::-=: unknown type");
300 assert(
metaSame(
rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
306 assert(
false &&
"PointsTo::intersectWithComplement(PT): unknown type");
312 assert(
metaSame(
rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
313 assert(
metaSame(
lhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
320 assert(
false &&
"PointsTo::intersectWithComplement(PT, PT): unknown type");
337 std::hash<SparseBitVector<>>
h;
344 assert(
false &&
"PointsTo::hash: unknown type");
397 *
this = std::move(
newPt);
404 if (
pt->
type == Type::CBV)
408 else if (
pt->
type == Type::SBV)
412 else if (
pt->
type == Type::BV)
418 assert(
false &&
"PointsToIterator::PointsToIterator: unknown type");
426 if (this->pt->type == PointsTo::Type::SBV)
430 else if (this->pt->type == PointsTo::Type::CBV)
434 else if (this->pt->type == PointsTo::Type::BV)
440 assert(
false &&
"PointsToIterator::PointsToIterator&: unknown type");
448 if (this->pt->type == PointsTo::Type::SBV)
452 else if (this->pt->type == PointsTo::Type::CBV)
456 else if (this->pt->type == PointsTo::Type::BV)
462 assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
471 if (this->pt->type == PointsTo::Type::SBV)
475 else if (this->pt->type == PointsTo::Type::CBV)
479 else if (this->pt->type == PointsTo::Type::BV)
483 else assert(
false &&
"PointsToIterator::PointsToIterator&: unknown type");
492 if (this->pt->type == PointsTo::Type::SBV)
496 else if (this->pt->type == PointsTo::Type::CBV)
500 else if (this->pt->type == PointsTo::Type::BV)
504 else assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
511 assert(!atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
512 if (pt->type == Type::CBV) ++cbvIt;
513 else if (pt->type == Type::SBV) ++sbvIt;
514 else if (pt->type == Type::BV) ++bvIt;
515 else assert(
false &&
"PointsToIterator::++(void): unknown type");
522 assert(!atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
530 assert(!atEnd() &&
"PointsToIterator: dereferencing end!");
531 if (pt->type == Type::CBV)
return pt->getExternalNode(*cbvIt);
532 else if (pt->type == Type::SBV)
return pt->getExternalNode(*sbvIt);
533 else if (pt->type == Type::BV)
return pt->getExternalNode(*bvIt);
536 assert(
false &&
"PointsToIterator::*: unknown type");
544 &&
"PointsToIterator::==: comparing iterators from different PointsTos!");
547 if (pt->type == Type::CBV)
return cbvIt ==
rhs.cbvIt;
548 else if (pt->type == Type::SBV)
return sbvIt ==
rhs.sbvIt;
549 else if (pt->type == Type::BV)
return bvIt ==
rhs.bvIt;
552 assert(
false &&
"PointsToIterator::==: unknown type");
560 &&
"PointsToIterator::!=: comparing iterators from different PointsTos!");
561 return !(*
this ==
rhs);
566 assert(pt !=
nullptr &&
"PointsToIterator::atEnd: iterator iterating over nothing!");
567 if (pt->type == Type::CBV)
return cbvIt == pt->cbv.end();
568 else if (pt->type == Type::SBV)
return sbvIt == pt->sbv.end();
569 else if (pt->type == Type::BV)
return bvIt == pt->bv.end();
572 assert(
false &&
"PointsToIterator::atEnd: unknown type");
bool intersects(const CoreBitVector &rhs) const
Returns true if this CBV and rhs share any set bits.
void clear(void)
Empty the CBV.
bool test_and_set(u32_t bit)
void reset(u32_t bit)
Resets bit in the CBV.
void set(u32_t bit)
Sets bit in the CBV.
bool test(u32_t bit) const
Returns true if bit is set in this CBV.
const_iterator begin(void) const
bool intersectWithComplement(const CoreBitVector &rhs)
const_iterator end(void) const
bool empty(void) const
Returns true if no bits are set.
u32_t count(void) const
Returns number of bits set.
bool contains(const CoreBitVector &rhs) const
Returns true if this CBV is a superset of rhs.
size_t hash(void) const
Hash for this CBV.
Carries around command line options.
u32_t operator*() const
Dereference: *it.
CoreBitVector::iterator cbvIt
SparseBitVector ::iterator sbvIt
const PointsTo * pt
PointsTo we are iterating over.
bool operator!=(const PointsToIterator &rhs) const
Inequality: *this != rhs.
PointsToIterator()=delete
Deleted because we don't want iterators with null pt.
const PointsToIterator & operator++()
Pre-increment: ++it.
PointsToIterator & operator=(const PointsToIterator &rhs)
bool operator==(const PointsToIterator &rhs) const
Equality: *this == rhs.
bool test_and_set(u32_t n)
bool empty() const
Returns true if set is empty.
void clear()
Empty the set.
static MappingPtr getCurrentBestReverseNodeMapping()
MappingPtr reverseNodeMapping
Internal nodes -> external nodes.
void reset(u32_t n)
Removes n from the set.
bool operator-=(const PointsTo &rhs)
PointsTo & operator=(const PointsTo &rhs)
Copy assignment.
size_t hash() const
Return a hash of this set.
bool operator&=(const PointsTo &rhs)
static MappingPtr currentBestReverseNodeMapping
Likewise, but reversed.
MappingPtr getNodeMapping() const
BitVector bv
Bit vector backing.
bool operator==(const PointsTo &rhs) const
Returns true if this set and rhs contain exactly the same elements.
const_iterator end() const
CoreBitVector cbv
Core bit vector backing.
NodeID getExternalNode(NodeID n) const
Returns reverseNodeMapping[n], checking for nullptr and size.
std::shared_ptr< std::vector< NodeID > > MappingPtr
static void setCurrentBestNodeMapping(MappingPtr newCurrentBestNodeMapping, MappingPtr newCurrentBestReverseNodeMapping)
bool operator!=(const PointsTo &rhs) const
Returns true if either this set or rhs has an element not in the other.
static MappingPtr currentBestNodeMapping
Best node mapping we know of the for the analyses at hand.
u32_t count() const
Returns number of elements.
bool metaSame(const PointsTo &pt) const
bool operator|=(const PointsTo &rhs)
enum Type type
Type of this points-to set.
void set(u32_t n)
Inserts n in the set.
bool contains(const PointsTo &rhs) const
Returns true if this set is a superset of rhs.
PointsTo()
Construct empty points-to set.
MappingPtr nodeMapping
External nodes -> internal nodes.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
const_iterator begin() const
bool intersects(const PointsTo &rhs) const
Returns true if this set and rhs share any elements.
static MappingPtr getCurrentBestNodeMapping()
SparseBitVector sbv
Sparse bit vector backing.
NodeID getInternalNode(NodeID n) const
Returns nodeMapping[n], checking for nullptr and size.
bool test(u32_t n) const
Returns true if n is in this set.
bool intersectWithComplement(const PointsTo &rhs)
bool test(unsigned Idx) const
bool intersects(const SparseBitVector< ElementSize > *RHS) const
bool test_and_set(unsigned Idx)
bool intersectWithComplement(const SparseBitVector &RHS)
bool contains(const SparseBitVector< ElementSize > &RHS) const
IntervalValue operator-(const IntervalValue &lhs, const IntervalValue &rhs)
Subtract IntervalValues.
IntervalValue operator&(const IntervalValue &lhs, const IntervalValue &rhs)
Bitwise AND of IntervalValues.
llvm::IRBuilder IRBuilder
IntervalValue operator|(const IntervalValue &lhs, const IntervalValue &rhs)
Bitwise OR of IntervalValues.