Static Value-Flow Analysis
Loading...
Searching...
No Matches
CFLAlias.h
Go to the documentation of this file.
1//===----- CFLAlias.h -- CFL Alias Analysis Client--------------//
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 * CFLAlias.h
25 *
26 * Created on: March 5, 2022
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_CFL_CFLALIAS_H_
31#define INCLUDE_CFL_CFLALIAS_H_
32
33#include "CFL/CFLBase.h"
34#include "CFL/CFLStat.h"
35#include "MemoryModel/PTATY.h"
36#include "SVFIR/SVFType.h"
37#include "Util/GeneralType.h"
38
39namespace SVF
40{
41
42class CFLAlias : public CFLBase
43{
44
45public:
47
51
53 virtual void initialize();
54
56 virtual void initializeSolver();
57
58
60 virtual void finalize();
61
63 virtual void solve();
64
73
75 virtual const PointsTo& getCFLPts(NodeID ptr)
76 {
79 for(auto outedge = funNode->getOutEdges().begin(); outedge!=funNode->getOutEdges().end(); outedge++)
80 {
81 if((*outedge)->getEdgeKind() == graph->getStartKind())
82 {
83 // Need to Find dst addr src
84 SVFVar *vNode = svfir->getGNode((*outedge)->getDstID());
86 // Remove svfir->getBaseValVar, SVF IR api change
87 if (vNode->hasIncomingEdges(SVFStmt::Gep))
88 {
90 SVFVar::iterator it = geps.begin();
91 basevNodeID = (*it)->getSrcID();
92 }
93 else
94 basevNodeID = vNode->getId();
96 for(auto inEdge = vNode->getInEdges().begin(); inEdge!=vNode->getInEdges().end(); inEdge++)
97 {
98 if((*inEdge)->getEdgeKind() == 0)
99 {
100 addPts(ptr, (*inEdge)->getSrcID());
101 }
102 }
103 }
104 }
105 return getPts(ptr);
106 }
107
109
111 virtual inline bool addCopyEdge(NodeID src, NodeID dst)
112 {
113 const CFLEdge *edge = graph->hasEdge(graph->getGNode(src),graph->getGNode(dst), 1);
114 if (edge != nullptr )
115 {
116 return false;
117 }
118 CFGrammar::Kind copyKind = grammar->strToKind("copy");
122 return true;
123 }
124
127 {
129 abort(); // to be implemented
130 }
131
133 virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
134
137
139 void connectCaller2CalleeParams(const CallICFGNode* cs, const FunObjVar* F);
140
142
143private:
145};
146
147class POCRAlias : public CFLAlias
148{
149public:
151 {
152 }
154 virtual void initializeSolver();
155};
156
157class POCRHybrid : public CFLAlias
158{
159public:
161 {
162 }
163
165 virtual void initializeSolver();
166};
167} // End namespace SVF
168
169#endif /* INCLUDE_CFL_CFLALIAS_H_*/
const PointsTo & getPts(NodeID id) override
virtual bool addPts(NodeID id, NodeID ptd)
virtual const NodeSet & getRevPts(NodeID nodeId)
Given an object, get all the nodes having whose pointsto contains the object.
Definition CFLAlias.h:126
void connectCaller2CalleeParams(const CallICFGNode *cs, const FunObjVar *F)
Connect formal and actual parameters for indirect callsites.
Definition CFLAlias.cpp:64
virtual void finalize()
Print grammar and graph.
Definition CFLAlias.cpp:215
virtual bool addCopyEdge(NodeID src, NodeID dst)
Need Original one for virtual table.
Definition CFLAlias.h:111
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
Definition CFLAlias.cpp:41
virtual void initializeSolver()
Initialize Solver.
Definition CFLAlias.cpp:210
OrderedMap< const CallICFGNode *, NodeID > CallSite2DummyValPN
Definition CFLAlias.h:46
void heapAllocatorViaIndCall(const CallICFGNode *cs)
Definition CFLAlias.cpp:147
virtual void solve()
Solving CFL Reachability.
Definition CFLAlias.cpp:230
virtual const PointsTo & getCFLPts(NodeID ptr)
Get points-to targets of a pointer. V In this context.
Definition CFLAlias.h:75
virtual bool updateCallGraph(const CallSiteToFunPtrMap &callsites)
Update call graph for the input indirect callsites.
Definition CFLAlias.cpp:175
CFLAlias(SVFIR *ir)
Definition CFLAlias.h:48
CallSite2DummyValPN callsite2DummyValPN
Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocat...
Definition CFLAlias.h:144
virtual void initialize()
Initialize the grammar, graph, solver.
Definition CFLAlias.cpp:190
virtual AliasResult alias(NodeID node1, NodeID node2)
Interface exposed to users of our Alias analysis, given PAGNodeID.
Definition CFLAlias.h:66
CFL Client Base Class.
Definition CFLBase.h:47
CFLSolver * solver
Definition CFLBase.h:110
CFLGraph * graph
Definition CFLBase.h:107
CFGrammar * grammar
Definition CFLBase.h:109
SVFIR * svfir
Definition CFLBase.h:106
Kind getStartKind() const
Definition CFLGraph.cpp:37
virtual const CFLEdge * addCFLEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:47
virtual const CFLEdge * hasEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:63
virtual bool pushIntoWorklist(const CFLEdge *item)
Definition CFLSolver.h:85
NodeType * getGNode(NodeID id) const
Get a node.
GEdgeSetTy::iterator iterator
Kind strToKind(std::string str) const
Definition CFGrammar.cpp:57
POCRAlias(SVFIR *ir)
Definition CFLAlias.h:150
virtual void initializeSolver()
Initialize POCR Solver.
Definition CFLAlias.cpp:249
virtual void initializeSolver()
Initialize POCRHybrid Solver.
Definition CFLAlias.cpp:254
POCRHybrid(SVFIR *ir)
Definition CFLAlias.h:160
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
SVFStmt::SVFStmtSetTy & getIncomingEdges(SVFStmt::PEDGEK kind)
Edge accessors and checkers.
for isBitcode
Definition BasicTypes.h:70
Set< NodeID > NodeSet
Definition GeneralType.h:87
PTATY
Pointer analysis type list.
Definition PTATY.h:9
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
Definition PTATY.h:23
u32_t NodeID
Definition GeneralType.h:76
AliasResult
Definition SVFType.h:619
@ MayAlias
Definition SVFType.h:621
@ NoAlias
Definition SVFType.h:620
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76