retdec
Public Types | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::NodesOfVarUseCFGTraversal Class Referencefinal

A CFG traversal that returns all nodes where the variables from VarDefStms are used. More...

#include <nodes_of_var_use_cfg_traversal.h>

Inheritance diagram for retdec::llvmir2hll::NodesOfVarUseCFGTraversal:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::NodesOfVarUseCFGTraversal:
Collaboration graph
[legend]

Public Types

using CFGNodeSet = std::set< ShPtr< CFG::Node > >
 Set of cfg nodes. More...
 
using VarDefStmtNodeMap = std::map< ShPtr< VarDefStmt >, CFGNodeSet >
 

Static Public Member Functions

static ShPtr< VarDefStmtNodeMapgetNodesOfUseVariable (const VarDefStmtSet &setOfVarDefStmt, ShPtr< CFG > cfg, ShPtr< ValueAnalysis > va)
 Function finds all nodes where is variable from it's own definition used. More...
 

Private Types

using VarVarDefMap = std::map< ShPtr< Variable >, ShPtr< VarDefStmt > >
 Maping of a variable into a VarDefStmt. More...
 

Private Member Functions

 NodesOfVarUseCFGTraversal (const VarDefStmtSet &setOfVarDefStmt, ShPtr< CFG > cfg, ShPtr< ValueAnalysis > va)
 Constructs a new traverser. More...
 
virtual bool visitStmt (ShPtr< Statement > stmt) override
 Visits the given statement stmt. More...
 
virtual bool getEndRetVal () const override
 Returns the value that should be returned when an end of the traversal is reached. More...
 
virtual bool combineRetVals (bool origRetVal, bool newRetVal) const override
 Computes a new return value from the original return value (origRetVal) and the new return value (newRetVal). More...
 

Private Attributes

ShPtr< ValueAnalysisva
 Analysis of values. More...
 
ShPtr< VarDefStmtNodeMapmapOfVarDefStmtNodes
 
VarVarDefMap mapOfVarVarDef
 Mapping a variable from VarDefStmt to VarDefStmt. More...
 

Additional Inherited Members

- Protected Member Functions inherited from retdec::llvmir2hll::CFGTraversal
 CFGTraversal (ShPtr< CFG > cfg, bool defaultCurrRetVal)
 Constructs a new traverser. More...
 
 ~CFGTraversal ()=default
 
bool getCurrRetVal () const
 Returns the value that should be returned as the result of visiting a statement. More...
 
bool performTraversal (ShPtr< Statement > startStmt)
 Performs a traversal of the current CFG, starting at startStmt. More...
 
bool performTraversalFromSuccessors (ShPtr< Statement > stmt)
 Performs a traversal of the current CFG, starting at the successor(s) of stmt. More...
 
bool performReverseTraversal (ShPtr< Statement > startStmt)
 Performs a reverse traversal of the current CFG, starting at startStmt. More...
 
bool performReverseTraversalFromPredecessors (ShPtr< Statement > stmt)
 Performs a reverse traversal of the current CFG, starting at the predecessor(s) of stmt. More...
 
- Protected Attributes inherited from retdec::llvmir2hll::CFGTraversal
ShPtr< CFGcfg
 CFG that is being traversed. More...
 
StmtUSet checkedStmts
 Statements that have been checked (to prevent looping). More...
 
bool currRetVal
 Current return value of visitStmt(). More...
 
bool stopTraversal
 Should the traversal be stopped? More...
 

Detailed Description

A CFG traversal that returns all nodes where the variables from VarDefStms are used.

This class is meant to be used in VarDefStmtOptimizer.

Instances of this class have reference object semantics. This is a concrete traverser which should not be subclassed.

Member Typedef Documentation

◆ CFGNodeSet

Set of cfg nodes.

◆ VarDefStmtNodeMap

Mapping of a VarDefStmt into a Node. Saves all nodes where variable from it's own definition is used.

◆ VarVarDefMap

Maping of a variable into a VarDefStmt.

Constructor & Destructor Documentation

◆ NodesOfVarUseCFGTraversal()

retdec::llvmir2hll::NodesOfVarUseCFGTraversal::NodesOfVarUseCFGTraversal ( const VarDefStmtSet setOfVarDefStmt,
ShPtr< CFG cfg,
ShPtr< ValueAnalysis va 
)
private

Constructs a new traverser.

See the description of getNodesOfUseVariable for information on the parameters.

Member Function Documentation

◆ combineRetVals()

bool retdec::llvmir2hll::NodesOfVarUseCFGTraversal::combineRetVals ( bool  origRetVal,
bool  newRetVal 
) const
overrideprivatevirtual

Computes a new return value from the original return value (origRetVal) and the new return value (newRetVal).

Implements retdec::llvmir2hll::CFGTraversal.

◆ getEndRetVal()

bool retdec::llvmir2hll::NodesOfVarUseCFGTraversal::getEndRetVal ( ) const
overrideprivatevirtual

Returns the value that should be returned when an end of the traversal is reached.

For example, the end may mean the end node of the CFG or a statement that has already been traversed.

Implements retdec::llvmir2hll::CFGTraversal.

◆ getNodesOfUseVariable()

ShPtr< NodesOfVarUseCFGTraversal::VarDefStmtNodeMap > retdec::llvmir2hll::NodesOfVarUseCFGTraversal::getNodesOfUseVariable ( const VarDefStmtSet setOfVarDefStmt,
ShPtr< CFG cfg,
ShPtr< ValueAnalysis va 
)
static

Function finds all nodes where is variable from it's own definition used.

Parameters
[in]setOfVarDefStmtSet with VarDefStmt statements.
[in]cfgCFG that should be traversed.
[in]vaAnalysis of values.
Returns
map where key is a VarDefStmt and item is a set of all nodes where variable from VarDefStmt is used.
Preconditions
  • cfg and va are non-null

This function leaves va in a valid state.

◆ visitStmt()

bool retdec::llvmir2hll::NodesOfVarUseCFGTraversal::visitStmt ( ShPtr< Statement stmt)
overrideprivatevirtual

Visits the given statement stmt.

return true if the traversing should continue, false otherwise.

Note: checkedStmts is modified in CFGTraversal, so it is not necessary for the implementation of this function to add stmt to checkedStmts.

If you want the traversal to end prematurely, set the stopTraversal variable to true. Otherwise, if you just return false, the traversal may still continue from other branches because of recursion.

Implements retdec::llvmir2hll::CFGTraversal.

Member Data Documentation

◆ mapOfVarDefStmtNodes

ShPtr<VarDefStmtNodeMap> retdec::llvmir2hll::NodesOfVarUseCFGTraversal::mapOfVarDefStmtNodes
private

A result map where key is a VarDefStmt statement and item is a set of nodes where variable from VarDefStmt statement is used.

◆ mapOfVarVarDef

VarVarDefMap retdec::llvmir2hll::NodesOfVarUseCFGTraversal::mapOfVarVarDef
private

Mapping a variable from VarDefStmt to VarDefStmt.

◆ va

ShPtr<ValueAnalysis> retdec::llvmir2hll::NodesOfVarUseCFGTraversal::va
private

Analysis of values.


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