Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SVF::MultiStageSlicer Class Reference

#include <MTASlicer.h>

Inheritance diagram for SVF::MultiStageSlicer:
SVF::MTASlicerBase

Public Member Functions

 MultiStageSlicer (SVFIR *svfIr, AndersenBase *pta, MHP *mhp, LockAnalysis *lockAnalysis, SVFG *vfg=nullptr)
 
OrderedSet< const ICFGNode * > runILASlicing (const OrderedSet< const SVFStmt * > &vulnerableStatements, const OrderedSet< const ICFGNode * > &threadVFSources={})
 
OrderedSet< const ICFGNode * > runPTASlicing (const OrderedSet< const SVFStmt * > &vulnerableStatements)
 
const OrderedSet< const VFGNode * > & getRetainedSVFGNodes (const OrderedSet< const SVFStmt * > &vulnerableStatements)
 
- Public Member Functions inherited from SVF::MTASlicerBase
 MTASlicerBase (SVFIR *svfIr, AndersenBase *pta, MHP *mhp, LockAnalysis *lockAnalysis, SVFG *vfg=nullptr)
 
virtual ~MTASlicerBase ()
 

Private Attributes

OrderedSet< const VFGNode * > retainedSVFGNodes
 memoised data-dependence slice
 
bool retainedComputed = false
 

Additional Inherited Members

- Protected Member Functions inherited from SVF::MTASlicerBase
OrderedSet< const ICFGNode * > sliceDataDependenceOverVFG (const OrderedSet< const SVFStmt * > &seeds, SVFG *vfg)
 
OrderedSet< const VFGNode * > computeDataDependenceSVFGNodes (const OrderedSet< const SVFStmt * > &seeds, SVFG *vfg)
 
OrderedSet< const ICFGNode * > svfgNodesToICFGNodes (const OrderedSet< const VFGNode * > &nodes, const OrderedSet< const SVFStmt * > &seeds)
 Project the retained VFG nodes (plus the seeds) onto their ICFG nodes.
 
OrderedSet< const SVFStmt * > getDependentThreadCreate (const SVFStmt *stmt)
 
OrderedSet< const TCTNode * > getTCTNodeSetFromNode (const ICFGNode *node)
 
OrderedSet< const ICFGNode * > getLockSet (const ICFGNode *node)
 
OrderedSet< const CallICFGNode * > collectPthreadStatements (const OrderedSet< const SVFStmt * > &vulnerableStmts)
 
OrderedSet< const CallICFGNode * > collectMutexStatements (const OrderedSet< const SVFStmt * > &vulnerableStmts)
 
std::pair< OrderedSet< const CallICFGNode * >, OrderedSet< const CallICFGNode * > > collectCommonThreadStatements (const OrderedSet< const SVFStmt * > &vulnerableStatements)
 
OrderedSet< const ICFGNode * > buildBackwardICFGNodeSet (const OrderedSet< const ICFGNode * > &vulnerableNodes)
 
OrderedSet< const ICFGNode * > expandCallDependence (const OrderedSet< const ICFGNode * > &nodes)
 
OrderedSet< const ICFGNode * > runDualSlicing (const OrderedSet< const ICFGNode * > &slicedNodes)
 
- Protected Attributes inherited from SVF::MTASlicerBase
SVFIRsvfIr
 
AndersenBasepta
 
MHPmhp
 
LockAnalysislockAnalysis
 
CallGraphcallGraph
 
SVFGvfg
 thread-aware VFG_pre (PTA/Single slicers; null for MTA)
 

Detailed Description

MultiStageSlicer - the multi-stage (differential) slicer of MSli: one class, two stages sharing one memoised data-dependence closure over VFG_pre. Stage 1 (ILA): runILASlicing – synchronization/dual slicing + function expansion, feeding the sliced MHP/lock. Stage 2 (FSPTA): runPTASlicing – backward data-dependence slice feeding the sliced flow-sensitive solve. Contrast: SingleSlicer below folds everything into ONE unified slice.

Definition at line 207 of file MTASlicer.h.

Constructor & Destructor Documentation

◆ MultiStageSlicer()

SVF::MultiStageSlicer::MultiStageSlicer ( SVFIR svfIr,
AndersenBase pta,
MHP mhp,
LockAnalysis lockAnalysis,
SVFG vfg = nullptr 
)

Definition at line 942 of file MTASlicer.cpp.

945{
946}
SVFG * vfg
thread-aware VFG_pre (PTA/Single slicers; null for MTA)
Definition MTASlicer.h:132
AndersenBase * pta
Definition MTASlicer.h:128
LockAnalysis * lockAnalysis
Definition MTASlicer.h:130

Member Function Documentation

◆ getRetainedSVFGNodes()

const OrderedSet< const SVFGNode * > & SVF::MultiStageSlicer::getRetainedSVFGNodes ( const OrderedSet< const SVFStmt * > &  vulnerableStatements)

