Skip to content

Conversation

@bjjwwang
Copy link
Contributor

Pre-Requisite: Should Merge this Test Suite PR

Introduction: This PR replace wto with worklist algotihm, naive version.

May Need To Discuss: At svf/lib/AE/Svfexe/AbstractInterpretation.cpp line 145, I use a lambda code to build cycleHeadToCycle map. Maybe I can change it to a member function.

Next PR: Use-Def Pre-Analysis Map.

// This maps cycle head nodes to their corresponding WTO cycles for efficient lookup
for (auto& [func, wto] : funcToWTO)
{
// Recursive lambda to collect cycle heads from nested WTO components
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove lambda

@bjjwwang bjjwwang changed the title refactor AE, use worklist algorithm(naive) refactor AE, use worklist algorithm(naive) WIP Jan 26, 2026
@yuleisui
Copy link
Collaborator

Needs to fix this CI and move the precision-loss test case to a separate folder and address it after optimizations are enabled in later implementation.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 85.81560% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.14%. Comparing base (25f4c58) to head (d3b4fae).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
svf/lib/AE/Svfexe/AbstractInterpretation.cpp 85.81% 20 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1786      +/-   ##
==========================================
- Coverage   64.15%   64.14%   -0.01%     
==========================================
  Files         243      243              
  Lines       24569    24624      +55     
  Branches     4627     4657      +30     
==========================================
+ Hits        15762    15796      +34     
- Misses       8807     8828      +21     
Files with missing lines Coverage Δ
svf/include/AE/Svfexe/AbstractInterpretation.h 95.23% <ø> (ø)
svf/lib/AE/Svfexe/AbstractInterpretation.cpp 79.10% <85.81%> (-1.48%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

bjjwwang added 2 commits January 31, 2026 22:42
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.
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.
nonRecursiveCallSites.end();
}

/// Recursion Handling Decision Methods
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add examples for three cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe what are set to top, where is widened and narrowed.

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.
}

bool AbstractInterpretation::shouldApplyNarrowingInRecursion(const FunObjVar* fun)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an assertion if this is not recursion function.

/// All recursion mode (TOP/WIDEN_ONLY/WIDEN_NARROW) logic is centralized here

bool AbstractInterpretation::skipRecursiveCall(
const CallICFGNode* callNode, const FunObjVar* callee)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callNode is enough as the argument.

bjjwwang added 7 commits February 2, 2026 16:25
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.
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.
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.
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.
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.
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.
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.
}

/// handle wto cycle (loop) using worklist-compatible widening/narrowing iteration
/// Handle WTO cycle (loop or recursive function) using widening/narrowing iteration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is ICFG cycle now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can rename handleICFGCycleOrRecursion.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HandleLoopOrRecursion. It would also be good to note that ICFGNode cycles refers to loops only, not interprocedural ICFGNode cycles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HandleLoopOrRecursion. It would also be good to note that ICFGNode cycles refers to loops only, not interprocedural ICFGNode cycles

Sure

// Skip recursive call if applicable (returns true if skipped)
if (skipRecursiveCall(callNode, funObjVar))
return;
const FunObjVar* callee = getCallee(callNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we using the andersen's points-to result here?

I think handling indirectcall is the same as handling direct call if the calleenode is known? Can the code below be shared with the direct call handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we using the andersen's points-to result here?

I think handling indirectcall is the same as handling direct call if the calleenode is known? Can the code below be shared with the direct call handling.

we use Address Domain here.
Yes, I am trying to merge them.

bjjwwang added 2 commits February 3, 2026 15:40
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.
*/
virtual void handleSVFStatement(const SVFStmt* stmt);

virtual void setRecursiveCallStoresToTop(const CallICFGNode* callnode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTopToObjInRecursion.

virtual void directCallFunPass(const CallICFGNode* callNode);
virtual bool isIndirectCall(const CallICFGNode* callNode);
virtual void indirectCallFunPass(const CallICFGNode* callNode);
virtual void callFunPass(const CallICFGNode* callNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HandleFunCall

你方便把 setRecursiveCallStoresToTop改名setTopToObjInRecursion

然后把callFunPass 改名HandleFunCall吗? 改名就行
@bjjwwang bjjwwang changed the title refactor AE, use worklist algorithm(naive) WIP refactor AE, use worklist algorithm(naive) Feb 4, 2026
if (isExtCall(callNode))
{
indirectCallFunPass(callNode);
extCallPass(callNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleExtCall

assert(false && "implement this part");
{
// Handle both direct and indirect calls uniformly
HandleFunCall(callNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleFunCall

bjjwwang added 2 commits February 4, 2026 14:52
你方便把 setRecursiveCallStoresToTop改名setTopToObjInRecursion

然后把callFunPass 改名HandleFunCall吗? 改名就行
你方便把 setRecursiveCallStoresToTop改名setTopToObjInRecursion

然后把callFunPass 改名HandleFunCall吗? 改名就行
@yuleisui yuleisui merged commit 85e1753 into SVF-tools:master Feb 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants