Static Value-Flow Analysis
Loading...
Searching...
No Matches
FSMPTA.cpp
Go to the documentation of this file.
1//===- FSMPTA.cpp -- Flow-sensitive multithreaded pointer analysis (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 * FSMPTA.cpp
25 *
26 * Author: Jiawei Yang
27 *
28 * Implements the flow-sensitive multithreaded pointer analysis (FSAM): build
29 * the thread-aware SVFG, then run the sparse flow-sensitive solver over it.
30 */
31
32#include "MTA/FSMPTA.h"
33#include "Graphs/SlicedGraphs.h"
34#include "WPA/Andersen.h"
35#include "WPA/WPAStat.h"
36#include "Util/Options.h"
37#include "Graphs/SVFGNode.h"
39
40using namespace SVF;
41
51template<class SVFGGraph>
53{
54 if (!GenericGraphTraits<SVFGGraph>::containsNode(graph, svfg->getSVFGNode(nodeId)))
55 return; // outside the sliced SVFG -- leave inert
57}
58
59// The ICFG slice to restrict the main-solve interference edges to, or null for
60// the whole-program SVFG*. Overloaded on the graph handle (static: file-local).
62{
63 return nullptr;
64}
66{
67 return v != nullptr ? v->getICFGView() : nullptr;
68}
69
75template<class SVFGGraph>
77{
79
80 stat = new FlowSensitiveStat(this);
81
82 // The artifact runs FSAM with default options; clustering / plain-mapping
83 // of the auxiliary Andersen's analysis is not supported here.
84 assert(!Options::ClusterAnder() && "FSMPTA: clustering aux. Andersen's unsupported.");
86 "FSMPTA: cluster-fs / plain-mapping-fs unsupported.");
87
89
90 // FSAM's thread-oblivious value flow treats a thread fork as an ordinary
91 // call: the spawner's memory state must flow into the spawnee. The stock
92 // Andersen call graph does not carry the pthread fork/join edges, so we
93 // add them here (they are CallGraphEdges) before building MemSSA/SVFG.
94 if (ThreadCallGraph* tcg = SVFUtil::dyn_cast<ThreadCallGraph>(ander->getCallGraph()))
95 {
96 tcg->updateCallGraph(ander); // fork edges (spawner -> spawnee, forward)
97 tcg->updateJoinEdge(ander); // join edges (for join-related def-use)
98 }
99 // Main solve: restrict interference edges to the slice and skip the
100 // [THREAD-VF] recording (only VFG_pre slicing consumes it). For SVFGGraph ==
101 // SVFG* (whole program) the slice is null, so nothing is restricted.
102 mtaSVFGBuilder.configureForMainSolve(mtaICFGSliceOf(graph));
103 // Build the thread-aware SVFG (stock value flow + MHP interference edges).
104 svfg = mtaSVFGBuilder.buildPTROnlySVFG(ander);
105
106 setGraph(svfg);
107}
108
109// The two SVFGs the solver runs on; the implementation above is written once.
110namespace SVF
111{
112template class FSMPTA<SVFG*>;
113template class FSMPTA<const SlicedSVFGView*>;
114} // namespace SVF
static const SlicedICFGView * mtaICFGSliceOf(SVFG *)
Definition FSMPTA.cpp:61
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:408
void processNode(NodeID nodeId) override
Restrict the solve to the graph's nodes (whole: no restriction).
Definition FSMPTA.cpp:52
void initialize() override
Initialise: build the thread-aware SVFG, then solve sparsely on it.
Definition FSMPTA.cpp:76
void processNode(NodeID nodeId) override
Handle various constraints.
static const Option< bool > PlainMappingFs
Use an explicitly plain mapping with flow-sensitive (not null).
Definition Options.h:43
static const Option< bool > ClusterAnder
Whether to stage Andersen's with Steensgaard and cluster based on that data.
Definition Options.h:37
static const Option< bool > ClusterFs
Whether to cluster FS or VFS with the auxiliary Andersen's.
Definition Options.h:40
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
for isBitcode
Definition BasicTypes.h:70
u32_t NodeID
Definition GeneralType.h:76
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76