-
Notifications
You must be signed in to change notification settings - Fork 440
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
fix incorrect implementation of getting CallGraphSCCRevTopoOrder #1640
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1640 +/- ##
=======================================
Coverage 63.70% 63.70%
=======================================
Files 245 245
Lines 25999 26001 +2
Branches 4509 4508 -1
=======================================
+ Hits 16563 16565 +2
Misses 9436 9436
|
Would it be possible to put the implementation in SCC.h so that every graph including calligraphscc can use it? Line 128 in 5e0491c
|
NodeStack revTopoStack; | ||
NodeStack& topoStack = this->getSCCDetector()->topoNodeStack(); | ||
while (!topoStack.empty()) | ||
NodeStack revTopoStack = this->getSCCDetector()->revTopoNodeStack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why making changes on SCCDetect
? It was correct, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems correct.
svf/lib/MSSA/MemRegion.cpp
Outdated
@@ -250,6 +250,7 @@ void MRGenerator::collectModRefForCall() | |||
{ | |||
PTACallGraphNode* subCallGraphNode = callGraph->getCallGraphNode(*it); | |||
/// Get mod-ref of all callsites calling callGraphNode | |||
std::cout << subCallGraphNode->getFunction()->getName() << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this debugging line.
svf/lib/WPA/Andersen.cpp
Outdated
while (!topoOrder.empty()) | ||
NodeStack revTopoOrder = getSCCDetector()->revTopoNodeStack(); | ||
/// referenced topoOrder is used for restoring the topological order for later solving. | ||
NodeStack &topoOrder = getSCCDetector()->topoNodeStack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
topoOrder
has been there when you retrieve it and should not be changed later at line 725.
svf/include/Graphs/SCC.h
Outdated
GNodeStack &topoOrder = topoNodeStack(); | ||
while(!topoOrder.empty()) | ||
{ | ||
NodeID callgraphNodeID = topoOrder.top(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callgraphNodeID => nodeID
svf/lib/WPA/Andersen.cpp
Outdated
NodeID nodeId = revTopoOrder.top(); | ||
revTopoOrder.pop(); | ||
topoOrder.push(nodeId); | ||
/// restore the topological order for later solving. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no restore is needed as you never popped any element in topoOrder
svf/lib/WPA/Andersen.cpp
Outdated
while (!topoOrder.empty()) | ||
NodeStack revTopoOrder = getSCCDetector()->revTopoNodeStack(); | ||
/// referenced topoOrder is used for restoring the topological order for later solving. | ||
NodeStack &topoOrder = getSCCDetector()->topoNodeStack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line: NodeStack &topoOrder = getSCCDetector()->topoNodeStack()
svf/lib/WPA/Andersen.cpp
Outdated
revTopoOrder.pop(); | ||
topoOrder.push(nodeId); | ||
/// restore the topological order for later solving. | ||
topoOrder.push(repNodeId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line topoOrder.push(repNodeId);
Could you run the below bcs and ensure you patch produces the same average points-to size using https://app.filemail.com/d/uayyovelgnuoixz |
You could also validate using your local bcs and report back the stats. |
Yeah, I first validate the second url. The first url seems be out-dated. |
Do you have any bc in your local machine? Try to validate another bc and upload your bc and results. |
Yes, I find some bcs to validate. |
I choose 3 project bcs with top size in https://github.com/SVF-tools/Test-Suite/tree/master/test_cases_bc/crux-bc I run the
In the following bash.bc, source is: https://github.com/SVF-tools/Test-Suite/blob/master/test_cases_bc/crux-bc/bash.bc $ diff -u bash.bc.before.txt bash.bc.after.txt
--- bash.bc.before.txt 2025-01-26 19:15:13
+++ bash.bc.after.txt 2025-01-26 19:27:00
@@ -19,7 +19,7 @@
IndCallSites 72
LoadsNum 59146
MaxStructSize 24
-NonPtrObj 8132
+NonPtrObj 8135
ReturnsNum 5385
StackObjs 9595
StoresNum 27665
@@ -32,9 +32,9 @@
VarArrayObj 157
VarStructObj 462
----------------Time and memory stats--------------------
-LLVMIRTime 5.542
-SVFIRTime 7.674
-SymbolTableTime 2.728
+LLVMIRTime 6.388
+SVFIRTime 7.678
+SymbolTableTime 2.713
#######################################################
*********PTACallGraph Stats (Andersen analysis)***************
@@ -65,7 +65,7 @@
MemoryUsageVmsize 0
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 58.191
+TotalTime 52.389
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 15085
@@ -116,21 +116,21 @@
****Persistent Points-To Cache Statistics: Andersen's analysis bitvector****
################ (program : bash.bc)###############
UniquePointsToSets 15689
-TotalUnions 174202
+TotalUnions 174203
PropertyUnions 142918
UniqueUnions 1401
LookupUnions 27249
-PreemptiveUnions 2634
+PreemptiveUnions 2635
TotalComplements 668673
PropertyComplements 644062
UniqueComplements 515
LookupComplements 23581
PreemptiveComplements 515
-TotalIntersections 1067892
-PropertyIntersections 1066301
-UniqueIntersections 5
+TotalIntersections 1067893
+PropertyIntersections 1066300
+UniqueIntersections 6
LookupIntersections 552
-PreemptiveIntersections 1034
+PreemptiveIntersections 1035
#######################################################
Process finished with exit code 0 libcurl.so.bc, source is: https://github.com/SVF-tools/Test-Suite/blob/master/test_cases_bc/crux-bc/libcurl.so.bc $ diff -u libcurl.so.bc.before.txt libcurl.so.bc.after.txt
--- libcurl.so.bc.before.txt 2025-01-26 19:17:05
+++ libcurl.so.bc.after.txt 2025-01-26 19:29:09
@@ -32,9 +32,9 @@
VarArrayObj 220
VarStructObj 199
----------------Time and memory stats--------------------
-LLVMIRTime 3.352
-SVFIRTime 5.138
-SymbolTableTime 1.566
+LLVMIRTime 3.648
+SVFIRTime 5.701
+SymbolTableTime 1.737
#######################################################
*********PTACallGraph Stats (Andersen analysis)***************
@@ -65,7 +65,7 @@
MemoryUsageVmsize 0
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 65.245
+TotalTime 61.742
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 10897
@@ -115,22 +115,22 @@
****Persistent Points-To Cache Statistics: Andersen's analysis bitvector****
################ (program : libcurl.so.bc)###############
-UniquePointsToSets 17799
+UniquePointsToSets 17800
TotalUnions 271805
-PropertyUnions 82352
-UniqueUnions 5906
-LookupUnions 173276
-PreemptiveUnions 10271
-TotalComplements 1215598
+PropertyUnions 82343
+UniqueUnions 5905
+LookupUnions 173285
+PreemptiveUnions 10272
+TotalComplements 1215597
PropertyComplements 1042920
UniqueComplements 5128
-LookupComplements 162427
+LookupComplements 162426
PreemptiveComplements 5123
-TotalIntersections 507640
-PropertyIntersections 494808
+TotalIntersections 507641
+PropertyIntersections 494809
UniqueIntersections 59
-LookupIntersections 2489
-PreemptiveIntersections 10284
+LookupIntersections 2488
+PreemptiveIntersections 10285
#######################################################
Process finished with exit code 0 tmux.bc, source is: https://github.com/SVF-tools/Test-Suite/blob/master/test_cases_bc/crux-bc/tmux.bc $ diff -u tmux.bc.before.txt tmux.bc.after.txt
--- tmux.bc.before.txt 2025-01-26 19:20:19
+++ tmux.bc.after.txt 2025-01-26 19:33:41
@@ -32,9 +32,9 @@
VarArrayObj 127
VarStructObj 385
----------------Time and memory stats--------------------
-LLVMIRTime 4.205
-SVFIRTime 7.519
-SymbolTableTime 2.422
+LLVMIRTime 4.263
+SVFIRTime 8.364
+SymbolTableTime 2.929
#######################################################
*********PTACallGraph Stats (Andersen analysis)***************
@@ -65,7 +65,7 @@
MemoryUsageVmsize 0
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 137.919
+TotalTime 132.443
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 14918
@@ -116,21 +116,21 @@
****Persistent Points-To Cache Statistics: Andersen's analysis bitvector****
################ (program : tmux.bc)###############
UniquePointsToSets 20463
-TotalUnions 734596
+TotalUnions 734597
PropertyUnions 137709
UniqueUnions 6728
LookupUnions 577604
-PreemptiveUnions 12555
+PreemptiveUnions 12556
TotalComplements 1868738
PropertyComplements 1330628
UniqueComplements 5273
LookupComplements 527564
PreemptiveComplements 5273
-TotalIntersections 1197616
-PropertyIntersections 1187010
-UniqueIntersections 20
-LookupIntersections 28
-PreemptiveIntersections 10558
+TotalIntersections 1197617
+PropertyIntersections 1187016
+UniqueIntersections 21
+LookupIntersections 21
+PreemptiveIntersections 10559
#######################################################
Process finished with exit code 0
|
Could you also run this https://github.com/user-attachments/files/18392297/502.gcc_r-16.bc.zip |
Yeah, I have a try. |
When I run two testcases, all nearly full of memory with my laptop. I don't know why the time cost difference is 1000+ s. I also find that: wpa will not reached the function My laptop is mac os:
I run two testcases in release mode, and diff is here below. $ diff -u 502.gcc_r-16.bc.before.txt 502.gcc_r-16.bc.after.txt
--- 502.gcc_r-16.bc.before.txt 2025-01-27 19:45:11
+++ 502.gcc_r-16.bc.after.txt 2025-01-27 14:38:53
@@ -30,9 +30,9 @@
VarArrayObj 1505
VarStructObj 5840
----------------Time and memory stats--------------------
-LLVMIRTime 47.759
-SVFIRTime 47.614
-SymbolTableTime 22.9
+LLVMIRTime 51.387
+SVFIRTime 54.674
+SymbolTableTime 23.792
#######################################################
*********PTACallGraph Stats (Andersen analysis)***************
@@ -63,7 +63,7 @@
MemoryUsageVmsize 0
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 6557.64
+TotalTime 7626.45
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 164468
@@ -139,7 +139,7 @@
MemoryUsageVmsize 0
SCCDetectTime 0
SCCMergeTime 0
-TotalTime 6608.77
+TotalTime 7710.31
UpdateCGTime 0
----------------Numbers stats----------------------------
AddrProcessed 164468
@@ -190,20 +190,20 @@
****Persistent Points-To Cache Statistics: Andersen's analysis bitvector****
################ (program : 502.gcc_r-16.bc)###############
UniquePointsToSets 204056
-TotalUnions 5326743
+TotalUnions 5326741
PropertyUnions 3024648
UniqueUnions 30687
LookupUnions 2212694
-PreemptiveUnions 58714
+PreemptiveUnions 58712
TotalComplements 24523125
PropertyComplements 22608331
UniqueComplements 19815
LookupComplements 1875164
PreemptiveComplements 19815
-TotalIntersections 66660467
-PropertyIntersections 66620516
-UniqueIntersections 28
-LookupIntersections 278
-PreemptiveIntersections 39645
+TotalIntersections 66660465
+PropertyIntersections 66620533
+UniqueIntersections 25
+LookupIntersections 264
+PreemptiveIntersections 39643
####################################################### |
You should use release SVF for testing. The time differences are quite large. Could you re-try it? It would be good to understand which modifications you made in the patch affected the performance. |
it's release mode. I have a re-try to understand some other problems. |
@bjjwwang could you test the time differences on our machine? |
an example of test.c:
before fix,
MRGenerator::getCallGraphSCCRevTopoOrder
will get:after fix, it will get: