Skip to content

Commit

Permalink
Merge pull request #1528 from yuleisui/master
Browse files Browse the repository at this point in the history
refactor SVFInstruction stage 5
  • Loading branch information
yuleisui authored Aug 23, 2024
2 parents a9be281 + fe4b1b3 commit e1ce6a0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 73 deletions.
2 changes: 1 addition & 1 deletion svf/include/Graphs/IRGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
u32_t totalPTAPAGEdge;
ValueToEdgeMap valueToEdgeMap; ///< Map SVFValues (e.g., SVFInstruction) to all corresponding PAGEdges
ValueToEdgeMap valueToEdgeMap; ///< Map SVFValues (e.g., ICFGNodes) to all corresponding PAGEdges
SymbolTableInfo* symInfo;

/// Add a node into the graph
Expand Down
2 changes: 0 additions & 2 deletions svf/include/Graphs/ThreadCallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ class ThreadCallGraph: public CallGraph
public:
typedef Set<const CallICFGNode*> InstSet;
typedef InstSet CallSiteSet;
typedef std::vector<const SVFInstruction*> InstVector;
typedef Map<const SVFInstruction*, InstSet> CallToInstMap;
typedef Set<CallSiteSet*> CtxSet;
typedef ThreadForkEdge::ForkEdgeSet ForkEdgeSet;
typedef Map<const CallICFGNode*, ForkEdgeSet> CallInstToForkEdgesMap;
Expand Down
2 changes: 0 additions & 2 deletions svf/include/MTA/MHP.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class MHP

public:
typedef Set<const SVFFunction*> FunSet;
typedef Set<const SVFInstruction*> InstSet;
typedef std::vector<const SVFInstruction*> InstVec;
typedef FIFOWorkList<CxtThreadStmt> CxtThreadStmtWorkList;
typedef Set<CxtThreadStmt> CxtThreadStmtSet;
typedef Map<CxtThreadStmt,NodeBS> ThreadStmtToThreadInterleav;
Expand Down
3 changes: 0 additions & 3 deletions svf/include/MTA/MTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class MTA
{

public:
typedef Set<const SVFInstruction*> LoadSet;
typedef Set<const SVFInstruction*> StoreSet;

/// Constructor
MTA();

Expand Down
24 changes: 4 additions & 20 deletions svf/include/SABER/SaberCheckerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,9 @@ class SaberCheckerAPI
{
return getType(fun) == CK_ALLOC;
}
inline bool isMemAlloc(const SVFInstruction* inst) const
{
return getType(SVFUtil::getCallee(inst)) == CK_ALLOC;
}
inline bool isMemAlloc(const CallICFGNode* cs) const
{
return isMemAlloc(cs->getCallSite());
return isMemAlloc(SVFUtil::getCallee(cs->getCallSite()));
}
//@}

Expand All @@ -117,13 +113,9 @@ class SaberCheckerAPI
{
return getType(fun) == CK_FREE;
}
inline bool isMemDealloc(const SVFInstruction *inst) const
{
return getType(SVFUtil::getCallee(inst)) == CK_FREE;
}
inline bool isMemDealloc(const CallICFGNode* cs) const
{
return isMemDealloc(cs->getCallSite());
return isMemDealloc(SVFUtil::getCallee(cs->getCallSite()));
}
//@}

Expand All @@ -133,13 +125,9 @@ class SaberCheckerAPI
{
return getType(fun) == CK_FOPEN;
}
inline bool isFOpen(const SVFInstruction* inst) const
{
return getType(SVFUtil::getCallee(inst)) == CK_FOPEN;
}
inline bool isFOpen(const CallICFGNode* cs) const
{
return isFOpen(cs->getCallSite());
return isFOpen(SVFUtil::getCallee(cs->getCallSite()));
}
//@}

Expand All @@ -149,13 +137,9 @@ class SaberCheckerAPI
{
return getType(fun) == CK_FCLOSE;
}
inline bool isFClose(const SVFInstruction* inst) const
{
return getType(SVFUtil::getCallee(inst)) == CK_FCLOSE;
}
inline bool isFClose(const CallICFGNode* cs) const
{
return isFClose(cs->getCallSite());
return isFClose(SVFUtil::getCallee(cs->getCallSite()));
}
//@}

Expand Down
41 changes: 1 addition & 40 deletions svf/include/Util/SVFUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ inline CallSite getSVFCallSite(const SVFInstruction* inst)
/// Match arguments for callsite at caller and callee
/// if the arg size does not match then we do not need to connect this parameter
/// unless the callee is a variadic function (the first parameter of variadic function is its parameter number)
bool matchArgs(const SVFInstruction* cs, const SVFFunction* callee);
bool matchArgs(const CallSite cs, const SVFFunction* callee);

/// Return LLVM callsite given a value
inline CallSite getSVFCallSite(const SVFValue* value)
Expand Down Expand Up @@ -466,24 +466,13 @@ inline int getHeapAllocHoldingArgPosition(const CallSite cs)
{
return getHeapAllocHoldingArgPosition(getCallee(cs));
}

inline int getHeapAllocHoldingArgPosition(const SVFInstruction *inst)
{
return getHeapAllocHoldingArgPosition(getCallee(inst));
}
//@}

inline bool isReallocExtCall(const CallSite cs)
{
bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
return isPtrTy && isReallocExtFun(getCallee(cs));
}

inline bool isReallocExtCall(const SVFInstruction *inst)
{
bool isPtrTy = inst->getType()->isPointerTy();
return isPtrTy && isReallocExtFun(getCallee(inst));
}
//@}

/// Return true if this is a thread creation call
Expand All @@ -504,10 +493,6 @@ inline bool isThreadJoinCall(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->isTDJoin(cs.getInstruction());
}
inline bool isThreadJoinCall(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->isTDJoin(inst);
}
//@}

/// Return true if this is a thread exit call
Expand All @@ -516,10 +501,6 @@ inline bool isThreadExitCall(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->isTDExit(cs.getInstruction());
}
inline bool isThreadExitCall(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->isTDExit(inst);
}
//@}

/// Return true if this is a lock acquire call
Expand All @@ -528,10 +509,6 @@ inline bool isLockAquireCall(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->isTDAcquire(cs.getInstruction());
}
inline bool isLockAquireCall(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->isTDAcquire(inst);
}
//@}

/// Return true if this is a lock acquire call
Expand All @@ -540,10 +517,6 @@ inline bool isLockReleaseCall(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->isTDRelease(cs.getInstruction());
}
inline bool isLockReleaseCall(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->isTDRelease(inst);
}
//@}

/// Return true if this is a barrier wait call
Expand All @@ -552,10 +525,6 @@ inline bool isBarrierWaitCall(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->isTDBarWait(cs.getInstruction());
}
inline bool isBarrierWaitCall(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->isTDBarWait(inst);
}
//@}

/// Return sole argument of the thread routine
Expand All @@ -564,10 +533,6 @@ inline const SVFValue* getActualParmAtForkSite(const CallSite cs)
{
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs.getInstruction());
}
inline const SVFValue* getActualParmAtForkSite(const SVFInstruction *inst)
{
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(inst);
}
//@}


