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

Replace ExAPI.json with extapi.c (extapi.c explaination wiki: https://github.com/SVF-tools/SVF/wiki/Handling-External-APIs-with-extapi.c) #1165

Merged
merged 4 commits into from
Aug 16, 2023

Conversation

shuangxiangkan
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #1165 (a6c467a) into master (f889cfb) will increase coverage by 0.10%.
The diff coverage is 88.16%.

❗ Current head a6c467a differs from pull request most recent head 68f270a. Consider uploading reports for the commit 68f270a to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1165      +/-   ##
==========================================
+ Coverage   64.64%   64.74%   +0.10%     
==========================================
  Files         223      222       -1     
  Lines       23865    23475     -390     
==========================================
- Hits        15427    15200     -227     
+ Misses       8438     8275     -163     
Files Changed Coverage Δ
svf-llvm/include/SVF-LLVM/SVFIRBuilder.h 88.88% <ø> (ø)
svf/include/SVFIR/SVFModule.h 78.94% <ø> (ø)
svf/include/SVFIR/SVFValue.h 90.00% <ø> (-0.79%) ⬇️
svf/lib/Util/SVFBugReport.cpp 19.27% <ø> (-0.32%) ⬇️
svf-llvm/lib/LLVMUtil.cpp 72.68% <82.81%> (+3.11%) ⬆️
svf-llvm/lib/SVFIRExtAPI.cpp 80.57% <83.17%> (+0.25%) ⬆️
svf-llvm/lib/SVFIRBuilder.cpp 78.15% <85.71%> (+0.08%) ⬆️
svf/lib/Util/ExtAPI.cpp 97.67% <96.15%> (+41.27%) ⬆️
svf-llvm/include/SVF-LLVM/LLVMModule.h 97.91% <100.00%> (+10.13%) ⬆️
svf-llvm/include/SVF-LLVM/LLVMUtil.h 76.25% <100.00%> (+2.91%) ⬆️
... and 4 more

... and 7 files with indirect coverage changes

/// if this function is declaration
candidateDecls.insert(&func);
removedFuncList.push_back(&func);
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

@@ -827,6 +830,64 @@ void LLVMModuleSet::buildFunToFunMap()
decls.push_back(decl);
}
}

/// App Func decl -> SVF extern Func def
Copy link
Collaborator

Choose a reason for hiding this comment

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

rewrite the comments to state the three cases.

for (const Function* extfun : extFuncs)
{
std::string declName = fdecl->getName().str();
// Change function like llvm.memcpy.p0i8.p0i8.i64 to llvm_memcpy_p0i8_p0i8_i64
Copy link
Collaborator

Choose a reason for hiding this comment

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

explain reason

}

/// Overwrite
/// App Func def -> SVF extern Func def
Copy link
Collaborator

Choose a reason for hiding this comment

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

put the table as comments here.

@shuangxiangkan
Copy link
Contributor Author

extapi.c/ExtAPI.json:
38.008/40.965,
43.949/45.621,
30.198/31.855

SVF with extapi.c:
Andersen Pointer Analysis Stats******
################ (program : vi.bc)###############

TotalTime 38.008
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 51.8628
AvgTopLvlPtsSize 153.607
TotalPointers 341440
TotalObjects 17890
IndCallSites 515
AddrProcessed 19941
CopyProcessed 200014
GepProcessed 86211
LoadProcessed 1218658
StoreProcessed 359661
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 340305
MemObjects 15501
DummyFieldPtrs 1135
FieldObjs 2389
MaxPtsSetSize 415
SolveIterations 10
IndEdgeSolved 1721
NumOfSCCDetect 10
TotalCycleNum 324
TotalPWCCycleNum 101
NodesInCycles 3913
MaxNodesInSCC 1597
NullPointer 161
PointsToConstPtr 14702
PointsToBlkPtr 0
#######################################################

SVF with ExtAPI.json:
Andersen Pointer Analysis Stats******
################ (program : vi.bc)###############

TotalTime 40.965
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 52.0716
AvgTopLvlPtsSize 154.493
TotalPointers 341083
TotalObjects 18074
IndCallSites 515
AddrProcessed 19883
CopyProcessed 197242
GepProcessed 85748
LoadProcessed 1264901
StoreProcessed 374892
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 339949
MemObjects 15680
DummyFieldPtrs 1134
FieldObjs 2394
MaxPtsSetSize 423
SolveIterations 11
IndEdgeSolved 1721
NumOfSCCDetect 11
TotalCycleNum 327
TotalPWCCycleNum 101
NodesInCycles 3922
MaxNodesInSCC 1597
NullPointer 162
PointsToConstPtr 14486
PointsToBlkPtr 0
#######################################################

