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

#include <SlicedGraphs.h>

Public Member Functions

 SlicedSVFIRView (SVFIR *svfIr, CallGraph *cg, ICFG *icfg, const OrderedSet< const ICFGNode * > &keepNodes, bool buildBridged=true)
 
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 getInEdgesOfCallGraphNode (const CallGraphNode *node, std::vector< const CallGraphEdge * > &out) const
 
const CallGraphgetAnalysisCallGraph () const
 
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 Attributes

SVFIRsvfIr
 
std::unique_ptr< SlicedICFGViewicfgView
 
std::unique_ptr< SlicedPAGViewpagView
 
std::unique_ptr< SlicedThreadCallGraphViewtcgView
 

Detailed Description

Definition at line 310 of file SlicedGraphs.h.

Constructor & Destructor Documentation

◆ SlicedSVFIRView()

SVF::SlicedSVFIRView::SlicedSVFIRView ( SVFIR svfIr,
CallGraph cg,
ICFG icfg,
const OrderedSet< const ICFGNode * > &  keepNodes,
bool  buildBridged = true 
)

Definition at line 728 of file SlicedGraphs.cpp.

733 : svfIr(svfIr)
734{
735 // Derive keptFunctions from keepNodes
737 for (const ICFGNode* node : keepNodes)
738 {
739 if (node != nullptr && node->getFun() != nullptr)
740 {
741 keptFunctions.insert(node->getFun());
742 }
743 }
744
745 // The MTA pipeline always slices over a ThreadCallGraph.
746 ThreadCallGraph* tcg = SVFUtil::dyn_cast<ThreadCallGraph>(cg);
747 assert(tcg != nullptr && "SlicedSVFIRView expects a ThreadCallGraph");
748 tcgView = std::make_unique<SlicedThreadCallGraphView>(tcg, keptFunctions, keepNodes);
749
750 // Create ICFG view (based on keepNodes and keptFunctions)
751 icfgView = std::make_unique<SlicedICFGView>(icfg, cg, keepNodes, keptFunctions, buildBridged);
752
753 // Create PAG view (extract statements from keepNodes)
755 for (const ICFGNode* node : keepNodes)
756 {
757 const ICFGNode::SVFStmtList& stmts = node->getSVFStmts();
758 keptStmts.insert(stmts.begin(), stmts.end());
759 }
760 pagView = std::make_unique<SlicedPAGView>(svfIr, keptStmts);
761}
std::list< const SVFStmt * > SVFStmtList
Definition ICFGNode.h:65
std::unique_ptr< SlicedPAGView > pagView
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 763 of file SlicedGraphs.cpp.

764{
765 icfgView->dump(prefix + "_icfg");
766 tcgView->dump(prefix + "_threadcallgraph");
767 pagView->dump(prefix + "_pag");
768}

◆ dumpStats()

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

Output statistics.

Definition at line 770 of file SlicedGraphs.cpp.

771{
772 std::string label = prefix.empty() ? "[SlicedSVFIRView]" : "[" + prefix + "]";
773 SVFUtil::outs() << label << " Statistics:\n";
774 SVFUtil::outs() << " ICFG nodes: " << icfgView->getKeptNodes().size() << "\n";
775 SVFUtil::outs() << " Functions: " << getKeptFunctions().size() << "\n";
776 SVFUtil::outs() << " PAG statements: " << getKeptStatements().size() << "\n";
778 {
779 SVFUtil::outs() << " Indirect callsites that lost all targets: "
780 << getIndirectSitesWithEmptyTargets().size() << "\n";
781 }
782}
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

◆ getAnalysisCallGraph()

const CallGraph * SVF::SlicedSVFIRView::getAnalysisCallGraph ( ) const

The CallGraph the sliced analyses scan: the sliced ThreadCallGraph's original CallGraph, or the full PAG CallGraph if no TCG view was built.

Definition at line 842 of file SlicedGraphs.cpp.

843{
844 if (getThreadCallGraph() != nullptr)
846 return PAG::getPAG()->getCallGraph();
847}
const CallGraph * getCallGraph()
Get CG.
Definition SVFIR.h:248
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
const SlicedThreadCallGraphView * getThreadCallGraph() const
Get SlicedThreadCallGraphView.
CallGraph * getOriginalCallGraph() const
Get original CallGraph (ThreadCallGraph inherits from CallGraph)

◆ getICFG() [1/2]

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

Definition at line 324 of file SlicedGraphs.h.

325 {
326 return icfgView.get();
327 }

◆ getICFG() [2/2]

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

Get SlicedICFGView.

Definition at line 320 of file SlicedGraphs.h.

321 {
322 return icfgView.get();
323 }

◆ getIndirectSitesWithEmptyTargets()

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

Get indirect call sites that lost all targets after filtering.

Definition at line 356 of file SlicedGraphs.h.

357 {
358 return tcgView->getIndirectSitesWithEmptyTargets();
359 }

◆ getInEdgesOfCallGraphNode()

void SVF::SlicedSVFIRView::getInEdgesOfCallGraphNode ( const CallGraphNode node,
std::vector< const CallGraphEdge * > &  out 
) const

In-edges of a call-graph node under the sliced ThreadCallGraph view (the full node in-edges if no TCG view was built).

Definition at line 831 of file SlicedGraphs.cpp.

833{
834 out.clear();
835 if (getThreadCallGraph() != nullptr)
837 else
838 for (CallGraphEdge* edge : node->getInEdges())
840}
void getInEdgesOf(const CallGraphNode *node, std::vector< const CallGraphEdge * > &out) const
Get in edges of a node (only returns kept edges and source nodes)

◆ getKeptFunctions()

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

Get all kept functions.

Definition at line 350 of file SlicedGraphs.h.

351 {
352 return tcgView->getKeptFunctions();
353 }

◆ getKeptStatements()

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

Get all kept statements.

Definition at line 362 of file SlicedGraphs.h.

363 {
364 return pagView->getKeptStmts();
365 }

◆ getPAG() [1/2]

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

Definition at line 334 of file SlicedGraphs.h.

335 {
336 return pagView.get();
337 }

◆ getPAG() [2/2]

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

Get SlicedPAGView.

Definition at line 330 of file SlicedGraphs.h.

331 {
332 return pagView.get();
333 }

◆ getSVFIR()

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

Get original SVFIR.

Definition at line 380 of file SlicedGraphs.h.

381 {
382 return svfIr;
383 }

◆ getThreadCallGraph() [1/2]

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

Definition at line 344 of file SlicedGraphs.h.

345 {
346 return tcgView.get();
347 }

◆ getThreadCallGraph() [2/2]

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

Get SlicedThreadCallGraphView.

Definition at line 340 of file SlicedGraphs.h.

341 {
342 return tcgView.get();
343 }

Member Data Documentation

◆ icfgView

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

Definition at line 390 of file SlicedGraphs.h.

◆ pagView

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

Definition at line 391 of file SlicedGraphs.h.

◆ svfIr

SVFIR* SVF::SlicedSVFIRView::svfIr
private

Definition at line 389 of file SlicedGraphs.h.

◆ tcgView

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

Definition at line 392 of file SlicedGraphs.h.


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