Skip to content
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

refactor Global/Constant Val/Obj #1621

Merged
merged 2 commits into from
Jan 7, 2025
Merged

refactor Global/Constant Val/Obj #1621

merged 2 commits into from
Jan 7, 2025

Conversation

bjjwwang
Copy link
Contributor

@bjjwwang bjjwwang commented Jan 6, 2025

No description provided.

@@ -40,12 +40,18 @@ using namespace SVFUtil;
* SVFVar constructor
*/
SVFVar::SVFVar(const SVFValue* val, NodeID i, PNODEK k) :
GenericPAGNodeTy(i,k), value(val), func(nullptr)
GenericPAGNodeTy(i,k), value(val), func(nullptr)
{
assert( ValNode <= k && k <= DummyObjNode && "new SVFIR node kind?");
switch (k)
{
case ValNode:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to follow the order and format here:

if (chaVtbls.find(vtbl) != chaVtbls.end())
vtbls.insert(vtbl);
// ptd is global obj var or ptd's base is global val/obj var
if (SVFUtil::varHasGlobalValue(ptdnode)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use downcasting?

@@ -439,6 +440,12 @@ class GepValVar: public ValVar
return ap.getConstantStructFldIdx();
}

/// Return the base object from which this GEP node came from.
inline NodeID getBaseNode(void) const
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this method? Can we get the basenode from its current nodeID?

else if (auto dataValue = SVFUtil::dyn_cast<ConstantData>(llvmValue))
{
pag->addConstantDataValNode(iter->first, iter->second, icfgNode);
llvmModuleSet()->setValueAttr(dataValue, pag->getGNode(iter->second));
Copy link
Collaborator

Choose a reason for hiding this comment

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

setValueAttr => addToLLVMVal2SVFVarMap


inline NodeID addConstantFPObjNode(const SVFValue* curInst, double dval, const NodeID i)
{
const MemObj* mem = getMemObj(curInst);
Copy link
Collaborator

Choose a reason for hiding this comment

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

MemObj == BaseObj

@@ -441,6 +441,7 @@ inline const ValVar* getActualParmAtForkSite(const CallICFGNode* cs)

bool isProgExitCall(const CallICFGNode* cs);

bool varHasGlobalValue(const SVFVar* var);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this

@@ -158,6 +158,12 @@ class SVFBaseNode
GepValNode, // ├──Represents a GEP value variable
RetNode, // ├──Represents a return value node
VarargNode, // ├──Represents a variadic argument node
GlobalValNode, // ├──Represents a global variable node
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aligin the classes

@@ -430,4 +430,19 @@ const ObjVar* SVFUtil::getObjVarOfValVar(const SVF::ValVar* valVar)
{
assert(valVar->getInEdges().size() == 1);
return SVFUtil::dyn_cast<ObjVar>((*valVar->getInEdges().begin())->getSrcNode());
}

bool SVFUtil::varHasGlobalValue(const SVF::SVFVar* var)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this.

1) remove unused format
2) remove confusing function like varHasGlobalVar
3) align the comment
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 59.67078% with 98 lines in your changes missing coverage. Please review.

Project coverage is 62.84%. Comparing base (efa1583) to head (bb240f1).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
svf/lib/SVFIR/SVFVariables.cpp 21.12% 56 Missing ⚠️
svf/include/SVFIR/SVFIR.h 70.58% 15 Missing ⚠️
svf-llvm/lib/SVFIRBuilder.cpp 74.46% 12 Missing ⚠️
svf/lib/SVFIR/SVFFileSystem.cpp 45.45% 6 Missing ⚠️
svf/include/SVFIR/SVFVariables.h 72.22% 5 Missing ⚠️
svf/lib/AE/Core/AbstractState.cpp 87.50% 2 Missing ⚠️
svf/lib/MemoryModel/AccessPath.cpp 88.88% 1 Missing ⚠️
svf/lib/SABER/SaberCondAllocator.cpp 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1621      +/-   ##
==========================================
- Coverage   62.93%   62.84%   -0.09%     
==========================================
  Files         247      247              
  Lines       27510    27700     +190     
  Branches     4535     4545      +10     
==========================================
+ Hits        17313    17409      +96     
- Misses      10197    10291      +94     
Files with missing lines Coverage Δ
svf-llvm/include/SVF-LLVM/LLVMModule.h 98.47% <100.00%> (ø)
svf-llvm/include/SVF-LLVM/SVFIRBuilder.h 90.76% <100.00%> (+0.14%) ⬆️
svf-llvm/lib/LLVMModule.cpp 81.06% <100.00%> (ø)
svf-llvm/lib/SVFIRExtAPI.cpp 85.24% <100.00%> (ø)
svf/include/Graphs/GenericGraph.h 81.44% <ø> (ø)
svf/lib/MemoryModel/PointerAnalysis.cpp 62.13% <100.00%> (+0.31%) ⬆️
svf/lib/SABER/SaberSVFGBuilder.cpp 93.13% <100.00%> (+0.06%) ⬆️
svf/lib/SVFIR/SVFIR.cpp 77.19% <100.00%> (ø)
svf/lib/Util/SVFUtil.cpp 44.07% <ø> (ø)
svf/lib/MemoryModel/AccessPath.cpp 52.74% <88.88%> (+1.09%) ⬆️
... and 7 more

... and 1 file with indirect coverage changes

@bjjwwang
Copy link
Contributor Author

bjjwwang commented Jan 6, 2025

--- pr.out 2025-01-06 19:08:00.126734684 +1100
+++ master.out 2025-01-06 22:20:07.005037422 +1100
@@ -1,3 +1,5 @@
+isIRFile: ../pldi25/redis-server.bc: error: Could not open input file: No such file or directory
+not an IR file: ../pldi25/redis-server.bc

General Stats******
################ (program : redis-server.bc)###############
@@ -31,9 +33,9 @@
VarArrayObj 831
VarStructObj 1663
----------------Time and memory stats--------------------
-LLVMIRTime 4.043
-SVFIRTime 2.793
-SymbolTableTime 0.522
+LLVMIRTime 4.088
+SVFIRTime 2.587
+SymbolTableTime 0.517
#######################################################

PTACallGraph Stats (Andersen analysis)******
@@ -60,11 +62,11 @@
CollapseTime 0
CopyGepTime 0
LoadStoreTime 0
-MemoryUsageVmrss 4.16595e+06
-MemoryUsageVmsize 4.16574e+06
+MemoryUsageVmrss 4.16581e+06
+MemoryUsageVmsize 4.16573e+06
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 119.171
+TotalTime 117.789
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 17879
@@ -115,47 +117,47 @@
Persistent Points-To Cache Statistics: Andersen's analysis bitvector
################ (program : redis-server.bc)###############
UniquePointsToSets 44826
-TotalUnions 672596
+TotalUnions 672607
PropertyUnions 222181
-UniqueUnions 19258
-LookupUnions 395181
-PreemptiveUnions 35976
+UniqueUnions 19257
+LookupUnions 395182
+PreemptiveUnions 35987
TotalComplements 3364058
PropertyComplements 2998447
UniqueComplements 16887
LookupComplements 331839
PreemptiveComplements 16885
-TotalIntersections 4184756
-PropertyIntersections 4147574
-UniqueIntersections 771
-LookupIntersections 2128
-PreemptiveIntersections 34283
+TotalIntersections 4184768
+PropertyIntersections 4147443
+UniqueIntersections 847
+LookupIntersections 2183
+PreemptiveIntersections 34295
#######################################################

Memory SSA Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
-AverageRegSize 85.8766
-GenMUCHITime 1.892
-GenRegionTime 545.632
-InsertPHITime 0.554
-SSARenameTime 0.087
-TotalMSSATime 548.184
+AverageRegSize 85.6225
+GenMUCHITime 1.886
+GenRegionTime 543.223
+InsertPHITime 0.551
+SSARenameTime 0.069
+TotalMSSATime 545.738
----------------Numbers stats----------------------------
BBHasMSSAPhi 10656
-CSChiNode 110781
+CSChiNode 111620
CSHasChi 22214
CSHasMu 24084
-CSMuNode 162728
-FunEntryChi 24040
+CSMuNode 163704
+FunEntryChi 24189
FunHasEntryChi 3939
FunHasRetMu 4624
-FunRetMu 23972
+FunRetMu 24121
LoadHasMu 24346
LoadMuNode 43116
-MSSAPhi 58814
+MSSAPhi 59492
MaxRegSize 1650
-MemRegions 4530
+MemRegions 4548
StoreChiNode 14268
StoreHasChi 10510
#######################################################
@@ -163,16 +165,16 @@
SVFG Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
-ATNodeTime 0.916
-AvgWeight 168.49
+ATNodeTime 0.93
+AvgWeight 167.296
ConnDirEdgeTime 0
-ConnIndEdgeTime 4.568
+ConnIndEdgeTime 4.609
OptTime 0
TLNodeTime 0
-TotalTime 5.484
+TotalTime 5.539
----------------Numbers stats----------------------------
-ActualIn 162728
-ActualOut 110781
+ActualIn 163704
+ActualOut 111620
ActualParam 57426
ActualRet 7530
Addr 17879
@@ -184,25 +186,25 @@
DirectCallEdge 41433
DirectEdge 292430
DirectRetEdge 6892
-FormalIn 24040
-FormalOut 23972
+FormalIn 24189
+FormalOut 24121
FormalParam 7868
FormalRet 789
Gep 84884
-IndCallEdge 189539
-IndRetEdge 124212
-IndirectEdge 714070
-IndirectEdgeLabels 120313808
+IndCallEdge 190756
+IndRetEdge 125220
+IndirectEdge 719150
+IndirectEdgeLabels 120311162
Load 24346
-MSSAPhi 58814
+MSSAPhi 59492
MaxInDegree 9710
MaxIndInDeg 9710
MaxIndOutDeg 2458
MaxOutDegree 9600
PHI 6770
Store 24167
-TotalEdge 1006500
-TotalNode 626133
+TotalEdge 1011580
+TotalNode 628924
#######################################################

PTACallGraph Stats (Flow-sensitive analysis)******
@@ -222,7 +224,7 @@
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
AddrTime 0
-AverageSCCSize 438.159
+AverageSCCSize 441.191
AvgAddrTakenVarPts 1104.9
AvgINPtsSize 0
AvgOUTPtsSize 0
@@ -233,16 +235,16 @@
GepTime 0
IndirectPropaTime 0
LoadTime 0
-MemoryUsageVmrss 1.48942e+07
-MemoryUsageVmsize 1.48938e+07
+MemoryUsageVmrss 1.48703e+07
+MemoryUsageVmsize 1.48699e+07
PhiTime 0
ProcessTime 0
PropagationTime 0
SCCTime 0
-SolveTime 5394.42
+SolveTime 5249.45
StoreTime 0
Strong/WeakUpdTime 0
-TotalTime 6076.79
+TotalTime 5928.64
UpdateCGTime 0
----------------Numbers stats----------------------------
AI_SNodesHaveIN 0
@@ -264,12 +266,12 @@
MaxINPtsSize 0
MaxOUTPtsSize 0
MaxPtsSize 1709
-MaxSCCSize 361291
+MaxSCCSize 363819
MaxTopLvlPtsSize 1709
MemObjects 9820
NullPointer 14313
NumOfAddrTakenVar 2168910
-NumOfNodesInSCC 365425
+NumOfNodesInSCC 367953
NumOfSCC 834
PHI_SNodesHaveIN 0
PHI_SNodesHaveOUT 0
@@ -280,13 +282,13 @@
PotentialVarHaveOUT 0
ProcessedAParam 0
ProcessedAddr 107274
-ProcessedCopy 218106
+ProcessedCopy 213701
ProcessedFRet 0
-ProcessedGep 1107038
-ProcessedLoad 1968209
-ProcessedMSSANode 16693491
-ProcessedPhi 150560
-ProcessedStore 544720
+ProcessedGep 1085429
+ProcessedLoad 1938786
+ProcessedMSSANode 16566715
+ProcessedPhi 148546
+ProcessedStore 536024
SNodesHaveIN 0
SNodesHaveOUT 0
ST_SNodesHaveIN 0
@@ -318,12 +320,12 @@

Persistent Points-To Cache Statistics: flow-sensitive analysis bitvector
################ (program : redis-server.bc)###############
-UniquePointsToSets 35100
-TotalUnions 27760928115
-PropertyUnions 22103235635
-UniqueUnions 93826
-LookupUnions 5657474922
-PreemptiveUnions 123732
+UniquePointsToSets 34420
+TotalUnions 27191692076
+PropertyUnions 21786092253
+UniqueUnions 86626
+LookupUnions 5405398605
+PreemptiveUnions 114592
TotalComplements 0
PropertyComplements 0
UniqueComplements 0

@jumormt
Copy link
Contributor

jumormt commented Jan 6, 2025

--- log/redis-server.log 2025-01-06 22:33:29.475188962 +1100
+++ log/redis-server-xiao.log 2025-01-06 22:32:23.467949326 +1100
@@ -31,9 +31,9 @@
VarArrayObj 831
VarStructObj 1663
----------------Time and memory stats--------------------
-LLVMIRTime 4.484
-SVFIRTime 3.264
-SymbolTableTime 0.633
+LLVMIRTime 4.495
+SVFIRTime 2.604
+SymbolTableTime 0.565
#######################################################

PTACallGraph Stats (Andersen analysis)******
@@ -60,11 +60,11 @@
CollapseTime 0
CopyGepTime 0
LoadStoreTime 0
-MemoryUsageVmrss 4.16566e+06
-MemoryUsageVmsize 4.16543e+06
+MemoryUsageVmrss 4.16576e+06
+MemoryUsageVmsize 4.16541e+06
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 130.648
+TotalTime 126.932
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 17879
@@ -115,32 +115,32 @@
Persistent Points-To Cache Statistics: Andersen's analysis bitvector
################ (program : redis-server.bc)###############
UniquePointsToSets 44826
-TotalUnions 672560
+TotalUnions 672559
PropertyUnions 222172
UniqueUnions 19258
LookupUnions 395148
-PreemptiveUnions 35982
+PreemptiveUnions 35981
TotalComplements 3363830
PropertyComplements 2998252
UniqueComplements 16887
LookupComplements 331806
PreemptiveComplements 16885
-TotalIntersections 4182707
-PropertyIntersections 4145429
-UniqueIntersections 830
-LookupIntersections 2159
-PreemptiveIntersections 34289
+TotalIntersections 4182706
+PropertyIntersections 4145440
+UniqueIntersections 836
+LookupIntersections 2142
+PreemptiveIntersections 34288
#######################################################

Memory SSA Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
AverageRegSize 85.9112
-GenMUCHITime 2.144
-GenRegionTime 578.073
-InsertPHITime 0.645
-SSARenameTime 0.087
-TotalMSSATime 580.955
+GenMUCHITime 2.167
+GenRegionTime 551.708
+InsertPHITime 0.625
+SSARenameTime 0.096
+TotalMSSATime 554.604
----------------Numbers stats----------------------------
BBHasMSSAPhi 10656
CSChiNode 110742
@@ -163,13 +163,13 @@
SVFG Statistics******
################ (program : redis-server.bc)###############
----------------Time and memory stats--------------------
-ATNodeTime 0.859
+ATNodeTime 0.848
AvgWeight 168.555
ConnDirEdgeTime 0
-ConnIndEdgeTime 4.585
+ConnIndEdgeTime 4.571
OptTime 0
TLNodeTime 0
-TotalTime 5.444
+TotalTime 5.419
----------------Numbers stats----------------------------
ActualIn 162689
ActualOut 110742
@@ -231,20 +231,20 @@
GepTime 0
IndirectPropaTime 0
LoadTime 0
-MemoryUsageVmrss 3.568e+06
-MemoryUsageVmsize 3.60086e+06
+MemoryUsageVmrss 3.57099e+06
+MemoryUsageVmsize 3.60524e+06
PhiTime 0
-PrelabelingTime 0.148
+PrelabelingTime 0.138
ProcessTime 0
PropagationTime 0
SCCTime 0
-SolveTime 434.721
+SolveTime 402.366
StoreTime 0
Strong/WeakUpdTime 0
-TotalTime 653.673
+TotalTime 618.176
UpdateCGTime 0
VersionPropTime 0
-meldLabelingTime 215.498
+meldLabelingTime 212.435
----------------Numbers stats----------------------------
CopysNum 14138
DummyFieldPtrs 2305
@@ -262,13 +262,13 @@
Pointers 494723
ProcessedAParam 0
ProcessedAddr 107274
-ProcessedCopy 161911
+ProcessedCopy 161604
ProcessedFRet 0
-ProcessedGep 866405
-ProcessedLoad 841174
+ProcessedGep 868542
+ProcessedLoad 836022
ProcessedMSSANode 2281182
-ProcessedPhi 102980
-ProcessedStore 314115
+ProcessedPhi 102879
+ProcessedStore 313966
SolveIterations 6
StoresNum 24163
StrongUpdates 3377
@@ -283,12 +283,12 @@

Persistent Points-To Cache Statistics: flow-sensitive analysis bitvector
################ (program : redis-server.bc)###############
-UniquePointsToSets 29411
-TotalUnions 1108309482
-PropertyUnions 953331418
-UniqueUnions 37129
-LookupUnions 154890848
-PreemptiveUnions 50087
+UniquePointsToSets 29560
+TotalUnions 1103352203
+PropertyUnions 948380785
+UniqueUnions 37675
+LookupUnions 154883058
+PreemptiveUnions 50685
TotalComplements 0
PropertyComplements 0
UniqueComplements 0

ConstantFPObjVar(NodeID i) : ConstantDataObjVar(i) {}

private:
float dval;
Copy link
Collaborator

Choose a reason for hiding this comment

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

float -> double

@@ -427,9 +428,9 @@ class GepValVar: public ValVar
//@}

/// Constructor
GepValVar(const SVFValue* val, NodeID i, const AccessPath& ap,
GepValVar(NodeID baseID, const SVFValue* val, NodeID i, const AccessPath& ap,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need SVFValue as an argument?

@yuleisui yuleisui merged commit cfdbb6c into SVF-tools:master Jan 7, 2025
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.

3 participants