Static Value-Flow Analysis
Loading...
Searching...
No Matches
MTASVFGBuilder.h
Go to the documentation of this file.
1//===- MTASVFGBuilder.h -- Thread-aware SVFG builder for FSAM -----------===//
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 * MTASVFGBuilder.h
25 *
26 * Author: Jiawei Yang
27 *
28 * Builds a *thread-aware* Sparse Value-Flow Graph (SVFG) for the FSAM
29 * flow-sensitive multithreaded pointer analysis (Sui, Di, Xue, CGO'16).
30 *
31 * On top of the stock thread-oblivious SVFG, it adds inter-thread (interference)
32 * indirect value-flow edges between store/load and store/store statements that
33 * (1) may-happen-in-parallel (MHP), and
34 * (2) may-alias on the address-taken object, and
35 * (3) are not excluded by a common lock (non-interference lock-pair pruning).
36 */
37
38#ifndef INCLUDE_MTA_MTASVFGBUILDER_H_
39#define INCLUDE_MTA_MTASVFGBUILDER_H_
40
41#include "MSSA/SVFGBuilder.h"
42#include "Graphs/SVFG.h"
43#include "Graphs/SVFGEdge.h"
44#include "MTA/MHP.h"
45#include "MTA/LockAnalysis.h"
47#include <map>
48#include <set>
49#include <utility>
50
51namespace SVF
52{
53
54class SlicedICFGView;
55
57{
58public:
61
64 ~MTASVFGBuilder() override = default;
65
68
77 {
79 recordThreadVF = false;
80 }
81
84 typedef std::pair<const StmtSVFGNode*, const StmtSVFGNode*> ThreadVFEdge;
85
101 const std::map<ThreadVFEdge, std::set<const ICFGNode*>>& getThreadVFQueryMap() const
102 {
103 return threadVFQueryMap;
104 }
105
106protected:
108 void buildSVFG() override;
109
112 std::unique_ptr<MRGenerator> createMRGenerator(BVDataPTAImpl* pta, bool ptrOnlyMSSA) override;
113
114private:
116 const SlicedICFGView* icfgSlice = nullptr;
117 bool recordThreadVF = true;
118
122
129
135
138
141
146 void recordThreadVFSource(const StmtSVFGNode* s, const StmtSVFGNode* sp, bool commonLock);
147
150
152
155 bool isHeadOfSpan(const StmtSVFGNode* n);
156 bool isTailOfSpan(const StmtSVFGNode* n);
158
161
163 std::map<ThreadVFEdge, std::set<const ICFGNode*>> threadVFQueryMap;
164
167
172};
173
174} // End namespace SVF
175
176#endif /* INCLUDE_MTA_MTASVFGBUILDER_H_ */
cJSON * n
Definition cJSON.cpp:2558
Definition MHP.h:57
LockAnalysis * lockana
static u32_t numOfNewSVFGEdges
Number of thread-aware (interference) SVFG edges added.
~MTASVFGBuilder() override=default
void connectMHPEdges(PointerAnalysis *pta)
Connect inter-thread (interference) value-flow edges for MHP pairs.
std::unique_ptr< MRGenerator > createMRGenerator(BVDataPTAImpl *pta, bool ptrOnlyMSSA) override
void handleStoreLoad(const StmtSVFGNode *n1, const StmtSVFGNode *n2, PointerAnalysis *pta)
Map< const StmtSVFGNode *, SVFGNodeIDSet > prevset
void handleStoreStore(const StmtSVFGNode *n1, const StmtSVFGNode *n2, PointerAnalysis *pta)
SVFGEdge * addTDEdge(NodeID srcId, NodeID dstId, const PointsTo &pts)
Add a thread-MHP indirect value-flow edge srcId -> dstId carrying pts.
bool isHeadOfSpan(const StmtSVFGNode *n)
void recordThreadVFSource(const StmtSVFGNode *s, const StmtSVFGNode *sp, bool commonLock)
bool recordThreadVF
false = skip [THREAD-VF] recording
SVFGNodeSet ldnodeSet
all load SVFG nodes
SVFGNodeIDSet getSuccNodes(const StmtSVFGNode *n)
Set< const StmtSVFGNode * > SVFGNodeSet
SVFGNodeSet stnodeSet
all store SVFG nodes
const std::map< ThreadVFEdge, std::set< const ICFGNode * > > & getThreadVFQueryMap() const
SVFGNodeIDSet getPrevNodes(const StmtSVFGNode *n)
Lock-span head/tail tests (non-interference lock-pair pruning).
bool isTailOfSpan(const StmtSVFGNode *n)
void configureForMainSolve(const SlicedICFGView *slice)
std::pair< const StmtSVFGNode *, const StmtSVFGNode * > ThreadVFEdge
const SlicedICFGView * icfgSlice
Main-solve configuration (see configureForMainSolve); defaults suit VFG_pre.
Map< const StmtSVFGNode *, SVFGNodeIDSet > succset
Map< const StmtSVFGNode *, bool > headmap
Map< const StmtSVFGNode *, bool > tailmap
MTASVFGBuilder(MHP *m, LockAnalysis *la)
Constructor: driven by the interleaving (MHP) and lock analyses.
std::map< ThreadVFEdge, std::set< const ICFGNode * > > threadVFQueryMap
[THREAD-VF] per-edge query map (see getThreadVFQueryMap).
void addJoinRetEdge(const FormalOUTSVFGNode *formalOut, const ActualOUTSVFGNode *actualOut, CallSiteID csId)
void buildSVFG() override
Rewrite the SVFG build hook: build the stock SVFG, then add MHP edges.
for isBitcode
Definition BasicTypes.h:70
unsigned CallSiteID
Definition GeneralType.h:78
u32_t NodeID
Definition GeneralType.h:76
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
unsigned u32_t
Definition GeneralType.h:67