Skip to content

Commit

Permalink
unified writing for phi and load, add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jumormt committed Nov 29, 2023
1 parent c6749de commit 37debb6
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,41 +759,34 @@ void SVFIR2ItvExeState::translateLoad(const LoadStmt *load)
{
VAddrs &addrs = getVAddrs(rhs);
assert(!addrs.empty());
for (const auto &addr: addrs)
{
u32_t objId = getInternalID(addr);
if (inLocToIValTable(objId))
_es[lhs] = IntervalValue::bottom();
else if (inLocToAddrsTable(objId))
_es.getVAddrs(lhs).setBottom();
break;
}
IntervalValue rhsItv = IntervalValue::bottom();
AddressValue rhsAddr;
bool isItv = false, isAddr = false;
for (const auto &addr: addrs)
{
u32_t objId = getInternalID(addr);
if (inLocToIValTable(objId))
{
if (!inVarToIValTable(lhs))
{
_es[lhs] = _es.load(addr);
}
else
{
_es[lhs].join_with(_es.load(addr));
}
rhsItv.join_with(_es.load(addr));
isItv = true;
}
else if (inLocToAddrsTable(objId))
{
if (!inVarToAddrsTable(lhs))
{
_es.getVAddrs(lhs) = _es.loadVAddrs(addr);
}
else
{
_es.getVAddrs(lhs).join_with(_es.loadVAddrs(addr));
}
rhsAddr.join_with(_es.loadVAddrs(addr));
isAddr = true;
} else {
// rhs not in table
}
}
if (isItv) {
// lhs var is an integer
_es[lhs] = rhsItv;
} else if (isAddr) {
// lhs var is an address
_es.getVAddrs(lhs) = rhsAddr;
} else {
// rhs not in table
}
}
}

Expand Down Expand Up @@ -911,30 +904,34 @@ void SVFIR2ItvExeState::translateSelect(const SelectStmt *select)
void SVFIR2ItvExeState::translatePhi(const PhiStmt *phi)
{
u32_t res = phi->getResID();
IntervalValue itv = IntervalValue::bottom();
AddressValue addr;
IntervalValue rhsItv = IntervalValue::bottom();
AddressValue rhsAddr;
bool isItv = false, isAddr = false;
for (u32_t i = 0; i < phi->getOpVarNum(); i++)
{
NodeID curId = phi->getOpVarID(i);
if (inVarToIValTable(curId))
{
itv.join_with(_es[curId]);
rhsItv.join_with(_es[curId]);
isItv = true;
}
else if (inVarToAddrsTable(curId))
{
assert(!getVAddrs(curId).empty());
addr.join_with(getVAddrs(curId));
rhsAddr.join_with(getVAddrs(curId));
isAddr = true;
} else {
// rhs not in the table
}
}
if(isItv) _es[res] = itv;
else if(isAddr) _es.getVAddrs(res) = addr;
else {
// rhs not in the table
if (isItv) {
// res var is an integer
_es[res] = rhsItv;
} else if (isAddr) {
// res var is an address
_es.getVAddrs(res) = rhsAddr;
} else {
// rhs not in table
}
}

Expand Down

0 comments on commit 37debb6

Please sign in to comment.