Static Value-Flow Analysis
Loading...
Searching...
No Matches
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 *svfg=nullptr)
OrderedSet< const ICFGNode * > runILASlicing (const OrderedSet< const SVFStmt * > &vulnerableStatements, const OrderedSet< const ICFGNode * > &threadVFSources={})
ValueFlowSlice runPTASlicing (const OrderedSet< const SVFStmt * > &vulnerableStatements, SVFG *refinedMainVFG)
void computePreCandidateSlice (const OrderedSet< const SVFStmt * > &vulnerableStatements)
const ValueFlowSlice & getPreCandidateSlice () const
 Return the pre-candidate slice after computePreCandidateSlice().
Public Member Functions inherited from SVF::MTASlicerBase
 MTASlicerBase (SVFIR *svfir, AndersenBase *pta, MHP *mhp, LockAnalysis *lockAnalysis, SVFG *svfg=nullptr)

Private Attributes

ValueFlowSlice preCandidateSlice
bool preCandidateComputed = false

Additional Inherited Members

Protected Member Functions inherited from SVF::MTASlicerBase
OrderedSet< const VFGNode * > computeDataDependenceSVFGNodes (const OrderedSet< const SVFStmt * > &seeds, SVFG *svfg)
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 CallICFGNode * > getDependentThreadCreate (const ICFGNode *node)
OrderedSet< const TCTNode * > getTCTNodeSetFromNode (const ICFGNode *node)
OrderedSet< const ICFGNode * > getLockSet (const ICFGNode *node)
OrderedSet< const CallICFGNode * > collectPthreadStatements (const OrderedSet< const ICFGNode * > &sourceNodes)
OrderedSet< const CallICFGNode * > collectMutexStatements (const OrderedSet< const ICFGNode * > &sourceNodes)
std::pair< OrderedSet< const CallICFGNode * >, OrderedSet< const CallICFGNode * > > collectCommonThreadStatements (const OrderedSet< const ICFGNode * > &sourceNodes)
void addSynchronizationDependencies (const OrderedSet< const CallICFGNode * > &pthreadCallNodes, const OrderedSet< const CallICFGNode * > &mutexCallNodes, OrderedSet< const ICFGNode * > &retainedNodes)
OrderedSet< const ICFGNode * > expandCallDependence (const OrderedSet< const ICFGNode * > &nodes)
Static Protected Member Functions inherited from SVF::MTASlicerBase
static void enqueueSVFGNode (const SVFGNode *node, OrderedSet< const SVFGNode * > &visited, std::deque< const SVFGNode * > &worklist)
Protected Attributes inherited from SVF::MTASlicerBase
SVFIR * svfir
AndersenBase * pta
MHP * mhp
LockAnalysis * lockAnalysis
CallGraph * callGraph
SVFG * svfg
 thread-aware VFG_pre (PTA/Single slicers; null for MTA)

Detailed Description

MultiStageSlicer - the multi-stage (differential) slicer of MSli. The pre-candidate closure scopes ILA queries and the Main-TVF overlay; the final closure is recomputed over that refined main graph. Stage 1 (ILA): runILASlicing – synchronization 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 201 of file MTASlicer.h.

Constructor & Destructor Documentation

◆ MultiStageSlicer()

SVF::MultiStageSlicer::MultiStageSlicer ( SVFIR * svfir,
AndersenBase * pta,
MHP * mhp,
LockAnalysis * lockAnalysis,
SVFG * svfg = nullptr )

Definition at line 793 of file MTASlicer.cpp.

796{
797}
AndersenBase * pta
Definition MTASlicer.h:129
LockAnalysis * lockAnalysis
Definition MTASlicer.h:131
MTASlicerBase(SVFIR *svfir, AndersenBase *pta, MHP *mhp, LockAnalysis *lockAnalysis, SVFG *svfg=nullptr)
SVFG * svfg
thread-aware VFG_pre (PTA/Single slicers; null for MTA)
Definition MTASlicer.h:133

Member Function Documentation

◆ computePreCandidateSlice()

void SVF::MultiStageSlicer::computePreCandidateSlice ( const OrderedSet< const SVFStmt * > & vulnerableStatements)

Compute the pre-candidate slice used to restrict [THREAD-VF] sources and scope construction of the refined main overlay.

Definition at line 858 of file MTASlicer.cpp.

860{
861 preCandidateSlice = ValueFlowSlice{};
862 preCandidateSlice.svfgNodes =
863 computeDataDependenceSVFGNodes(vulnerableStatements, svfg);
864 preCandidateSlice.icfgNodes =
865 svfgNodesToICFGNodes(preCandidateSlice.svfgNodes, vulnerableStatements);
867}
OrderedSet< const VFGNode * > computeDataDependenceSVFGNodes(const OrderedSet< const SVFStmt * > &seeds, SVFG *svfg)
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.
ValueFlowSlice preCandidateSlice
Definition MTASlicer.h:238

◆ getPreCandidateSlice()

const ValueFlowSlice & SVF::MultiStageSlicer::getPreCandidateSlice ( ) const

Return the pre-candidate slice after computePreCandidateSlice().

Definition at line 869 of file MTASlicer.cpp.

870{
871 assert(preCandidateComputed && "pre-candidate slice has not been computed");
872 return preCandidateSlice;
873}

◆ runILASlicing()

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

Stage 1: the ILA slice (synchronization + 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 800 of file MTASlicer.cpp.

803{
804
805 // Step 1: Form the complete ILA source set first. MSli section 4.2 defines
806 // V_ILA as [INIT] union [THREAD-VF], then closes every source over its
807 // synchronization dependences. Keep this set at ICFG granularity: some
808 // THREAD-VF call/marker nodes have no attached SVF statement.
809 OrderedSet<const ICFGNode*> ilaSourceNodes = threadVFSources;
810 for (const SVFStmt* stmt : vulnerableStatements)
811 ilaSourceNodes.insert(stmt->getICFGNode());
812
813 // Step 2: synchronization-dependence closure of the complete source set.
814 auto commonStmts = collectCommonThreadStatements(ilaSourceNodes);
815 const OrderedSet<const CallICFGNode*>& pthreadCallNodes = commonStmts.first;
816 const OrderedSet<const CallICFGNode*>& mutexCallNodes = commonStmts.second;
817
818 // Form V_ILA_sync before function expansion: all [INIT] and [THREAD-VF]
819 // sources plus the synchronization primitives on which they depend.
820 OrderedSet<const ICFGNode*> initialSliceResult;
822 pthreadCallNodes, mutexCallNodes, initialSliceResult);
823 for (const SVFStmt* stmt : vulnerableStatements)
824 {
825 initialSliceResult.insert(stmt->getICFGNode());
826 }
827 initialSliceResult.insert(threadVFSources.begin(), threadVFSources.end());
828
829 // Step 3: Expand keptNodes to include call/ret nodes and function entry/exit
830 // nodes (call dependence).
831 OrderedSet<const ICFGNode*> finalSlice = expandCallDependence(initialSliceResult);
832
833 // Slicing invariant: no relevant synchronization primitive may be contracted
834 // into a bridge edge. Return nodes are retained because the sliced ICFG
835 // represents external synchronization calls as paired call/return nodes.
836 for (const CallICFGNode* callNode : pthreadCallNodes)
837 {
838 assert(finalSlice.count(callNode) && finalSlice.count(callNode->getRetICFGNode()) &&
839 "ILA slice dropped a fork/join synchronization dependence");
840 (void)callNode;
841 }
842 for (const CallICFGNode* callNode : mutexCallNodes)
843 {
844 assert(finalSlice.count(callNode) && finalSlice.count(callNode->getRetICFGNode()) &&
845 "ILA slice dropped a lock/unlock synchronization dependence");
846 (void)callNode;
847 }
848 return finalSlice;
849}
std::pair< OrderedSet< const CallICFGNode * >, OrderedSet< const CallICFGNode * > > collectCommonThreadStatements(const OrderedSet< const ICFGNode * > &sourceNodes)
OrderedSet< const ICFGNode * > expandCallDependence(const OrderedSet< const ICFGNode * > &nodes)
void addSynchronizationDependencies(const OrderedSet< const CallICFGNode * > &pthreadCallNodes, const OrderedSet< const CallICFGNode * > &mutexCallNodes, OrderedSet< const ICFGNode * > &retainedNodes)
std::set< Key, Compare, Allocator > OrderedSet
Definition GeneralType.h:60

◆ runPTASlicing()

ValueFlowSlice SVF::MultiStageSlicer::runPTASlicing ( const OrderedSet< const SVFStmt * > & vulnerableStatements,
SVFG * refinedMainVFG )

Stage 2: the FSPTA slice (backward data dependence over the refined main value-flow graph; node set only, no function expansion).

Definition at line 876 of file MTASlicer.cpp.

879{
880 ValueFlowSlice result;
881 result.svfgNodes =
882 computeDataDependenceSVFGNodes(vulnerableStatements, refinedMainVFG);
883 result.icfgNodes =
884 svfgNodesToICFGNodes(result.svfgNodes, vulnerableStatements);
885 return result;
886}
OrderedSet< const SVFGNode * > svfgNodes
Definition MTASlicer.h:61
OrderedSet< const ICFGNode * > icfgNodes
Definition MTASlicer.h:62

Member Data Documentation

◆ preCandidateComputed

bool SVF::MultiStageSlicer::preCandidateComputed = false
private

Definition at line 239 of file MTASlicer.h.

◆ preCandidateSlice

ValueFlowSlice SVF::MultiStageSlicer::preCandidateSlice
private

Definition at line 238 of file MTASlicer.h.


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