From c6749de4d1e7fe7998206fe8451beb5fb2b48525 Mon Sep 17 00:00:00 2001 From: jumormt Date: Wed, 29 Nov 2023 06:50:41 +0000 Subject: [PATCH 1/2] strong update for translating phi --- .../AbstractExecution/SVFIR2ItvExeState.cpp | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp index 9481abc0a..73713f4b4 100644 --- a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +++ b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp @@ -911,35 +911,31 @@ void SVFIR2ItvExeState::translateSelect(const SelectStmt *select) void SVFIR2ItvExeState::translatePhi(const PhiStmt *phi) { u32_t res = phi->getResID(); + IntervalValue itv = IntervalValue::bottom(); + AddressValue addr; + bool isItv = false, isAddr = false; for (u32_t i = 0; i < phi->getOpVarNum(); i++) { NodeID curId = phi->getOpVarID(i); if (inVarToIValTable(curId)) { - const IntervalValue &cur = _es[curId]; - if (!inVarToIValTable(res)) - { - _es[res] = cur; - } - else - { - _es[res].join_with(cur); - } + itv.join_with(_es[curId]); + isItv = true; } else if (inVarToAddrsTable(curId)) { assert(!getVAddrs(curId).empty()); - const VAddrs &cur = getVAddrs(curId); - if (!inVarToAddrsTable(res)) - { - _es.getVAddrs(res) = cur; - } - else - { - _es.getVAddrs(res).join_with(cur); - } + addr.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 + } } From 37debb631cc29ce80480092c7209e6c27626b33c Mon Sep 17 00:00:00 2001 From: jumormt Date: Wed, 29 Nov 2023 10:53:46 +0000 Subject: [PATCH 2/2] unified writing for phi and load, add some comments --- .../AbstractExecution/SVFIR2ItvExeState.cpp | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp index 73713f4b4..327e842c4 100644 --- a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +++ b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp @@ -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 + } } } @@ -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 } }