Expand All @@ -576,10 +541,6 @@ inline bool isProgExitCall(const CallSite cs)
return isProgExitFunction(getCallee(cs));
}

inline bool isProgExitCall(const SVFInstruction *inst)
{
return isProgExitFunction(getCallee(inst));
}

template<typename T>
constexpr typename std::remove_reference<T>::type &&
Expand Down
2 changes: 1 addition & 1 deletion svf/lib/SABER/SaberCondAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void SaberCondAllocator::collectBBCallingProgExit(const SVFBasicBlock &bb)
{
const SVFInstruction* svfInst = *it;
if (SVFUtil::isCallSite(svfInst))
if (SVFUtil::isProgExitCall(svfInst))
if (SVFUtil::isProgExitCall(SVFUtil::getSVFCallSite(svfInst)))
{
const SVFFunction* svfun = bb.getParent();
funToExitBBsMap[svfun].insert(&bb);
Expand Down
8 changes: 4 additions & 4 deletions svf/lib/Util/SVFUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ void SVFUtil::stopAnalysisLimitTimer(bool limitTimerSet)
/// unless the callee is a variadic function (the first parameter of variadic function is its parameter number)
/// e.g., void variadicFoo(int num, ...); variadicFoo(5, 1,2,3,4,5)
/// for variadic function, callsite arg size must be greater than or equal to callee arg size
bool SVFUtil::matchArgs(const SVFInstruction* cs, const SVFFunction* callee)
bool SVFUtil::matchArgs(const CallSite cs, const SVFFunction* callee)
{
if (callee->isVarArg() || ThreadAPI::getThreadAPI()->isTDFork(cs))
return getSVFCallSite(cs).arg_size() >= callee->arg_size();
if (callee->isVarArg() || ThreadAPI::getThreadAPI()->isTDFork(cs.getInstruction()))
return cs.arg_size() >= callee->arg_size();
else
return getSVFCallSite(cs).arg_size() == callee->arg_size();
return cs.arg_size() == callee->arg_size();
}

0 comments on commit e1ce6a0

Please sign in to comment.