Static Value-Flow Analysis
Loading...
Searching...
No Matches
PreAnalysis.cpp
Go to the documentation of this file.
1//===- PreAnalysis.cpp -- Pre-Analysis for Abstract Interpretation---------//
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 * PreAnalysis.cpp
25 *
26 * Created on: Feb 25, 2026
27 * Author: Jiawei Wang
28 */
29
31
32using namespace SVF;
33
41
43{
44 for (auto& [func, wto] : funcToWTO)
45 delete wto;
46}
47
49{
50 callGraphSCC->find();
51
52 for (auto it = callGraph->begin(); it != callGraph->end(); it++)
53 {
54 const FunObjVar *fun = it->second->getFunction();
55 if (fun->isDeclaration())
56 continue;
57
58 NodeID repNodeId = callGraphSCC->repNode(it->second->getId());
59 auto cgSCCNodes = callGraphSCC->subNodes(repNodeId);
60
61 bool isEntry = false;
62 if (it->second->getInEdges().empty())
63 isEntry = true;
64 for (auto inEdge: it->second->getInEdges())
65 {
66 NodeID srcNodeId = inEdge->getSrcID();
67 if (!cgSCCNodes.test(srcNodeId))
68 isEntry = true;
69 }
70
71 if (isEntry)
72 {
74 for (const auto& node: cgSCCNodes)
75 {
76 funcScc.insert(callGraph->getGNode(node)->getFunction());
77 }
79 iwto->init();
80 funcToWTO[it->second->getFunction()] = iwto;
81 }
82 }
83
84}
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:407
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
bool isDeclaration() const
iterator begin()
Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
CallGraph * getCallGraph() const
Return call graph.
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
Definition PreAnalysis.h:85
CallGraphSCC * callGraphSCC
Definition PreAnalysis.h:83
AndersenWaveDiff * pta
Definition PreAnalysis.h:81
virtual ~PreAnalysis()
CallGraph * callGraph
Definition PreAnalysis.h:82
void initWTO()
Build WTO for each function using call graph SCC.
PreAnalysis(SVFIR *pag, ICFG *icfg)
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:56
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74