Skip to content

Commit

Permalink
Update svflib
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleisui committed Aug 16, 2023
1 parent a3952c8 commit ce954c4
Show file tree
Hide file tree
Showing 11 changed files with 2,146 additions and 496 deletions.
1 change: 1 addition & 0 deletions SVF-linux/Release-build/include/Util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define CONFIG_H_IN

#define PROJECT_PATH "/home/runner/work/SVF/SVF"
#define EXTAPI_PATH PROJECT_PATH "/Release-build/include/Util"

#endif
2,084 changes: 2,084 additions & 0 deletions SVF-linux/Release-build/include/Util/extapi.bc

Large diffs are not rendered by default.

Binary file modified SVF-linux/Release-build/svf-llvm/libSvfLLVM.a
Binary file not shown.
Binary file modified SVF-linux/Release-build/svf/libSvfCore.a
Binary file not shown.
17 changes: 17 additions & 0 deletions SVF-linux/svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Util/CppUtil.h"
#include "SVFIR/SVFValue.h"
#include "SVFIR/SVFModule.h"
#include "Util/Options.h"

namespace SVF
{
Expand Down Expand Up @@ -74,6 +75,8 @@ class LLVMModuleSet
FunDeclToDefMapTy FunDeclToDefMap;
/// Function definition to function declaration map
FunDefToDeclsMapTy FunDefToDeclsMap;
/// Record some "sse_" function declarations used in other ext function definition, e.g., svf_ext_foo(), and svf_ext_foo() used in app functions
FunctionSetType ExtFuncsVec;
/// Global definition to a rep definition map
GlobalDefToRepMapTy GlobalDefToRepMap;

Expand Down Expand Up @@ -233,6 +236,20 @@ class LLVMModuleSet

SVFOtherValue* getSVFOtherValue(const Value* ov);

/// Remove unused function in extapi.bc module
bool isUsedExtFunction(Function* func)
{
/// if this function func defined in extapi.bc but never used in application code (without any corresponding declared functions).
if (func->getParent()->getName().str() == Options::ExtAPIInput()
&& func->getName().str() != "svf__main"
&& FunDefToDeclsMap.find(func) == FunDefToDeclsMap.end()
&& std::find(ExtFuncsVec.begin(), ExtFuncsVec.end(), func) == ExtFuncsVec.end())
{
return true;
}
return false;
}

/// Get the corresponding Function based on its name
inline const SVFFunction* getSVFFunction(const std::string& name)
{
Expand Down
15 changes: 14 additions & 1 deletion SVF-linux/svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "SVF-LLVM/BasicTypes.h"
#include "SVF-LLVM/LLVMModule.h"
#include "SVFIR/SVFValue.h"
#include "Util/ExtAPI.h"
#include "Util/ThreadAPI.h"

namespace SVF
Expand Down Expand Up @@ -373,6 +372,20 @@ const std::string getSourceLocOfFunction(const Function* F);
bool isIntrinsicInst(const Instruction* inst);
bool isIntrinsicFun(const Function* func);

/// Get all called funcions in a parent function
std::vector<const Function *> getCalledFunctions(const Function *F);
std::vector<std::string> getFunAnnotations(const Function* fun);
void removeFunAnnotations(std::vector<Function*>& removedFuncList);

inline void removeUnusedFuncsAndAnnotations(std::vector<Function*> removedFuncList)
{
/// Remove unused function annotations in extapi.bc
LLVMUtil::removeFunAnnotations(removedFuncList);
/// Remove unused function in extapi.bc
for (Function* func : removedFuncList)
func->eraseFromParent();
}

/// Get the corresponding Function based on its name
inline const SVFFunction* getFunction(const std::string& name)
{
Expand Down
19 changes: 5 additions & 14 deletions SVF-linux/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#define PAGBUILDER_H_

#include "SVFIR/SVFIR.h"
#include "Util/ExtAPI.h"
#include "SVF-LLVM/BasicTypes.h"
#include "SVF-LLVM/ICFGBuilder.h"
#include "SVF-LLVM/LLVMModule.h"
#include "SVF-LLVM/LLVMUtil.h"

namespace SVF
{
Expand Down Expand Up @@ -232,18 +232,9 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>

/// Handle external call
//@{
virtual SVFCallInst* addSVFExtCallInst(const SVFCallInst* svfInst, SVFBasicBlock* svfBB, const SVFFunction* svfCaller, const SVFFunction* svfCallee);
virtual void addSVFExtRetInst(SVFCallInst* svfCall, SVFBasicBlock* svfBB, SVFFunction* svfCaller);
virtual SVFInstruction* addSVFExtInst(const std::string& instName, const SVFCallInst* svfInst, SVFBasicBlock* svfBB, SVF::ExtAPI::OperationType opType, const SVFType* svfType);
virtual void extFuncAtomaticOperation(ExtAPI::Operand& atomicOp, const SVFCallInst* svfInst);
virtual SVFBasicBlock* extFuncInitialization(const SVFCallInst* svfInst, SVFFunction* svfCaller);
virtual void handleExtCallStat(ExtAPI::ExtFunctionOps &extFunctionOps, const SVFCallInst* svfInst);
virtual NodeID getExtID(ExtAPI::OperationType operationType, const std::string &s, const SVFCallInst* svfCall);
virtual void parseAtomaticOp(SVF::ExtAPI::Operand &atomaticOp, const SVFCallInst* svfCall, std::map<std::string, NodeID> &nodeIDMap);
virtual void parseExtFunctionOps(ExtAPI::ExtFunctionOps &extFunctionOps, const SVFCallInst* svfCall);
virtual void preProcessExtCall(CallBase* cs);
virtual void handleExtCall(const SVFInstruction* svfInst, const SVFFunction* svfCallee);
void addComplexConsForExt(const SVFValue* D, const SVFValue* S, const SVFValue* sz);
virtual const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<AccessPath> &fields, const Value* szValue);
virtual void addComplexConsForExt(Value *D, Value *S, const Value* sz);
virtual void handleExtCall(const CallBase* cs, const SVFFunction* svfCallee);
//@}

/// Set current basic block in order to keep track of control flow information
Expand Down Expand Up @@ -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& ap, const SVFType* elementType);

void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);

Expand Down
1 change: 0 additions & 1 deletion SVF-linux/svf/include/SVFIR/SVFModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#define INCLUDE_SVFMODULE_H_

#include "SVFIR/SVFValue.h"
#include "Util/ExtAPI.h"
#include "Util/NodeIDAllocator.h"
#include "Util/ThreadAPI.h"

Expand Down
8 changes: 7 additions & 1 deletion SVF-linux/svf/include/SVFIR/SVFValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

protected:
///@{ attributes to be set only through Module builders e.g., LLVMModule
Expand Down Expand Up @@ -322,7 +323,7 @@ class SVFFunction : public SVFValue
/// @}

public:
SVFFunction(const SVFType* ty,const SVFFunctionType* ft, bool declare, bool intrinsic, bool addrTaken, bool varg, SVFLoopAndDomInfo* ld);
SVFFunction(const SVFType* ty,const SVFFunctionType* ft, bool declare, bool intrinsic, bool addrTaken, bool varg, SVFLoopAndDomInfo* ld, std::vector<std::string> annos);
SVFFunction(void) = delete;
virtual ~SVFFunction();

Expand Down Expand Up @@ -430,6 +431,11 @@ class SVFFunction : public SVFValue
return isNotRet;
}

inline const std::vector<std::string>& getAnnotations() const
{
return annotations;
}

inline void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const
{
return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
Expand Down
Loading

0 comments on commit ce954c4

Please sign in to comment.