SVF with extapi.c:
Andersen Pointer Analysis Stats******
################ (program : evim.bc)###############

TotalTime 43.949
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 50.3127
AvgTopLvlPtsSize 144.956
TotalPointers 384248
TotalObjects 21318
IndCallSites 566
AddrProcessed 22795
CopyProcessed 213409
GepProcessed 92796
LoadProcessed 1331323
StoreProcessed 389037
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 382946
MemObjects 17877
DummyFieldPtrs 1302
FieldObjs 3441
MaxPtsSetSize 426
SolveIterations 10
IndEdgeSolved 1739
NumOfSCCDetect 10
TotalCycleNum 342
TotalPWCCycleNum 106
NodesInCycles 4052
MaxNodesInSCC 1597
NullPointer 2313
PointsToConstPtr 15467
PointsToBlkPtr 0
#######################################################

SVF with ExtAPI.json:
Andersen Pointer Analysis Stats******
################ (program : evim.bc)###############

TotalTime 45.621
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 50.3631
AvgTopLvlPtsSize 145.342
TotalPointers 383856
TotalObjects 21525
IndCallSites 566
AddrProcessed 22726
CopyProcessed 210263
GepProcessed 92339
LoadProcessed 1382274
StoreProcessed 405518
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 382555
MemObjects 18074
DummyFieldPtrs 1301
FieldObjs 3451
MaxPtsSetSize 433
SolveIterations 11
IndEdgeSolved 1739
NumOfSCCDetect 11
TotalCycleNum 347
TotalPWCCycleNum 106
NodesInCycles 4062
MaxNodesInSCC 1597
NullPointer 2315
PointsToConstPtr 15246
PointsToBlkPtr 0
#######################################################

SVF with extapi.c:
################ (program : bash.bc)###############

TotalTime 30.198
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 60.5401
AvgTopLvlPtsSize 176.517
TotalPointers 223771
TotalObjects 14036
IndCallSites 68
AddrProcessed 14944
CopyProcessed 123846
GepProcessed 38938
LoadProcessed 924289
StoreProcessed 300773
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 222831
MemObjects 12772
DummyFieldPtrs 940
FieldObjs 1264
MaxPtsSetSize 323
SolveIterations 9
IndEdgeSolved 1349
NumOfSCCDetect 9
TotalCycleNum 212
TotalPWCCycleNum 25
NodesInCycles 2113
MaxNodesInSCC 263
NullPointer 576
PointsToConstPtr 12220
PointsToBlkPtr 0
#######################################################

SVF with ExtAPI.json:
Andersen Pointer Analysis Stats******
################ (program : bash.bc)###############

TotalTime 31.855
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 62.0863
AvgTopLvlPtsSize 180.973
TotalPointers 223360
TotalObjects 13954
IndCallSites 68
AddrProcessed 14853
CopyProcessed 120665
GepProcessed 36848
LoadProcessed 1107860
StoreProcessed 388316
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 222421
MemObjects 12692
DummyFieldPtrs 939
FieldObjs 1262
MaxPtsSetSize 354
SolveIterations 9
IndEdgeSolved 1349
NumOfSCCDetect 9
TotalCycleNum 218
TotalPWCCycleNum 25
NodesInCycles 2153
MaxNodesInSCC 263
NullPointer 633
PointsToConstPtr 11601
PointsToBlkPtr 0
#######################################################

if (func.isDeclaration())
/// Remove unused function in extapi.bc module
/// if this function func defined in extapi.bc but never used in application code (without any corresponding declared functions).
if (mod.getName().str() == Options::ExtAPIInput() && func.getName().str() != "svf__main" && FunDefToDeclsMap.find(&func) == FunDefToDeclsMap.end()
Copy link
Collaborator

Choose a reason for hiding this comment

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

put this condition in a new method.

@@ -827,6 +830,94 @@ void LLVMModuleSet::buildFunToFunMap()
decls.push_back(decl);
}
}

/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

put these comments before the function.

Fix AppDef -> ExtDef/ExtDef -> AppDef (overwrite).

Give each case an example.

@shuangxiangkan shuangxiangkan changed the title Replace ExAPI.json with extapi.c Replace ExAPI.json with extapi.c (extapi.c explaination wiki: https://github.com/SVF-tools/SVF/wiki/Handling-External-APIs-with-extapi.c) Aug 16, 2023
@yuleisui yuleisui merged commit 860b891 into SVF-tools:master Aug 16, 2023
3 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.

None yet

2 participants