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::~PointsTo: unknown type");
78 else assert(
false &&
"PointsTo::PointsTo=&: unknown type");
87 this->nodeMapping =
rhs.nodeMapping;
88 this->reverseNodeMapping =
rhs.reverseNodeMapping;
93 else assert(
false &&
"PointsTo::PointsTo=&&: unknown type");
105 assert(
false &&
"PointsTo::empty: unknown type");
118 assert(
false &&
"PointsTo::count: unknown type");
128 else assert(
false &&
"PointsTo::clear: unknown type");
139 assert(
false &&
"PointsTo::test: unknown type");
152 assert(
false &&
"PointsTo::test_and_set: unknown type");
163 else assert(
false &&
"PointsTo::set: unknown type");
172 else assert(
false &&
"PointsTo::reset: unknown type");
177 assert(
metaSame(
rhs) &&
"PointsTo::contains: mappings of operands do not match!");
184 assert(
false &&
"PointsTo::contains: unknown type");
191 assert(
metaSame(
rhs) &&
"PointsTo::intersects: mappings of operands do not match!");
198 assert(
false &&
"PointsTo::intersects: unknown type");
205 if (
count() == 0)
return -1;
218 assert(
false &&
"PointsTo::==: unknown type");
228 return !(*
this ==
rhs);
240 assert(
false &&
"PointsTo::|=: unknown type");
267 assert(
false &&
"PointsTo::&=: unknown type");
281 assert(
false &&
"PointsTo::-=: unknown type");
288 assert(
metaSame(
rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
294 assert(
false &&
"PointsTo::intersectWithComplement(PT): unknown type");
300 assert(
metaSame(
rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
301 assert(
metaSame(
lhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
308 assert(
false &&
"PointsTo::intersectWithComplement(PT, PT): unknown type");
325 std::hash<SparseBitVector<>>
h;
332 assert(
false &&
"PointsTo::hash: unknown type");
385 *
this = std::move(
newPt);
392 if (
pt->
type == Type::CBV)
396 else if (
pt->
type == Type::SBV)
400 else if (
pt->
type == Type::BV)
406 assert(
false &&
"PointsToIterator::PointsToIterator: unknown type");
414 if (this->pt->type == PointsTo::Type::SBV)
418 else if (this->pt->type == PointsTo::Type::CBV)
422 else if (this->pt->type == PointsTo::Type::BV)
428 assert(
false &&
"PointsToIterator::PointsToIterator&: unknown type");
436 if (this->pt->type == PointsTo::Type::SBV)
440 else if (this->pt->type == PointsTo::Type::CBV)
444 else if (this->pt->type == PointsTo::Type::BV)
450 assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
459 if (this->pt->type == PointsTo::Type::SBV)
463 else if (this->pt->type == PointsTo::Type::CBV)
467 else if (this->pt->type == PointsTo::Type::BV)
471 else assert(
false &&
"PointsToIterator::PointsToIterator&: unknown type");
480 if (this->pt->type == PointsTo::Type::SBV)
484 else if (this->pt->type == PointsTo::Type::CBV)
488 else if (this->pt->type == PointsTo::Type::BV)
492 else assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
499 assert(!atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
500 if (pt->type == Type::CBV) ++cbvIt;
501 else if (pt->type == Type::SBV) ++sbvIt;
502 else if (pt->type == Type::BV) ++bvIt;
503 else assert(
false &&
"PointsToIterator::++(void): unknown type");
510 assert(!atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
518 assert(!atEnd() &&
"PointsToIterator: dereferencing end!");
519 if (pt->type == Type::CBV)
return pt->getExternalNode(*cbvIt);
520 else if (pt->type == Type::SBV)
return pt->getExternalNode(*sbvIt);
521 else if (pt->type == Type::BV)
return pt->getExternalNode(*bvIt);
524 assert(
false &&
"PointsToIterator::*: unknown type");
532 &&
"PointsToIterator::==: comparing iterators from different PointsTos!");
535 if (pt->type == Type::CBV)
return cbvIt ==
rhs.cbvIt;
536 else if (pt->type == Type::SBV)
return sbvIt ==
rhs.sbvIt;
537 else if (pt->type == Type::BV)
return bvIt ==
rhs.bvIt;
540 assert(
false &&
"PointsToIterator::==: unknown type");
548 &&
"PointsToIterator::!=: comparing iterators from different PointsTos!");
549 return !(*
this ==
rhs);
554 assert(pt !=
nullptr &&
"PointsToIterator::atEnd: iterator iterating over nothing!");
555 if (pt->type == Type::CBV)
return cbvIt == pt->cbv.end();
556 else if (pt->type == Type::SBV)
return sbvIt == pt->sbv.end();
557 else if (pt->type == Type::BV)
return bvIt == pt->bv.end();
560 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.