Static Value-Flow Analysis
Loading...
Searching...
No Matches
MTASlicer.h
Go to the documentation of this file.
1//===- MTASlicer.h -- Multi-stage on-demand program slicers ---------------===//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * MTASlicer.h
25 *
26 * Author: Jiawei Yang
27 *
28 * The program slicers of "Multi-Stage On-Demand Program Slicing for Modular
29 * Analysis of Multi-Threaded Programs" (ISSTA 2026): a shared MTASlicerBase plus
30 * three concrete slicers.
31 * - MultiStageSlicer : ILA (sync + dual + call) slice for the thread-aware analysis
32 * (its FSPTA stage: data-dependence slice over the thread-aware VFG_pre)
33 * - SingleSlicer: one unified slice combining all three dependence kinds, shared
34 * by both ILA and FSPTA (the single-pass baseline, MSli §3/§5.4)
35 */
36
37#ifndef MTA_MTASLICER_H
38#define MTA_MTASLICER_H
39
40#include "SVFIR/SVFIR.h"
41#include "SVFIR/SVFStatements.h"
42#include "SVFIR/SVFVariables.h"
43#include "WPA/Andersen.h"
44#include "MTA/MHP.h"
45#include "MTA/LockAnalysis.h"
46#include "MTA/TCT.h"
47#include "Graphs/SlicedGraphs.h"
49#include "Graphs/ICFG.h"
50#include "Graphs/ICFGNode.h"
51#include <fstream>
52#include "Graphs/ICFGEdge.h"
53#include "Graphs/CallGraph.h"
54#include "Util/WorkList.h"
55#include <memory>
56#include <set>
57#include <string>
58#include <unordered_map>
59#include <unordered_set>
60#include <vector>
61#include <utility>
62
63namespace SVF
64{
65
66// Forward declarations
67class SVFG;
68class VFGNode; // SVFGNode is a typedef for VFGNode
69class PointerAnalysis;
70
71
72//===----------------------------------------------------------------------===//
73// SlicedTCT - the Thread-Create-Tree rebuilt over a SlicedThreadCallGraphView.
74//
75// Inherits TCT and overrides the ThreadCallGraph-traversing steps to use the
76// sliced view. It sits at the sliced-representation layer (built from the view,
77// consumed by the sliced MHP/LockAnalysis graph-access), which is why it lives
78// here with the views rather than beside the analyses.
79//===----------------------------------------------------------------------===//
80class SlicedTCT : public TCT
81{
82public:
87
88 ~SlicedTCT() override = default;
89
91 void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee) override;
92
93protected:
94 void build() override;
95 void markRelProcs() override;
96 void markRelProcs(const FunObjVar* fun) override;
97 void collectLoopInfoForJoin() override;
98 void handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, const CallICFGNode* cs) override;
99
100private:
101 void collectEntryFunInCallGraph() override;
102
103 const SlicedThreadCallGraphView* tcgView; // ThreadCallGraph view (from the sliced view)
104 u32_t maxContextLen; // 0 means use Options::MaxContextLen()
105
106 bool isKeptNode(const CallGraphNode* node) const;
107 bool isKeptEdge(const CallGraphEdge* edge) const;
108 void getKeptForkSites(std::vector<const ICFGNode*>& out) const;
109 void getKeptJoinSites(std::vector<const ICFGNode*>& out) const;
110};
111
112
120{
121public:
123 LockAnalysis* lockAnalysis, SVFG* vfg = nullptr);
124 virtual ~MTASlicerBase();
125
126protected:
133
134 // === Data flow analysis helper ===
145
152
156
157 // === Thread analysis helpers ===
160
161 // === Lock analysis helpers ===
165
166 // === Common slicing helpers ===
172 std::pair<OrderedSet<const CallICFGNode*>, OrderedSet<const CallICFGNode*>>
174
175 // === ICFG analysis helpers ===
177
187
196};
197
247
272
273} // End namespace SVF
274
275#endif // MTA_MTASLICER_H
cJSON * p
Definition cJSON.cpp:2559
Definition MHP.h:57
SVFG * vfg
thread-aware VFG_pre (PTA/Single slicers; null for MTA)
Definition MTASlicer.h:132
OrderedSet< const SVFStmt * > getDependentThreadCreate(const SVFStmt *stmt)
OrderedSet< const ICFGNode * > buildBackwardICFGNodeSet(const OrderedSet< const ICFGNode * > &vulnerableNodes)
std::pair< OrderedSet< const CallICFGNode * >, OrderedSet< const CallICFGNode * > > collectCommonThreadStatements(const OrderedSet< const SVFStmt * > &vulnerableStatements)
OrderedSet< const VFGNode * > computeDataDependenceSVFGNodes(const OrderedSet< const SVFStmt * > &seeds, SVFG *vfg)
virtual ~MTASlicerBase()
OrderedSet< const CallICFGNode * > collectMutexStatements(const OrderedSet< const SVFStmt * > &vulnerableStmts)
OrderedSet< const ICFGNode * > expandCallDependence(const OrderedSet< const ICFGNode * > &nodes)
OrderedSet< const ICFGNode * > runDualSlicing(const OrderedSet< const ICFGNode * > &slicedNodes)
OrderedSet< const CallICFGNode * > collectPthreadStatements(const OrderedSet< const SVFStmt * > &vulnerableStmts)
AndersenBase * pta
Definition MTASlicer.h:128
OrderedSet< const ICFGNode * > getLockSet(const ICFGNode *node)
OrderedSet< const ICFGNode * > sliceDataDependenceOverVFG(const OrderedSet< const SVFStmt * > &seeds, SVFG *vfg)
OrderedSet< const TCTNode * > getTCTNodeSetFromNode(const ICFGNode *node)
LockAnalysis * lockAnalysis
Definition MTASlicer.h:130
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.
CallGraph * callGraph
Definition MTASlicer.h:131
OrderedSet< const VFGNode * > retainedSVFGNodes
memoised data-dependence slice
Definition MTASlicer.h:244
const OrderedSet< const VFGNode * > & getRetainedSVFGNodes(const OrderedSet< const SVFStmt * > &vulnerableStatements)
OrderedSet< const ICFGNode * > runILASlicing(const OrderedSet< const SVFStmt * > &vulnerableStatements, const OrderedSet< const ICFGNode * > &threadVFSources={})
OrderedSet< const ICFGNode * > runPTASlicing(const OrderedSet< const SVFStmt * > &vulnerableStatements)
OrderedSet< const ICFGNode * > runSlicing(const OrderedSet< const SVFStmt * > &vulnerableStatements)
void getKeptForkSites(std::vector< const ICFGNode * > &out) const
~SlicedTCT() override=default
void collectEntryFunInCallGraph() override
Get entry functions that are neither called by other functions nor extern functions.
void collectLoopInfoForJoin() override
Handle join site in loop.
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee) override
Override pushCxt to use the custom maxContextLen.
void handleCallRelation(CxtThreadProc &ctp, const CallGraphEdge *cgEdge, const CallICFGNode *cs) override
Handle call relations.
const SlicedThreadCallGraphView * tcgView
Definition MTASlicer.h:103
u32_t maxContextLen
Definition MTASlicer.h:104
bool isKeptEdge(const CallGraphEdge *edge) const
void getKeptJoinSites(std::vector< const ICFGNode * > &out) const
bool isKeptNode(const CallGraphNode *node) const
void build() override
Build TCT.
Definition MTASlicer.cpp:79
void markRelProcs() override
Mark relevant procedures that are backward reachable from any fork/join site.
Definition MTASlicer.cpp:98
for isBitcode
Definition BasicTypes.h:70
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
iter_range< typename GenericGraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
std::vector< u32_t > CallStrCxt
Definition GeneralType.h:96
unsigned u32_t
Definition GeneralType.h:67