8000 Remove getCallee in AE by yuleisui · Pull Request #1537 · SVF-tools/SVF · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove getCallee in AE #1537

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

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion svf-llvm/lib/ICFGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ InterICFGNode* ICFGBuilder::addInterBlockICFGNode(const SVFInstruction* inst)
assert(SVFUtil::isNonInstricCallSite(inst) && "associating an intrinsic debug instruction with an ICFGNode!");
CallICFGNode* callICFGNode = icfg->addCallICFGNode(inst);
(void) icfg->addRetICFGNode(inst);
addICFGInterEdges(inst, getCallee(inst)); //creating interprocedural edges
addICFGInterEdges(inst, callICFGNode->getCalledFunction()); //creating interprocedural edges
return callICFGNode;
}

Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/SymbolTableBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
else if(SVFUtil::isHeapAllocExtCallViaArg(svfinst))
{
const CallBase* cs = LLVMUtil::getLLVMCallSite(inst);
int arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(getCallee(svfinst));
u32_t arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(SVFUtil::cast<SVFCallInst>(svfinst)->getCalledFunction());

Check warning on line 611 in svf-llvm/lib/SymbolTableBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf-llvm/lib/SymbolTableBuilder.cpp#L611

Added line #L611 was not covered by tests
const Value* arg = cs->getArgOperand(arg_pos);
originalPType = SVFUtil::dyn_cast<PointerType>(arg->getType());
inferedType = inferObjType(startValue = arg);
Expand Down
2 changes: 1 addition & 1 deletion svf/include/Graphs/ICFGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class CallICFGNode : public InterICFGNode
/// Return true if this is an indirect call
inline bool isIndirectCall() const
{
return nullptr == SVFUtil::getCallee(cs);
return nullptr == SVFUtil::cast<SVFCallInst>(cs)->getCalledFunction();
}

/// Return the set of actual parameters
Expand Down
12 changes: 9 additions & 3 deletions svf/include/MTA/LockAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,17 +437,23 @@
/// Whether it is a lock site
inline bool isTDFork(const ICFGNode* call)
{
return getTCG()->getThreadAPI()->isTDFork(call);
if(SVFUtil::isa<CallICFGNode>(call) == false)

Check warning on line 440 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L440

Added line #L440 was not covered by tests
return false;
return getTCG()->getThreadAPI()->isTDFork(SVFUtil::cast<CallICFGNode>(call));

Check warning on line 442 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L442

Added line #L442 was not covered by tests
}
/// Whether it is a lock site
inline bool isTDAcquire(const ICFGNode* call)
{
return getTCG()->getThreadAPI()->isTDAcquire(call);
if(SVFUtil::isa<CallICFGNode>(call) == false)

Check warning on line 447 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L447

Added line #L447 was not covered by tests
return false;
return getTCG()->getThreadAPI()->isTDAcquire(SVFUtil::cast<CallICFGNode>(call));

Check warning on line 449 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L449

Added line #L449 was not covered by tests
}
/// Whether it is a unlock site
inline bool isTDRelease(const ICFGNode* call)
{
return getTCG()->getThreadAPI()->isTDRelease(call);
if(SVFUtil::isa<CallICFGNode>(call) == false)

Check warning on line 454 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L454

Added line #L454 was not covered by tests
return false;
return getTCG()->getThreadAPI()->isTDRelease(SVFUtil::cast<CallICFGNode>(call));

Check warning on line 456 in svf/include/MTA/LockAnalysis.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/LockAnalysis.h#L456

Added line #L456 was not covered by tests
}
/// Whether it is a callsite
inline bool isCallSite(const ICFGNode* inst)
Expand Down
16 changes: 10 additions & 6 deletions svf/include/MTA/MHP.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,14 @@ class MHP
/// Whether it is a fork site
inline bool isTDFork(const ICFGNode* call)
{
return tcg->getThreadAPI()->isTDFork(call);
const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
return fork && tcg->getThreadAPI()->isTDFork(fork);
}
/// Whether it is a join site
inline bool isTDJoin(const ICFGNode* call)
{
return tcg->getThreadAPI()->isTDJoin(call);
const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
return join && tcg->getThreadAPI()->isTDJoin(join);
}

/// Return thread id(s) which are directly or indirectly joined at this join site
Expand Down Expand Up @@ -345,11 +347,11 @@ class ForkJoinAnalysis
}

/// Get loop for join site
inline LoopBBs& getJoinLoop(const ICFGNode* inst)
inline LoopBBs& getJoinLoop(const CallICFGNode* inst)
{
return tct->getJoinLoop(inst);
}
inline bool hasJoinLoop(const ICFGNode* inst)
inline bool hasJoinLoop(const CallICFGNode* inst)
{
return tct->hasJoinLoop(inst);
}
Expand Down Expand Up @@ -461,12 +463,14 @@ class ForkJoinAnalysis
/// Whether it is a fork site
inline bool isTDFork(const ICFGNode* call)
{
return getTCG()->getThreadAPI()->isTDFork(call);
const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
return fork && getTCG()->getThreadAPI()->isTDFork(fork);
}
/// Whether it is a join site
inline bool isTDJoin(const ICFGNode* call)
{
return getTCG()->getThreadAPI()->isTDJoin(call);
const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
return join && getTCG()->getThreadAPI()->isTDJoin(join);
}
/// Get forked thread
inline const SVFValue* getForkedThread(const CallICFGNode* call)
Expand Down
6 changes: 3 additions & 3 deletions svf/include/MTA/TCT.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@
}