The FSPTA data-dependence slice at SVFG-node granularity (memoised). The ILA stage queries this first, to restrict the [THREAD-VF] sources to ThreadVF(VFG'_pre); runPTASlicing reuses the same set, so the backward closure over VFG_pre is computed once and shared across both stages.

Definition at line 1010 of file MTASlicer.cpp.

1012{
1013 if (!retainedComputed)
1014 {
1016 retainedComputed = true;
1017 }
1018 return retainedSVFGNodes;
1019}
OrderedSet< const VFGNode * > computeDataDependenceSVFGNodes(const OrderedSet< const SVFStmt * > &seeds, SVFG *vfg)
OrderedSet< const VFGNode * > retainedSVFGNodes
memoised data-dependence slice
Definition MTASlicer.h:244
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ runILASlicing()

OrderedSet< const ICFGNode * > SVF::MultiStageSlicer::runILASlicing ( const OrderedSet< const SVFStmt * > &  vulnerableStatements,
const OrderedSet< const ICFGNode * > &  threadVFSources = {} 
)

Stage 1: the ILA slice (dual slicing + function expansion for the IRView).

Parameters
vulnerableStatementsSet of vulnerable statements to start slicing from (the [INIT] rule: pre-analysis race statements).
threadVFSourcesExtra ILA slicing sources from the [THREAD-VF] rule (MSli 4.2): statements whose MHP/lock-span results are queried during the main-phase thread-aware value-flow construction (endpoints and in-span non-interference witnesses collected while building VFG_pre).
Returns
Set of ICFG nodes in the slice (including call/ret and entry/exit nodes)

Definition at line 949 of file MTASlicer.cpp.

952{
953
954 // Step 1: Collect common pthread and mutex statements
958
959 // Step 2: Form initial slice result (before function expansion). The ILA
960 // slicing sources are the [INIT] race statements plus the [THREAD-VF]
961 // sources (MSli §4.2) extracted while building VFG_pre: the endpoints and
962 // in-span lock witnesses queried during main-phase value-flow construction.
966 {
967 initialSliceResult.insert(pthreadCallNode->getRetICFGNode());
968 }
969 initialSliceResult.insert(mutexCallNodes.begin(), mutexCallNodes.end());
971 {
972 initialSliceResult.insert(mutexCallNode->getRetICFGNode());
973 }
975 for (const SVFStmt* stmt: vulnerableStatements)
976 {
977 initialSliceResult.insert(stmt->getICFGNode());
978 }
980
981 // Retain loop-exit entry anchors. MHP seeds post-join interleaving directly at
982 // the loop-exit block entry of each join in a loop; keeping those entries makes
983 // the seed land on a kept node, so no runtime seed projection is needed. Reuses
984 // the shared FunObjVar::getExitBlocksOfLoop.
986 for (const CallICFGNode* c : pthreadCallNodes)
987 {
988 if (!threadAPI->isTDJoin(c) || c->getBB() == nullptr) continue;
989 std::vector<const SVFBasicBlock*> exitbbs;
990 c->getFun()->getExitBlocksOfLoop(c->getBB(), exitbbs);
991 for (const SVFBasicBlock* eb : exitbbs)
992 if (!eb->getICFGNodeList().empty())
993 initialSliceResult.insert(eb->front());
994 }
995
996 // Step 3: Perform dual slicing (temporal slicing)
998
999 // Step 4: Expand keptNodes to include call/ret nodes and function entry/exit
1000 // nodes (call dependence).
1002}
if(prebuffer< 0)
Definition cJSON.cpp:1269
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
Definition MHP.h:89
std::pair< OrderedSet< const CallICFGNode * >, OrderedSet< const CallICFGNode * > > collectCommonThreadStatements(const OrderedSet< const SVFStmt * > &vulnerableStatements)
OrderedSet< const ICFGNode * > expandCallDependence(const OrderedSet< const ICFGNode * > &nodes)
OrderedSet< const ICFGNode * > runDualSlicing(const OrderedSet< const ICFGNode * > &slicedNodes)
ThreadAPI * getThreadAPI() const
Thread API.
static void collectLockFunctionMarkers(const OrderedSet< const CallICFGNode * > &mutexCallNodes, OrderedSet< const ICFGNode * > &sliceResult)

◆ runPTASlicing()

OrderedSet< const ICFGNode * > SVF::MultiStageSlicer::runPTASlicing ( const OrderedSet< const SVFStmt * > &  vulnerableStatements)

Stage 2: the FSPTA slice (backward data dependence over the thread-aware VFG_pre; node set only, no function expansion).

Definition at line 1022 of file MTASlicer.cpp.

1024{
1025
1026 // Step 1: paper-faithful (§4.3) data-dependence slice over the thread-aware
1027 // SVFG built once in pre-analysis (reusing the memoised SVFG-node closure).
1030
1031 // Retain the lock/unlock-function control-flow markers the sliced lock
1032 // analysis depends on (see collectLockFunctionMarkers); the data-dependence
1033 // SVFG slice does not otherwise keep them.
1035
1036 // Step 2: Perform dual slicing (temporal slicing)
1038
1039 return dualSlicedNodes;
1040}
OrderedSet< const CallICFGNode * > collectMutexStatements(const OrderedSet< const SVFStmt * > &vulnerableStmts)
OrderedSet< const ICFGNode * > svfgNodesToICFGNodes(const OrderedSet< const VFGNode * > &nodes, const OrderedSet< const SVFStmt * > &seeds)
Project the retained VFG nodes (plus the seeds) onto their ICFG nodes.
const OrderedSet< const VFGNode * > & getRetainedSVFGNodes(const OrderedSet< const SVFStmt * > &vulnerableStatements)

Member Data Documentation

◆ retainedComputed

bool SVF::MultiStageSlicer::retainedComputed = false
private

Definition at line 245 of file MTASlicer.h.

◆ retainedSVFGNodes

OrderedSet<const VFGNode*> SVF::MultiStageSlicer::retainedSVFGNodes
private

memoised data-dependence slice

Definition at line 244 of file MTASlicer.h.


The documentation for this class was generated from the following files: