Skip to content

remove all SVFFunction in svf #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

Geoffrey1014
Copy link
Contributor

remove all SVFFunction in svf except SVFValue
svf-llvm remains some SVFFunction usages

hwg added 30 commits January 27, 2025 14:24
(cherry picked from commit 94a899a)
(cherry picked from commit 82daf5b)
…st SVFFunction* F,

                        NodePairSet& cpySrcNodes);
…NodeMap; --> Map<const CallGraphNode*, PTACallGraphNode*> FunToCallGraphNodeMap; in PTACallGraphNode
…oPTACallGraphNodeMap cgNodeToPtaCallGraphNodeMap; in PTACallGraphNode
…tePair; --> std::pair<const CallICFGNode*, const CallGraphNode*> CallSitePair; in PTACallGraphNode
…t CallGraphNode*> FunctionSet; in PTACallGraphNode
Copy link

codecov bot commented Feb 1, 2025

Codecov Report

Attention: Patch coverage is 76.42726% with 128 lines in your changes missing coverage. Please review.

Project coverage is 63.84%. Comparing base (ab71cdd) to head (0410a42).

Files with missing lines Patch % Lines
svf/lib/MTA/LockAnalysis.cpp 4.00% 24 Missing ⚠️
svf/lib/MTA/MHP.cpp 58.33% 10 Missing ⚠️
svf/lib/DDA/DDAPass.cpp 0.00% 8 Missing ⚠️
svf/include/Graphs/CallGraph.h 87.50% 5 Missing ⚠️
svf/lib/Graphs/PTACallGraph.cpp 72.22% 5 Missing ⚠️
svf/lib/MSSA/MemPartition.cpp 37.50% 5 Missing ⚠️
svf/lib/MTA/TCT.cpp 83.87% 5 Missing ⚠️
svf/lib/Util/CDGBuilder.cpp 0.00% 5 Missing ⚠️
svf/include/Graphs/ThreadCallGraph.h 0.00% 4 Missing ⚠️
svf/lib/Graphs/ICFG.cpp 60.00% 4 Missing ⚠️
... and 33 more
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1646   +/-   ##
=======================================
  Coverage   63.84%   63.84%           
=======================================
  Files         246      246           
  Lines       25993    26055   +62     
  Branches     4507     4509    +2     
=======================================
+ Hits        16594    16635   +41     
- Misses       9399     9420   +21     
Files with missing lines Coverage Δ
svf-llvm/include/SVF-LLVM/LLVMModule.h 94.89% <100.00%> (-3.60%) ⬇️
svf-llvm/include/SVF-LLVM/SVFIRBuilder.h 90.62% <ø> (ø)
svf-llvm/lib/ICFGBuilder.cpp 100.00% <100.00%> (ø)
svf-llvm/lib/LLVMLoopAnalysis.cpp 100.00% <100.00%> (ø)
svf-llvm/lib/LLVMModule.cpp 79.19% <100.00%> (+0.29%) ⬆️
svf-llvm/lib/SVFIRExtAPI.cpp 85.71% <100.00%> (ø)
svf/include/CFL/CFLAlias.h 92.85% <ø> (ø)
svf/include/DDA/ContextDDA.h 75.00% <100.00%> (ø)
svf/include/DDA/DDAVFSolver.h 90.61% <100.00%> (ø)
svf/include/DDA/FlowDDA.h 90.00% <100.00%> (ø)
... and 88 more

... and 1 file with indirect coverage changes

@yuleisui
Copy link
Collaborator

yuleisui commented Feb 1, 2025

@jumormt pls review and make the code style consistent as you previous refactoring

@Geoffrey1014
Copy link
Contributor Author

--- master-2.3.txt 2025-02-02 13:05:43
+++ refactor-2.3.txt 2025-02-02 13:06:12
@@ -31,9 +31,9 @@
VarArrayObj 831
VarStructObj 1663
----------------Time and memory stats--------------------
-LLVMIRTime 4.377
-SVFIRTime 3.516
-SymbolTableTime 0.889
+LLVMIRTime 4.097
+SVFIRTime 3.175
+SymbolTableTime 0.565
#######################################################

PTACallGraph Stats (Andersen analysis)******
@@ -60,11 +60,11 @@
CollapseTime 0
CopyGepTime 0
LoadStoreTime 0
-MemoryUsageVmrss 4.17078e+06
-MemoryUsageVmsize 4.1706e+06
+MemoryUsageVmrss 4.17092e+06
+MemoryUsageVmsize 4.17059e+06
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 118.739
+TotalTime 119.448
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 17879
@@ -115,47 +115,47 @@
Persistent Points-To Cache Statistics: Andersen's analysis bitvector
################ (program : redis-server.bc)###############
UniquePointsToSets 44826
-TotalUnions 672574
+TotalUnions 672563
PropertyUnions 222172
UniqueUnions 19257
LookupUnions 395149
-PreemptiveUnions 35996
+PreemptiveUnions 35985
TotalComplements 3363830
PropertyComplements 2998252
UniqueComplements 16887
LookupComplements 331806
PreemptiveComplements 16885
-TotalIntersections 4182722
-PropertyIntersections 4145316
-UniqueIntersections 863
-LookupIntersections 2239
-PreemptiveIntersections 34304
+TotalIntersections 4182711
+PropertyIntersections 4145485
+UniqueIntersections 788
+LookupIntersections 2145
+PreemptiveIntersections 34293
#######################################################

Memory SSA Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
-AverageRegSize 85.8766
-GenMUCHITime 1.753
-GenRegionTime 594.911
-InsertPHITime 0.523
-SSARenameTime 0.124
-TotalMSSATime 597.321
+AverageRegSize 85.9112
+GenMUCHITime 1.818
+GenRegionTime 595.641
+InsertPHITime 0.515
+SSARenameTime 0.104
+TotalMSSATime 598.088
----------------Numbers stats----------------------------
BBHasMSSAPhi 10656
-CSChiNode 110781
+CSChiNode 110742
CSHasChi 22214
CSHasMu 24084
-CSMuNode 162728
-FunEntryChi 24040
+CSMuNode 162689
+FunEntryChi 24034
FunHasEntryChi 3939
FunHasRetMu 4624
-FunRetMu 23972
+FunRetMu 23966
LoadHasMu 24342
LoadMuNode 43107
-MSSAPhi 58814
+MSSAPhi 58766
MaxRegSize 1650
-MemRegions 4530
+MemRegions 4528
StoreChiNode 14268
StoreHasChi 10506
#######################################################
@@ -163,16 +163,16 @@
SVFG Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
-ATNodeTime 0.931
-AvgWeight 168.485
+ATNodeTime 0.912
+AvgWeight 168.555
ConnDirEdgeTime 0
-ConnIndEdgeTime 4.591
+ConnIndEdgeTime 4.61
OptTime 0
TLNodeTime 0
TotalTime 5.522
----------------Numbers stats----------------------------
-ActualIn 162728
-ActualOut 110781
+ActualIn 162689
+ActualOut 110742
ActualParam 57426
ActualRet 7530
Addr 17879
@@ -184,25 +184,25 @@
DirectCallEdge 41433
DirectEdge 292410
DirectRetEdge 6892
-FormalIn 24040
-FormalOut 23972
+FormalIn 24034
+FormalOut 23966
FormalParam 7868
FormalRet 789
Gep 84876
-IndCallEdge 189539
-IndRetEdge 124212
-IndirectEdge 714061
-IndirectEdgeLabels 120308915
+IndCallEdge 189473
+IndRetEdge 124146
+IndirectEdge 713766
+IndirectEdgeLabels 120308943
Load 24342
-MSSAPhi 58814
+MSSAPhi 58766
MaxInDegree 9710
MaxIndInDeg 9710
MaxIndOutDeg 2458
MaxOutDegree 9600
PHI 6770
Store 24163
-TotalEdge 1006471
-TotalNode 626117
+TotalEdge 1006176
+TotalNode 625979
#######################################################

