35using namespace SVFUtil;
39 return *
this ==
other;
48 h ^=
hf(t.first) + 0x9e3779b9 + (
h << 6) + (
h >> 2);
53 h2 ^=
hf(t.first) + 0x9e3779b9 + (
h2 << 6) + (
h2 >> 2);
63 for (
auto it =
es._varToAbsVal.begin();
it !=
es._varToAbsVal.end(); ++
it)
67 if (
it->second.isInterval() &&
other._varToAbsVal.at(
key).isInterval())
68 it->second.getInterval().widen_with(
other._varToAbsVal.at(
key).getInterval());
70 for (
auto it =
es._addrToAbsVal.begin();
it !=
es._addrToAbsVal.end(); ++
it)
73 if (
other._addrToAbsVal.find(
key) !=
other._addrToAbsVal.end())
74 if (
it->second.isInterval() &&
other._addrToAbsVal.at(
key).isInterval())
75 it->second.getInterval().widen_with(
other._addrToAbsVal.at(
key).getInterval());
83 for (
auto it =
es._varToAbsVal.begin();
it !=
es._varToAbsVal.end(); ++
it)
87 if (
it->second.isInterval() &&
other._varToAbsVal.at(
key).isInterval())
88 it->second.getInterval().narrow_with(
other._varToAbsVal.at(
key).getInterval());
90 for (
auto it =
es._addrToAbsVal.begin();
it !=
es._addrToAbsVal.end(); ++
it)
93 if (
other._addrToAbsVal.find(
key) !=
other._addrToAbsVal.end())
94 if (
it->second.isInterval() &&
other._addrToAbsVal.at(
key).isInterval())
95 it->second.getInterval().narrow_with(
other._addrToAbsVal.at(
key).getInterval());
104 for (
auto it =
other._varToAbsVal.begin();
it !=
other._varToAbsVal.end(); ++
it)
106 auto key =
it->first;
110 oit->second.join_with(
it->second);
117 for (
auto it =
other._addrToAbsVal.begin();
it !=
other._addrToAbsVal.end(); ++
it)
119 auto key =
it->first;
123 oit->second.join_with(
it->second);
135 for (
auto it =
other._varToAbsVal.begin();
it !=
other._varToAbsVal.end(); ++
it)
137 auto key =
it->first;
141 oit->second.meet_with(
it->second);
144 for (
auto it =
other._addrToAbsVal.begin();
it !=
other._addrToAbsVal.end(); ++
it)
146 auto key =
it->first;
150 oit->second.meet_with(
it->second);
188 if (
obj->isConstDataOrConstGlobal() ||
obj->isConstantArray() ||
obj->isConstantStruct())
199 else if (SVFUtil::isa<ConstantNullPtrObjVar>(
objVar))
203 else if (SVFUtil::isa<GlobalObjVar>(
objVar))
207 else if (
obj->isConstantArray() ||
obj->isConstantStruct())
228 if (
gep->isConstantOffset())
233 for (
int i =
gep->getOffsetVarAndGepTypePairVec().size() - 1;
i >= 0;
i--)
236 const SVFVar*
var =
gep->getOffsetVarAndGepTypePairVec()[
i].first;
259 if (SVFUtil::isa<SVFPointerType>(
type))
261 u32_t elemNum =
gep->getAccessPath().getElementNum(
gep->getAccessPath().gepSrcPointeeType());
301 if (
gep->isConstantOffset())
307 for (
int i =
gep->getOffsetVarAndGepTypePairVec().size() - 1;
i >= 0;
i--)
319 elemByteSize =
gep->getAccessPath().gepSrcPointeeType()->getByteSize();
321 assert(
false &&
"idxOperandType must be ArrType or PtrType");
359 assert(
false &&
"gep type pair only support arr/ptr/struct");
368 for (
auto addr : (*this)[
varId].getAddrs())
377 for (
auto addr : (*this)[
varId].getAddrs())
391 return a.first < b.first;
396 if (
item.second.isInterval())
400 else if (
item.second.isAddr())
404 for (
const auto&
addr:
item.second.getAddrs())
407 if (
i <
item.second.getAddrs().size())
427 return a.first < b.first;
432 std::ostringstream
oss;
435 if (
item.second.isInterval())
439 else if (
item.second.isAddr())
443 for (
const auto&
addr:
item.second.getAddrs())
446 if (
i <
item.second.getAddrs().size())
462 SVFUtil::outs() <<
"-----------------------------------------\n";
476 return SVFUtil::dyn_cast<ObjVar>(svfir->
getGNode(
addr_id))->getMemObj()->getType();
492 if (
objvar->getMemObj()->isConstantByteSize())
500 const std::vector<SVFValue*>&
sizes =
addr->getArrSize();
517 assert (
false &&
"Addr rhs value is not ObjVar");
const AddrToAbsValMap & getLocToVal() const
get loc2val map
u32_t getAllocaInstByteSize(const AddrStmt *addr)
const VarToAbsValMap & getVarToVal() const
get var2val map
void store(u32_t addr, const AbstractValue &val)
void printAbstractState() const
void joinWith(const AbstractState &other)
domain join with other, important! other widen this.
IntervalValue getElementIndex(const GepStmt *gep)
bool equals(const AbstractState &other) const
VarToAbsValMap _varToAbsVal
Map a variable (symbol) to its abstract value.
AddrToAbsValMap _addrToAbsVal
Map a memory address to its stored abstract value.
const SVFType * getPointeeElement(NodeID id)
virtual AbstractValue & load(u32_t addr)
IntervalValue getByteOffset(const GepStmt *gep)
AbstractValue loadValue(NodeID varId)
bool inVarToAddrsTable(u32_t id) const
whether the variable is in varToAddrs table
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.
AbstractState narrowing(const AbstractState &other)
domain narrow with other, and return the narrowed domain
static u32_t getInternalID(u32_t idx)
Return the internal index if idx is an address otherwise return the value of idx.
virtual bool inVarToValTable(u32_t id) const
whether the variable is in varToVal table
void storeValue(NodeID varId, AbstractValue val)
void meetWith(const AbstractState &other)
domain meet with other, important! other widen this.
AddressValue getGepObjAddrs(u32_t pointer, IntervalValue offset)
void initObjVar(ObjVar *objVar)
AbstractState widening(const AbstractState &other)
domain widen with other, and return the widened domain
void join_with(const AbstractValue &other)
AddressValue & getAddrs()
std::pair< const SVFVar *, const SVFType * > IdxOperandPair
s64_t getIntNumeral() const
NodeType * getGNode(NodeID id) const
Get a node.
NodeID getValueNode(const SVFValue *V)
void meet_with(const IntervalValue &other)
Return a intersected IntervalValue.
const BoundedInt & ub() const
Return the upper bound.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
const BoundedInt & lb() const
Return the lower bound.
static const Option< bool > ModelArrays
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
u32_t getByteSize() const
std::vector< u32_t > & getFlattenedElemIdxVec()
u32_t getFlattenedElemIdx(const SVFType *T, u32_t origId)
Flattened element idx of an array or struct by considering stride.
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis.
const StInfo * getTypeInfo(const SVFType *T) const
Get struct info.
std::ostream & outs()
Overwrite llvm::outs()
llvm::IRBuilder IRBuilder