Static Value-Flow Analysis
Loading...
Searching...
No Matches
mta.cpp
Go to the documentation of this file.
1//===- mta.cpp --Program Analysis for Multithreaded Programs------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2022> <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#include "SVF-LLVM/LLVMUtil.h"
25#include "MTA/MTA.h"
26#include "MTA/MTAStat.h"
27#include "Util/CommandLine.h"
28#include "Util/Options.h"
29
30#include <string>
31#include <vector>
32
33using namespace llvm;
34using namespace std;
35using namespace SVF;
36
37namespace
38{
39
42{
43 ScopedPhaseTimer timer("Andersen's pointer analysis");
44
45 AndersenWaveDiff* preAnalysis =
48 {
49 preAnalysis->getConstraintGraph()->dump("original_consg");
50 preAnalysis->getCallGraph()->dump("original_tcg");
51 }
52 builder.updateCallGraph(preAnalysis->getCallGraph());
53 pag->getICFG()->updateCallGraph(preAnalysis->getCallGraph());
55 pag->getICFG()->dump("original_icfg");
56
57 return preAnalysis;
58}
59
60} // namespace
61
62int main(int argc, char** argv)
63{
64 std::vector<std::string> moduleNameVec = OptionBase::parseOptions(
65 argc, argv, "MTA Analysis", "[options] <input-bitcode...>");
66
69 SVFIR* pag = builder.build();
70
71 // MTA's only client is race detection. -mta-flow-sensitive (default) selects the
72 // FSAM pipeline (SlicedMTA), which decides slicing and the pre-analysis
73 // context handling internally; otherwise run the flow-insensitive Andersen
74 // detector.
75 bool succeeded = true;
77 {
78 AndersenWaveDiff* preAnalysis = preparePreAnalysis(pag, builder);
80 succeeded = sliced.runOnModule(pag, *preAnalysis);
81 }
82 else
83 {
84 MTA mta;
86 }
87
91 return succeeded ? 0 : 1;
92}
static std::vector< std::string > parseOptions(int argc, char *argv[], std::string description, std::string callFormat)
Definition CommandLine.h:75
ConstraintGraph * getConstraintGraph()
Get constraint graph.
Definition Andersen.h:122
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:408
static void releaseAndersenWaveDiff()
Definition Andersen.h:418
void dump(const std::string &filename)
Dump the graph.
void dump(std::string name)
Dump graph into dot file.
Definition ConsG.cpp:595
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
Definition ICFG.cpp:412
void updateCallGraph(CallGraph *callgraph)
update ICFG for indirect calls
Definition ICFG.cpp:428
static void releaseLLVMModuleSet()
Definition LLVMModule.h:140
static void buildSVFModule(Module &mod)
Definition MTA.h:81
virtual bool runOnModule(SVFIR *module)
We start the pass here.
Definition MTA.cpp:67
static const Option< bool > DumpMTAGraphs
MTA: dump the pointer-analysis and thread call graphs (ptacg/tcg.dot), Default: false.
Definition Options.h:258
static const Option< bool > MTFlowSensitive
MTA: flow-sensitive (FSAM) main analysis; false = Andersen flow-insensitive base, Default: true.
Definition Options.h:256
CallGraph * getCallGraph() const
Return call graph.
static void releaseSVFIR()
Definition SVFIR.h:128
ICFG * getICFG() const
Definition SVFIR.h:231
bool runOnModule(SVFIR *pag, AndersenWaveDiff &preAnalysis)
Run the slicing pipeline with its prepared Andersen pre-analysis.
Definition MTA.cpp:1276
int main(int argc, char **argv)
Definition mta.cpp:62
for isBitcode
Definition BasicTypes.h:70
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76