Skip to content

Commit 09e86d5

Browse files
author
bjjwwang
committed
Continue to reduce the Options() handleRecur. (vibe-kanban 5f1e98b0)
I think you could continue to narrow down the usage of OPtions::HandleREcur(). I mean maybe you could put the option check inside the function. For example, "// Check if this recursive call should be skipped if (shouldSkipRecursiveCall(callNode, funObjVar)) { // In TOP mode, set return value and stores to TOP // In WIDEN\_ONLY/WIDEN\_NARROW, just skip (WTO handles it) if (Options::HandleRecur() == TOP) handleSkippedRecursiveCall(callNode); return; } " maybe you should move the if check inside the function. You could try this way to reduce the Options::handleRecur as low as possible.
1 parent bf793f8 commit 09e86d5

File tree

2 files changed

+7
-56
lines changed

2 files changed

+7
-56
lines changed

svf/include/AE/Svfexe/AbstractInterpretation.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ class AbstractInterpretation
348348
virtual bool isRecursiveCall(const CallICFGNode* callNode);
349349
virtual void recursiveCallPass(const CallICFGNode *callNode);
350350
virtual bool isRecursiveCallSite(const CallICFGNode* callNode, const FunObjVar *);
351-
virtual bool isDirectCall(const CallICFGNode* callNode);
352-
virtual void directCallFunPass(const CallICFGNode* callNode);
353-
virtual bool isIndirectCall(const CallICFGNode* callNode);
354-
virtual void indirectCallFunPass(const CallICFGNode* callNode);
351+
virtual void callFunPass(const CallICFGNode* callNode);
355352

356353
bool skipRecursiveCall(const CallICFGNode* callNode);
357354
const FunObjVar* getCallee(const CallICFGNode* callNode);

svf/lib/AE/Svfexe/AbstractInterpretation.cpp

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -804,16 +804,11 @@ void AbstractInterpretation::handleCallSite(const ICFGNode* node)
804804
{
805805
extCallPass(callNode);
806806
}
807-
else if (isDirectCall(callNode))
808-
{
809-
directCallFunPass(callNode);
810-
}
811-
else if (isIndirectCall(callNode))
807+
else
812808
{
813-
indirectCallFunPass(callNode);
809+
// Handle both direct and indirect calls uniformly
810+
callFunPass(callNode);
814811
}
815-
else
816-
assert(false && "implement this part");
817812
}
818813
else
819814
assert (false && "it is not call node");
@@ -950,51 +945,13 @@ bool AbstractInterpretation::shouldApplyNarrowing(const FunObjVar* fun)
950945
return false;
951946
}
952947
}
953-
954-
955-
bool AbstractInterpretation::isDirectCall(const CallICFGNode *callNode)
956-
{
957-
const FunObjVar *callfun =callNode->getCalledFunction();
958-
if (!callfun)
959-
return false;
960-
else
961-
return !callfun->isDeclaration();
962-
}
963-
void AbstractInterpretation::directCallFunPass(const CallICFGNode *callNode)
948+
/// Handle direct or indirect call: get callee, process function body, set return state
949+
void AbstractInterpretation::callFunPass(const CallICFGNode *callNode)
964950
{
965951
AbstractState& as = getAbsStateFromTrace(callNode);
966-
967952
abstractTrace[callNode] = as;
968953

969-
// Skip recursive call if applicable (returns true if skipped)
970-
if (skipRecursiveCall(callNode))
971-
return;
972-
973-
const FunObjVar *calleeFun = callNode->getCalledFunction();
974-
callSiteStack.push_back(callNode);
975-
976-
// Use worklist-based function handling instead of recursive WTO component handling
977-
const ICFGNode* calleeEntry = icfg->getFunEntryICFGNode(calleeFun);
978-
handleFunction(calleeEntry);
979-
980-
callSiteStack.pop_back();
981-
// handle Ret node
982-
const RetICFGNode *retNode = callNode->getRetICFGNode();
983-
// resume ES to callnode
984-
abstractTrace[retNode] = abstractTrace[callNode];
985-
}
986-
987-
bool AbstractInterpretation::isIndirectCall(const CallICFGNode *callNode)
988-
{
989-
const auto callsiteMaps = svfir->getIndirectCallsites();
990-
return callsiteMaps.find(callNode) != callsiteMaps.end();
991-
}
992-
993-
void AbstractInterpretation::indirectCallFunPass(const CallICFGNode *callNode)
994-
{
995-
AbstractState& as = getAbsStateFromTrace(callNode);
996-
997-
// Skip recursive call if applicable (returns true if skipped)
954+
// Skip recursive callsites (within SCC); entry calls are not skipped
998955
if (skipRecursiveCall(callNode))
999956
return;
1000957

@@ -1003,14 +960,11 @@ void AbstractInterpretation::indirectCallFunPass(const CallICFGNode *callNode)
1003960
return;
1004961

1005962
callSiteStack.push_back(callNode);
1006-
abstractTrace[callNode] = as;
1007963

1008-
// Use worklist-based function handling instead of recursive WTO component handling
1009964
const ICFGNode* calleeEntry = icfg->getFunEntryICFGNode(callee);
1010965
handleFunction(calleeEntry);
1011966

1012967
callSiteStack.pop_back();
1013-
// handle Ret node
1014968
const RetICFGNode* retNode = callNode->getRetICFGNode();
1015969
abstractTrace[retNode] = abstractTrace[callNode];
1016970
}

0 commit comments

Comments
 (0)