PTACallGraph Stats (Flow-sensitive analysis)******
@@ -231,20 +231,20 @@
GepTime 0
IndirectPropaTime 0
LoadTime 0
-MemoryUsageVmrss 3.66454e+06
-MemoryUsageVmsize 3.69424e+06
+MemoryUsageVmrss 3.66245e+06
+MemoryUsageVmsize 3.69684e+06
PhiTime 0
-PrelabelingTime 0.13
+PrelabelingTime 0.131
ProcessTime 0
PropagationTime 0
SCCTime 0
-SolveTime 505.376
+SolveTime 510.79
StoreTime 0
Strong/WeakUpdTime 0
-TotalTime 728.681
+TotalTime 734.015
UpdateCGTime 0
VersionPropTime 0
-meldLabelingTime 220.077
+meldLabelingTime 219.865
----------------Numbers stats----------------------------
CopysNum 14138
DummyFieldPtrs 2305
@@ -262,13 +262,13 @@
Pointers 535314
ProcessedAParam 0
ProcessedAddr 107274
-ProcessedCopy 185583
+ProcessedCopy 186826
ProcessedFRet 0
-ProcessedGep 1054148
-ProcessedLoad 1028701
-ProcessedMSSANode 2282010
-ProcessedPhi 128976
-ProcessedStore 429814
+ProcessedGep 1056048
+ProcessedLoad 1024000
+ProcessedMSSANode 2281182
+ProcessedPhi 129086
+ProcessedStore 427488
SolveIterations 6
StoresNum 24163
StrongUpdates 3377
@@ -283,12 +283,12 @@

Persistent Points-To Cache Statistics: flow-sensitive analysis bitvector
################ (program : redis-server.bc)###############
-UniquePointsToSets 29196
-TotalUnions 1345935918
-PropertyUnions 1189227108
-UniqueUnions 35842
-LookupUnions 156624402
-PreemptiveUnions 48566
+UniquePointsToSets 29265
+TotalUnions 1343102932
+PropertyUnions 1180849052
+UniqueUnions 36161
+LookupUnions 162168783
+PreemptiveUnions 48936
TotalComplements 0
PropertyComplements 0
UniqueComplements 0

}
// else
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove comments

{
CallGraphNode* callNode = const_cast<CallGraphNode*>(item.first);
SVFFunction* fun = item.second;
callNode->init(fun->getFunctionType(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Too many fields in the classs. Need to simplify fields and use methods for flags and some fields

@@ -324,7 +324,7 @@ class SVFFunction : public SVFValue
BasicBlockGraph* bbGraph; /// the basic block graph of this function

protected:
inline void setCallGraphNode(CallGraphNode *cgn)
inline void setCallGraphNode(const CallGraphNode *cgn)
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -415,7 +418,7 @@ class PTACallGraph : public GenericPTACallGraphTy
for (CallGraphEdgeSet::const_iterator it = getCallEdgeBegin(cs), eit =
getCallEdgeEnd(cs); it != eit; ++it)
{
callees.insert((*it)->getDstNode()->getFunction());
callees.insert((*it)->getDstNode()->getCallNode());
Copy link
Contributor

Choose a reason for hiding this comment

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

getCallNode() -> getCallGraphNode()

{
return callGraphSCC->isInCycle(callgraph->getCallGraphNode(fun)->getId());
return callGraphSCC->isInCycle(
callgraph->getPTACallGraphNode(fun)->getId());
Copy link
Contributor

@jumormt jumormt Feb 2, 2025

Choose a reason for hiding this comment

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

fun->getId() is enough please also check other places

@@ -263,7 +264,7 @@ class PTACallGraph : public GenericPTACallGraphTy
static CallSiteID totalCallSiteNum; ///< CallSiteIDs, start from 1;

protected:
FunToCallGraphNodeMap funToCallGraphNodeMap; ///< Call Graph node map
CgNodeToPTACallGraphNodeMap cgNodeToPtaCallGraphNodeMap; ///< Call Graph node map
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this map. We can use id to get ptacallgraphnode from callgraphnode

CallGraph* buildSVFIRCallGraph(SVFModule* svfModule);
CallGraph* createSVFIRCallGraph(SVFModule* svfModule);

void connectSVFIRCallGraphEdge(CallGraph* callGraph);
Copy link
Contributor

Choose a reason for hiding this comment

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

addSVFIRCallGraphEdges

@@ -800,7 +797,7 @@ void AbstractInterpretation::SkipRecursiveCall(const CallICFGNode *callNode)
}
FIFOWorkList<const SVFBasicBlock *> blkWorkList;
FIFOWorkList<const ICFGNode *> instWorklist;
for (const SVFBasicBlock * bb: callNode->getCalledFunction()->getReachableBBs())
for (const SVFBasicBlock * bb: callNode->getCalledFunction()->getReachableBBs()) // HWG need to rethink this
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comments

hwg added 3 commits February 2, 2025 21:23
connectSVFIRCallGraphEdge -> addSVFIRCallGraphEdges
connectSVFIRCallGraphEdge -> addSVFIRCallGraphEdges
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.

3 participants