/// Get loop for join site
inline LoopBBs& getJoinLoop(const ICFGNode* join)
inline LoopBBs& getJoinLoop(const CallICFGNode* join)

Check warning on line 367 in svf/include/MTA/TCT.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/TCT.h#L367

Added line #L367 was not covered by tests
{
assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
InstToLoopMap::iterator it = joinSiteToLoopMap.find(join);
assert(it!=joinSiteToLoopMap.end() && "loop not found");
return it->second;
}

inline bool hasJoinLoop(const ICFGNode* join) const
inline bool hasJoinLoop(const CallICFGNode* join) const

Check warning on line 375 in svf/include/MTA/TCT.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/TCT.h#L375

Added line #L375 was not covered by tests
{
assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
InstToLoopMap::const_iterator it = joinSiteToLoopMap.find(join);
Expand Down Expand Up @@ -407,7 +407,7 @@
MaxCxtSize = cxt.size();
}
/// Whether a join site is in recursion
inline bool isJoinSiteInRecursion(const ICFGNode* join) const
inline bool isJoinSiteInRecursion(const CallICFGNode* join) const

Check warning on line 410 in svf/include/MTA/TCT.h

View check run for this annotation

Codecov / codecov/patch

svf/include/MTA/TCT.h#L410

Added line #L410 was not covered by tests
{
assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
return inRecurJoinSites.find(join)!=inRecurJoinSites.end();
Expand Down
8 changes: 4 additions & 4 deletions svf/include/SABER/SaberCheckerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SaberCheckerAPI
}
inline bool isMemAlloc(const CallICFGNode* cs) const
{
return isMemAlloc(SVFUtil::getCallee(cs->getCallSite()));
return isMemAlloc(cs->getCalledFunction());
}
//@}

Expand All @@ -115,7 +115,7 @@ class SaberCheckerAPI
}
inline bool isMemDealloc(const CallICFGNode* cs) const
{
return isMemDealloc(SVFUtil::getCallee(cs->getCallSite()));
return isMemDealloc(cs->getCalledFunction());
}
//@}

Expand All @@ -127,7 +127,7 @@ class SaberCheckerAPI
}
inline bool isFOpen(const CallICFGNode* cs) const
{
return isFOpen(SVFUtil::getCallee(cs->getCallSite()));
return isFOpen(cs->getCalledFunction());
}
//@}

Expand All @@ -139,7 +139,7 @@ class SaberCheckerAPI
}
inline bool isFClose(const CallICFGNode* cs) const
{
return isFClose(SVFUtil::getCallee(cs->getCallSite()));
return isFClose(cs->getCalledFunction());
}
//@}

Expand Down
61 changes: 12 additions & 49 deletions svf/include/Util/SVFUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,6 @@ inline std::vector<std::string> split(const std::string& s, char separator)
return output;
}

/// Return callee of a callsite. Return null if this is an indirect call
//@{
inline const SVFFunction* getCallee(const SVFCallInst* cs)
{
return cs->getCalledFunction();
}

inline const SVFFunction* getCallee(const SVFInstruction *inst)
{
if (!isCallSite(inst))
return nullptr;
return getCallee(cast<SVFCallInst>(inst));
}

const SVFFunction* getCallee(const CallICFGNode *inst);

const SVFFunction* getCallee(const ICFGNode *inst);
//@}

/// Given a map mapping points-to sets to a count, adds from into to.
template <typename Data>
void mergePtsOccMaps(Map<Data, unsigned> &to, const Map<Data, unsigned> from)
Expand Down Expand Up @@ -332,7 +313,7 @@ inline bool isHeapAllocExtFunViaArg(const SVFFunction* fun)

/// Get the position of argument that holds an allocated heap object.
//@{
inline int getHeapAllocHoldingArgPosition(const SVFFunction* fun)
inline u32_t getHeapAllocHoldingArgPosition(const SVFFunction* fun)
{
return ExtAPI::getExtAPI()->get_alloc_arg_pos(fun);
}
Expand Down Expand Up @@ -404,25 +385,13 @@ inline const SVFValue* getForkedFun(const CallICFGNode *inst)
//@}


inline bool isExtCall(const CallICFGNode* cs)
{
return isExtCall(getCallee(cs));
}
bool isExtCall(const CallICFGNode* cs);

bool isExtCall(const ICFGNode* node);

inline bool isHeapAllocExtCallViaArg(const CallICFGNode* cs)
{
return isHeapAllocExtFunViaArg(getCallee(cs));
}
bool isHeapAllocExtCallViaArg(const CallICFGNode* cs);

inline bool isHeapAllocExtCallViaArg(const SVFInstruction *inst)
{
if(const SVFCallInst* call = SVFUtil::dyn_cast<SVFCallInst>(inst))
return isHeapAllocExtFunViaArg(call->getCalledFunction());
else
return false;
}
bool isHeapAllocExtCallViaArg(const SVFInstruction *inst);

bool isHeapAllocExtCallViaRet(const SVFInstruction *inst);

Expand All @@ -438,58 +407,55 @@ inline bool isHeapAllocExtCall(const SVFInstruction *inst)

//@}

inline int getHeapAllocHoldingArgPosition(const CallICFGNode* cs)
{
return getHeapAllocHoldingArgPosition(getCallee(cs));
}
u32_t getHeapAllocHoldingArgPosition(const CallICFGNode* cs);
//@}

bool isReallocExtCall(const CallICFGNode* cs);
//@}

/// Return true if this is a thread creation call
///@{
inline bool isThreadForkCall(const ICFGNode *inst)
inline bool isThreadForkCall(const CallICFGNode *inst)
{
return ThreadAPI::getThreadAPI()->isTDFork(inst);
}
//@}

/// Return true if this is a thread join call
///@{
inline bool isThreadJoinCall(const ICFGNode* cs)
inline bool isThreadJoinCall(const CallICFGNode* cs)
{
return ThreadAPI::getThreadAPI()->isTDJoin(cs);
}
//@}

/// Return true if this is a thread exit call
///@{
inline bool isThreadExitCall(const ICFGNode* cs)
inline bool isThreadExitCall(const CallICFGNode* cs)
{
return ThreadAPI::getThreadAPI()->isTDExit(cs);
}
//@}

/// Return true if this is a lock acquire call
///@{
inline bool isLockAquireCall(const ICFGNode* cs)
inline bool isLockAquireCall(const CallICFGNode* cs)
{
return ThreadAPI::getThreadAPI()->isTDAcquire(cs);
}
//@}

/// Return true if this is a lock acquire call
///@{
inline bool isLockReleaseCall(const ICFGNode* cs)
inline bool isLockReleaseCall(const CallICFGNode* cs)
{
return ThreadAPI::getThreadAPI()->isTDRelease(cs);
}
//@}

/// Return true if this is a barrier wait call
//@{
inline bool isBarrierWaitCall(const ICFGNode* cs)
inline bool isBarrierWaitCall(const CallICFGNode* cs)
{
return ThreadAPI::getThreadAPI()->isTDBarWait(cs);
}
Expand All @@ -504,10 +470,7 @@ inline const SVFValue* getActualParmAtForkSite(const CallICFGNode* cs)
//@}


inline bool isProgExitCall(const CallICFGNode* cs)
{
return isProgExitFunction(getCallee(cs));
}
bool isProgExitCall(const CallICFGNode* cs);


template<typename T>
Expand Down
43 changes: 10 additions & 33 deletions svf/include/Util/ThreadAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,6 @@ class ThreadAPI
}
}

/// Return the callee/callsite/func
//@{
const SVFFunction* getCallee(const ICFGNode *inst) const;
//@}

/// Return true if this call create a new thread
//@{
inline bool isTDFork(const ICFGNode *inst) const
{
return getType(getCallee(inst)) == TD_FORK;
}
//@}

/// Return arguments/attributes of pthread_create / hare_parallel_for
//@{
/// Return the first argument of the call,
Expand All @@ -146,12 +133,14 @@ class ThreadAPI
const SVFValue* getActualParmAtForkSite(const CallICFGNode *inst) const;
//@}

/// Return true if this call create a new thread
//@{
bool isTDFork(const CallICFGNode *inst) const;
//@}

/// Return true if this call wait for a worker thread
//@{
inline bool isTDJoin(const ICFGNode *inst) const
{
return getType(getCallee(inst)) == TD_JOIN;
}
bool isTDJoin(const CallICFGNode *inst) const;
//@}

/// Return arguments/attributes of pthread_join
Expand All @@ -167,26 +156,17 @@ class ThreadAPI

/// Return true if this call exits/terminate a thread
//@{
inline bool isTDExit(const ICFGNode *inst) const
{
return getType(getCallee(inst)) == TD_EXIT;
}
bool isTDExit(const CallICFGNode *inst) const;
//@}

/// Return true if this call acquire a lock
//@{
inline bool isTDAcquire(const ICFGNode* inst) const
{
return getType(getCallee(inst)) == TD_ACQUIRE;
}
bool isTDAcquire(const CallICFGNode* inst) const;
//@}

/// Return true if this call release a lock
//@{
inline bool isTDRelease(const ICFGNode *inst) const
{
return getType(getCallee(inst)) == TD_RELEASE;
}
bool isTDRelease(const CallICFGNode *inst) const;
//@}

/// Return lock value
Expand All @@ -197,10 +177,7 @@ class ThreadAPI

/// Return true if this call waits for a barrier
//@{
inline bool isTDBarWait(const ICFGNode *inst) const
{
return getType(getCallee(inst)) == TD_BAR_WAIT;
}
bool isTDBarWait(const CallICFGNode *inst) const;
//@}

void performAPIStat(SVFModule* m);
Expand Down
Loading
Loading
0