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, using attributes to represent some … #1157

Closed
wants to merge 8 commits into from

Conversation

shuangxiangkan
Copy link
Contributor

…SVF operations

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #1157 (e36ae77) into master (3f20e97) will increase coverage by 0.05%.
Report is 23 commits behind head on master.
The diff coverage is 86.74%.

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

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1157      +/-   ##
==========================================
+ Coverage   64.68%   64.73%   +0.05%     
==========================================
  Files         223      222       -1     
  Lines       23821    23477     -344     
==========================================
- Hits        15408    15198     -210     
+ Misses       8413     8279     -134     
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-llvm/lib/LLVMModule.cpp 82.24% <91.30%> (+1.88%) ⬆️
svf/lib/Util/ExtAPI.cpp 97.67% <96.15%> (+41.27%) ⬆️
svf-llvm/include/SVF-LLVM/LLVMUtil.h 76.25% <100.00%> (+2.91%) ⬆️
... and 3 more

... and 20 files with indirect coverage changes

@@ -292,6 +292,7 @@ class SVFFunction : public SVFValue
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
std::vector<const SVFBasicBlock*> allBBs; /// all BasicBlocks of this function
std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
std::vector<std::string> annotations; /// annotations of this function
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use one string?

@@ -1257,10 +1187,10 @@ void SVFIRBuilder::sanityCheck()
* Add a temp field value node according to base value and offset
* this node is after the initial node method, it is out of scope of symInfo table
*/
NodeID SVFIRBuilder::getGepValVar(const SVFValue* val, const AccessPath& ap, const SVFType* elementType)
NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ls, const SVFType* elementType)
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename ls => ap

@@ -99,6 +98,121 @@ inline const Function* getProgFunction(const std::string& funName)
return nullptr;
}

inline std::vector<std::string> getFunAnnotations(const Function* fun)
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 function body into LLVMUtil.cpp

Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this function

return annotations;
}

inline void removeFunAnnotations(const std::vector<Function*>& removedFuncList) {
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 function body into LLVMUtil.cpp

Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this function

CMakeLists.txt Outdated
@@ -87,3 +87,19 @@ install(
DESTINATION include/svf
FILES_MATCHING
PATTERN "**/*.h")

# Compile extapi.c to extapi.bc
string(REGEX REPLACE "/lib/cmake/llvm$" "" LLVM_DIR "${LLVM_DIR}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this part

Copy link
Collaborator

@yuleisui yuleisui left a comment

Choose a reason for hiding this comment

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

Post benchmark statistics of 2-3 large bcs, including time and other stats.

@@ -99,6 +98,121 @@ inline const Function* getProgFunction(const std::string& funName)
return nullptr;
}

inline std::vector<std::string> getFunAnnotations(const Function* fun)
Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this function

return annotations;
}

inline void removeFunAnnotations(const std::vector<Function*>& removedFuncList) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify this function

@@ -287,7 +278,7 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
return nullPtr;
}

NodeID getGepValVar(const SVFValue* val, const AccessPath& ap, const SVFType* baseType);
NodeID getGepValVar(const Value* val, const AccessPath& ls, const SVFType* elementType);
Copy link
Collaborator

Choose a reason for hiding this comment

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

const AccessPath& ls => const AccessPath& ap;


for (Module& mod : modules)
{
std::vector<Function*> removedFuncList;
/// Function
for (Function& func : mod.functions())
{
if (func.isDeclaration())
if (func.isDeclaration() && (FunDefToDeclsMap.find(&func) != FunDefToDeclsMap.end() || mod.getName().str() != Options::ExtAPIInput()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix this and put the later conditions inside the if branch. Add comments to explain this.

}
else
{
/// if this function is definition
if (mod.getName().str() == Options::ExtAPIInput() && FunDefToDeclsMap[&func].empty() && func.getName().str() != "svf__main")
if (mod.getName().str() == Options::ExtAPIInput() && FunDefToDeclsMap.find(&func) == FunDefToDeclsMap.end() && func.getName().str() != "svf__main")
Copy link
Collaborator

Choose a reason for hiding this comment

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

combine this condition and the above one into a method. Use the method as a condtion.

Comment on lines 188 to 193
// Remove unused function annotations in extapi.bc
LLVMUtil::removeFunAnnotations(removedFuncList);
// Remove unused function in extapi.bc
for (Function* func : removedFuncList)
{
mod.getFunctionList().remove(func);
func->eraseFromParent();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make this as one function.

Comment on lines 560 to 562
// The module of ext.bc needs to be imported before other modules.
// Otherwise, when overwriting the app function with SVF extern function,
// the corresponding SVFFunction of the extern function will not be found.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure the comments reflect what your code is. Put an example.

@shuangxiangkan
Copy link
Contributor Author

extapi.bc

Andersen Pointer Analysis Stats******
################ (program : vi.bc)###############

TotalTime 37.248
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 51.8631
AvgTopLvlPtsSize 153.607
TotalPointers 341438
TotalObjects 17890
IndCallSites 515
AddrProcessed 19941
CopyProcessed 200014
GepProcessed 86211
LoadProcessed 1218658
StoreProcessed 359661
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 340303
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
#######################################################

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

TotalTime 39.981
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
#######################################################

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

TotalTime 43.145
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 50.3129
AvgTopLvlPtsSize 144.956
TotalPointers 384246
TotalObjects 21318
IndCallSites 566
AddrProcessed 22795
CopyProcessed 213409
GepProcessed 92796
LoadProcessed 1331323
StoreProcessed 389037
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 382944
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
#######################################################

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

TotalTime 44.063
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
#######################################################

extapi.bc
Andersen Pointer Analysis Stats******
################ (program : bash.bc)###############

TotalTime 30.111
CollapseTime 0
SCCDetectTime 0
SCCMergeTime 0
LoadStoreTime 0
CopyGepTime 0
UpdateCGTime 0
AvgPtsSetSize 60.5406
AvgTopLvlPtsSize 176.517
TotalPointers 223769
TotalObjects 14036
IndCallSites 68
AddrProcessed 14944
CopyProcessed 123846
GepProcessed 38938
LoadProcessed 924289
StoreProcessed 300773
NumOfSFRs 0
NumOfFieldExpand 0
Pointers 222829
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
#######################################################

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

TotalTime 31.828
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
#######################################################

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