Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::SlicedSVFIRView Class Reference

#include <SlicedGraphs.h>

Public Member Functions

 SlicedSVFIRView (SVFIR *svfir, ThreadCallGraph &callGraph, ICFG *icfg, const OrderedSet< const ICFGNode * > &keepNodes)
 
const SlicedICFGViewgetICFG () const
 Get SlicedICFGView.
 
SlicedICFGViewgetICFG ()
 
const SlicedPAGViewgetPAG () const
 Get SlicedPAGView.
 
SlicedPAGViewgetPAG ()
 
const SlicedThreadCallGraphViewgetThreadCallGraph () const
 Get SlicedThreadCallGraphView.
 
SlicedThreadCallGraphViewgetThreadCallGraph ()
 
const Set< const FunObjVar * > & getKeptFunctions () const
 Get all kept functions.
 
const Set< const CallICFGNode * > & getIndirectSitesWithEmptyTargets () const
 Get indirect call sites that lost all targets after filtering.
 
const OrderedSet< const SVFStmt * > & getKeptStatements () const
 Get all kept statements.
 
void dumpAll (const std::string &prefix) const
 Dump all views to files.
 
SVFIRgetSVFIR () const
 Get original SVFIR.
 
void dumpStats (const std::string &prefix="") const
 Output statistics.
 

Private Member Functions

void ensurePAGView () const
 

Private Attributes

SVFIRsvfir
 
std::unique_ptr< SlicedICFGViewicfgView
 
std::unique_ptr< SlicedPAGViewpagView
 
std::unique_ptr< SlicedThreadCallGraphViewtcgView
 

Detailed Description

Definition at line 300 of file SlicedGraphs.h.

Constructor & Destructor Documentation

◆ SlicedSVFIRView()

SVF::SlicedSVFIRView::SlicedSVFIRView ( SVFIR svfir,
ThreadCallGraph callGraph,
ICFG icfg,
const OrderedSet< const ICFGNode * > &  keepNodes 
)

Definition at line 808 of file SlicedGraphs.cpp.

812 : svfir(svfir)
813{
814 // A retained function is represented by explicit synthetic entry/exit
815 // nodes. Graph-generic MHP and lock propagation can therefore never seed or
816 // rendezvous at a node outside the view.
818
819 // Derive keptFunctions from keepNodes.
821 for (const ICFGNode* node : keepNodes)
822 {
823 if (node != nullptr && node->getFun() != nullptr)
824 {
825 keptFunctions.insert(node->getFun());
826 }
827 }
828 for (const FunObjVar* fun : keptFunctions)
829 {
830 extendedKeepNodes.insert(icfg->getFunEntryICFGNode(fun));
831 extendedKeepNodes.insert(icfg->getFunExitICFGNode(fun));
832 }
833
834 tcgView = std::make_unique<SlicedThreadCallGraphView>(
835 &callGraph, keptFunctions, extendedKeepNodes);
836
837 // Create ICFG view (based on keepNodes and keptFunctions)
838 icfgView = std::make_unique<SlicedICFGView>(
839 icfg, extendedKeepNodes);
840}
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
Definition ICFG.cpp:250
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:243
std::unique_ptr< SlicedThreadCallGraphView > tcgView
std::unique_ptr< SlicedICFGView > icfgView
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

Member Function Documentation

◆ dumpAll()

void SVF::SlicedSVFIRView::dumpAll ( const std::string &  prefix) const

Dump all views to files.

Definition at line 858 of file SlicedGraphs.cpp.

859{
860 icfgView->dump(prefix + "_icfg");
861 tcgView->dump(prefix + "_threadcallgraph");
862 getPAG()->dump(prefix + "_pag");
863}
void dump(const std::string &filename) const
Dump the sliced PAG to a dot file.
const SlicedPAGView * getPAG() const
Get SlicedPAGView.

◆ dumpStats()

void SVF::SlicedSVFIRView::dumpStats ( const std::string &  prefix = "") const

Output statistics.

Definition at line 865 of file SlicedGraphs.cpp.

866{
867 std::string label = prefix.empty() ? "[SlicedSVFIRView]" : "[" + prefix + "]";
868 SVFUtil::outs() << label << " Statistics:\n";
869 SVFUtil::outs() << " ICFG nodes: " << icfgView->getKeptNodes().size() << "\n";
870 SVFUtil::outs() << " Functions: " << getKeptFunctions().size() << "\n";
871 SVFUtil::outs() << " PAG statements: " << getKeptStatements().size() << "\n";
873 {
874 SVFUtil::outs() << " Indirect callsites that lost all targets: "
875 << getIndirectSitesWithEmptyTargets().size() << "\n";
876 }
877}
const Set< const FunObjVar * > & getKeptFunctions() const
Get all kept functions.
const OrderedSet< const SVFStmt * > & getKeptStatements() const
Get all kept statements.
const Set< const CallICFGNode * > & getIndirectSitesWithEmptyTargets() const
Get indirect call sites that lost all targets after filtering.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ ensurePAGView()

void SVF::SlicedSVFIRView::ensurePAGView ( ) const
private

Definition at line 842 of file SlicedGraphs.cpp.

843{
844 if (pagView != nullptr)
845 return;
846
847 // Most analyses consume only the sliced ICFG and call graph. Materialize
848 // the PAG membership only for clients that explicitly request that view.
850 for (const ICFGNode* node : icfgView->getKeptNodes())
851 {
852 const ICFGNode::SVFStmtList& stmts = node->getSVFStmts();
853 keptStmts.insert(stmts.begin(), stmts.end());
854 }
855 pagView = std::make_unique<SlicedPAGView>(svfir, keptStmts);
856}
std::list< const SVFStmt * > SVFStmtList
Definition ICFGNode.h:65
std::unique_ptr< SlicedPAGView > pagView

◆ getICFG() [1/2]

SlicedICFGView * SVF::SlicedSVFIRView::getICFG ( )
inline

Definition at line 313 of file SlicedGraphs.h.

314 {
315 return icfgView.get();
316 }

◆ getICFG() [2/2]

const SlicedICFGView * SVF::SlicedSVFIRView::getICFG ( ) const
inline

Get SlicedICFGView.

Definition at line 309 of file SlicedGraphs.h.

310 {
311 return icfgView.get();
312 }

◆ getIndirectSitesWithEmptyTargets()

const Set< const CallICFGNode * > & SVF::SlicedSVFIRView::getIndirectSitesWithEmptyTargets ( ) const
inline

Get indirect call sites that lost all targets after filtering.

Definition at line 347 of file SlicedGraphs.h.

348 {
349 return tcgView->getIndirectSitesWithEmptyTargets();
350 }

◆ getKeptFunctions()

const Set< const FunObjVar * > & SVF::SlicedSVFIRView::getKeptFunctions ( ) const
inline

Get all kept functions.

Definition at line 341 of file SlicedGraphs.h.

342 {
343 return tcgView->getKeptFunctions();
344 }

◆ getKeptStatements()

const OrderedSet< const SVFStmt * > & SVF::SlicedSVFIRView::getKeptStatements ( ) const
inline

Get all kept statements.

Definition at line 353 of file SlicedGraphs.h.

354 {
355 return getPAG()->getKeptStmts();
356 }
const OrderedSet< const SVFStmt * > & getKeptStmts() const
Get all kept statements.

◆ getPAG() [1/2]

SlicedPAGView * SVF::SlicedSVFIRView::getPAG ( )
inline

Definition at line 324 of file SlicedGraphs.h.

325 {
327 return pagView.get();
328 }
void ensurePAGView() const

◆ getPAG() [2/2]

const SlicedPAGView * SVF::SlicedSVFIRView::getPAG ( ) const
inline

Get SlicedPAGView.

Definition at line 319 of file SlicedGraphs.h.

320 {
322 return pagView.get();
323 }

◆ getSVFIR()

SVFIR * SVF::SlicedSVFIRView::getSVFIR ( ) const
inline

Get original SVFIR.

Definition at line 362 of file SlicedGraphs.h.

363 {
364 return svfir;
365 }

◆ getThreadCallGraph() [1/2]

SlicedThreadCallGraphView * SVF::SlicedSVFIRView::getThreadCallGraph ( )
inline

Definition at line 335 of file SlicedGraphs.h.

336 {
337 return tcgView.get();
338 }

◆ getThreadCallGraph() [2/2]

const SlicedThreadCallGraphView * SVF::SlicedSVFIRView::getThreadCallGraph ( ) const
inline

Get SlicedThreadCallGraphView.

Definition at line 331 of file SlicedGraphs.h.

332 {
333 return tcgView.get();
334 }

Member Data Documentation

◆ icfgView

std::unique_ptr<SlicedICFGView> SVF::SlicedSVFIRView::icfgView
private

Definition at line 374 of file SlicedGraphs.h.

◆ pagView

std::unique_ptr<SlicedPAGView> SVF::SlicedSVFIRView::pagView
mutableprivate

Definition at line 375 of file SlicedGraphs.h.

◆ svfir

SVFIR* SVF::SlicedSVFIRView::svfir
private

Definition at line 373 of file SlicedGraphs.h.

◆ tcgView

std::unique_ptr<SlicedThreadCallGraphView> SVF::SlicedSVFIRView::tcgView
private

Definition at line 376 of file SlicedGraphs.h.


The documentation for this class was generated from the following files: