Skip to content

Commit

Permalink
Merge pull request #1466 from bjjwwang/0524
Browse files Browse the repository at this point in the history
rename ICFGWTONode/Cycle
  • Loading branch information
yuleisui authored May 24, 2024
2 parents b7a671e + f76186b commit 442e106
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions svf/include/AE/Core/ICFGWTO.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace SVF
{

typedef WTOComponent<ICFG> ICFGWTOComp;
typedef WTONode<ICFG> ICFGWTONode;
typedef WTOCycle<ICFG> ICFGWTOCycle;
typedef WTONode<ICFG> ICFGSingletonWTO;
typedef WTOCycle<ICFG> ICFGCycleWTO;

class ICFGWTO : public WTO<ICFG>
{
Expand Down
8 changes: 4 additions & 4 deletions svf/include/AE/Svfexe/AbstractInterpretation.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ class AbstractInterpretation
bool isBranchFeasible(const IntraCFGEdge* intraEdge, AbstractState& as);

/**
* handle instructions in ICFGNode
* handle instructions in ICFGSingletonWTO
*
* @param block basic block that has a series of instructions
* @param block basic block that has one instruction or a series of instructions
*/
virtual void handleWTONode(const ICFGNode* node);
virtual void handleWTONode(const ICFGSingletonWTO *icfgSingletonWto);

/**
* handle one instruction in ICFGNode
Expand All @@ -182,7 +182,7 @@ class AbstractInterpretation
*
* @param cycle WTOCycle which has weak topo order of basic blocks and nested cycles
*/
virtual void handleCycle(const ICFGWTOCycle* cycle);
virtual void handleCycle(const ICFGCycleWTO* cycle);

/**
* handle user defined function, ext function is not included.
Expand Down
15 changes: 8 additions & 7 deletions svf/include/Graphs/WTO.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,21 @@ template <typename GraphT> class WTOCycle final : public WTOComponent<GraphT>

private:
/// Head of the cycle
const NodeT* _head;
const WTONode<GraphT>* _head;

/// List of components
WTOComponentRefList _components;

public:
/// Constructor
WTOCycle(const NodeT* head, WTOComponentRefList components)
WTOCycle(const WTONode<GraphT>* head, WTOComponentRefList components)
: WTOComponent<GraphT>(WTOComponent<GraphT>::Cycle), _head(head),
_components(std::move(components))
{
}

/// Return the head of the cycle
const NodeT* head() const
const WTONode<GraphT>* head() const
{
return _head;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ template <typename GraphT> class WTOCycle final : public WTOComponent<GraphT>
std::string str;
std::stringstream rawstr(str);
rawstr << "(";
rawstr << _head->getId() << ", ";
rawstr << _head->node()->getId() << ", ";
for (auto it = begin(), et = end(); it != et;)
{
rawstr << (*it)->toString();
Expand Down Expand Up @@ -687,7 +687,7 @@ template <typename GraphT> class WTO

void visit(const WTOCycleT& cycle) override
{
const NodeT* head = cycle.head();
const NodeT* head = cycle.head()->node();
WTOCycleDepthPtr previous_cycleDepth = _wtoCycleDepth;
_nodeToWTOCycleDepth.insert(std::make_pair(head, _wtoCycleDepth));
_wtoCycleDepth =
Expand Down Expand Up @@ -765,7 +765,7 @@ template <typename GraphT> class WTO
return ptr;
}

const WTOCycleT* newCycle(const NodeT* node,
const WTOCycleT* newCycle(const WTONodeT* node,
const WTOComponentRefList& partition)
{
const WTOCycleT* ptr = new WTOCycleT(node, std::move(partition));
Expand All @@ -784,7 +784,8 @@ template <typename GraphT> class WTO
visit(succ, partition);
}
});
const WTOCycleT* ptr = newCycle(node, partition);
const WTONodeT* head = newNode(node);
const WTOCycleT* ptr = newCycle(head, partition);
headRefToCycle.emplace(node, ptr);
return ptr;
}
Expand Down
33 changes: 16 additions & 17 deletions svf/lib/AE/Svfexe/AbstractInterpretation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ bool AbstractInterpretation::isBranchFeasible(const IntraCFGEdge* intraEdge,
return true;
}
/// handle instructions in svf basic blocks
void AbstractInterpretation::handleWTONode(const ICFGNode *node)
void AbstractInterpretation::handleWTONode(const ICFGSingletonWTO *icfgSingletonWto)
{
const ICFGNode* node = icfgSingletonWto->node();
_stat->getBlockTrace()++;
// Get execution states from in edges
if (!propagateStateIfFeasible(node))
Expand Down Expand Up @@ -690,30 +691,28 @@ void AbstractInterpretation::handleICFGNode(const ICFGNode *curICFGNode)
}

/// handle wto cycle (loop)
void AbstractInterpretation::handleCycle(const ICFGWTOCycle *cycle)
void AbstractInterpretation::handleCycle(const ICFGCycleWTO*cycle)
{
// Get execution states from in edges
if (!propagateStateIfFeasible(cycle->head()))
if (!propagateStateIfFeasible(cycle->head()->node()))
{
// No ES on the in edges - Infeasible block
return;
}
AbstractState pre_es = _preAbsTrace[cycle->head()];
AbstractState pre_es = _preAbsTrace[cycle->head()->node()];
// set -widen-delay
s32_t widen_delay = Options::WidenDelay();
bool incresing = true;
for (int i = 0; ; i++)
{
const ICFGNode* cycle_head = cycle->head();
// handle cycle head
handleWTONode(cycle_head);
handleWTONode(cycle->head());
if (i < widen_delay)
{
if (i> 0 && pre_es >= _postAbsTrace[cycle_head])
if (i> 0 && pre_es >= _postAbsTrace[cycle->head()->node()])
{
break;
}
pre_es = _postAbsTrace[cycle_head];
pre_es = _postAbsTrace[cycle->head()->node()];
}
else
{
Expand All @@ -722,7 +721,7 @@ void AbstractInterpretation::handleCycle(const ICFGWTOCycle *cycle)
if (incresing)
{
bool is_fixpoint =
isFixPointAfterWidening(cycle_head, pre_es);
isFixPointAfterWidening(cycle->head()->node(), pre_es);
if (is_fixpoint)
{
incresing = false;
Expand All @@ -732,7 +731,7 @@ void AbstractInterpretation::handleCycle(const ICFGWTOCycle *cycle)
else if (!incresing)
{
bool is_fixpoint =
isFixPointAfterNarrowing(cycle_head, pre_es);
isFixPointAfterNarrowing(cycle->head()->node(), pre_es);
if (is_fixpoint)
break;
}
Expand All @@ -741,11 +740,11 @@ void AbstractInterpretation::handleCycle(const ICFGWTOCycle *cycle)
for (auto it = cycle->begin(); it != cycle->end(); ++it)
{
const ICFGWTOComp* cur = *it;
if (const ICFGWTONode* vertex = SVFUtil::dyn_cast<ICFGWTONode>(cur))
if (const ICFGSingletonWTO* vertex = SVFUtil::dyn_cast<ICFGSingletonWTO>(cur))
{
handleWTONode(vertex->node());
handleWTONode(vertex);
}
else if (const ICFGWTOCycle* cycle2 = SVFUtil::dyn_cast<ICFGWTOCycle>(cur))
else if (const ICFGCycleWTO* cycle2 = SVFUtil::dyn_cast<ICFGCycleWTO>(cur))
{
handleCycle(cycle2);
}
Expand Down Expand Up @@ -813,11 +812,11 @@ void AbstractInterpretation::handleFunc(const SVFFunction *func)
for (auto it = wto->begin(); it!= wto->end(); ++it)
{
const ICFGWTOComp* cur = *it;
if (const ICFGWTONode* vertex = SVFUtil::dyn_cast<ICFGWTONode>(cur))
if (const ICFGSingletonWTO* vertex = SVFUtil::dyn_cast<ICFGSingletonWTO>(cur))
{
handleWTONode(vertex->node());
handleWTONode(vertex);
}
else if (const ICFGWTOCycle* cycle = SVFUtil::dyn_cast<ICFGWTOCycle>(cur))
else if (const ICFGCycleWTO* cycle = SVFUtil::dyn_cast<ICFGCycleWTO>(cur))
{
handleCycle(cycle);
}
Expand Down

0 comments on commit 442e106

Please sign in to comment.