retdec
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
retdec::llvmir2hll::OptimCallInfoObtainer Class Reference

Obtainer of information about functions and function calls that assumes it has access to complete information about the module. More...

#include <optim_call_info_obtainer.h>

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

Public Member Functions

virtual void init (ShPtr< CG > cg, ShPtr< ValueAnalysis > va) override
 Initializes the obtainer. More...
 
virtual std::string getId () const override
 Returns the ID of the obtainer. More...
 
virtual ShPtr< CallInfogetCallInfo (ShPtr< CallExpr > call, ShPtr< Function > caller) override
 Computes and returns information about the given function call which occurs in caller. More...
 
virtual ShPtr< FuncInfogetFuncInfo (ShPtr< Function > func) override
 Computes and returns information about the given function. More...
 
- Public Member Functions inherited from retdec::llvmir2hll::CallInfoObtainer
virtual ~CallInfoObtainer ()=default
 
ShPtr< CGgetCG () const
 Returns the call graph with which the obtainer has been initialized. More...
 
ShPtr< CFGgetCFGForFunc (ShPtr< Function > func) const
 Returns the CFG for func after the obtainer has been initialized. More...
 
virtual bool isInitialized () const
 Returns true if the obtainer has been initialized, false otherwise. More...
 

Static Public Member Functions

static ShPtr< CallInfoObtainercreate ()
 Creates a new obtainer. More...
 

Private Types

using FuncInfoMap = std::map< ShPtr< Function >, ShPtr< OptimFuncInfo > >
 Mapping of a function into its info. More...
 
using CallInfoMap = std::map< ShPtr< CallExpr >, ShPtr< OptimCallInfo > >
 Mapping of a function call into its info. More...
 

Private Member Functions

 OptimCallInfoObtainer ()
 Constructs a new obtainer. More...
 
void computeAllFuncInfos ()
 Computes funcInfoMap for each function in the module. More...
 
void computeFuncInfo (ShPtr< Function > func)
 Computes funcInfoMap[func] for func from the currently known information. More...
 
void computeFuncInfos (const FuncSet &funcs)
 Computes funcInfoMap[f] for every function f from funcs using the currently known information. More...
 
VarSet skipLocalVars (const VarSet &vars)
 Returns the set of variables that are in both vars and globalVars. More...
 
ShPtr< OptimFuncInfocomputeFuncInfoDeclaration (ShPtr< Function > func)
 Computes and returns a function info for the given function declaration. More...
 
ShPtr< OptimFuncInfocomputeFuncInfoDefinition (ShPtr< Function > func)
 Computes and returns a function info for the given function definition. More...
 
ShPtr< OptimCallInfocomputeCallInfo (ShPtr< CallExpr > call, ShPtr< Function > caller)
 Computes and returns information about the given function call which occurs in caller. More...
 

Static Private Member Functions

static bool areDifferent (ShPtr< OptimFuncInfo > fi1, ShPtr< OptimFuncInfo > fi2)
 Returns true if fi1 differs from fi2, false otherwise. More...
 
static bool hasChanged (const FuncInfoMap &oldInfo, const FuncInfoMap &newInfo)
 Returns true if the FuncInfos in newInfo for functions that are also in oldInfo have changed, false otherwise. More...
 

Private Attributes

FuncInfoMap funcInfoMap
 Mapping of a function into its info. More...
 
CallInfoMap callInfoMap
 Mapping of a call into its info. More...
 
VarSet globalVars
 Global variables in the module, including functions. More...
 

Friends

class OptimFuncInfoCFGTraversal
 

Additional Inherited Members

- Protected Types inherited from retdec::llvmir2hll::CallInfoObtainer
using FuncVectorSet = std::vector< FuncSet >
 Vector of sets of functions. More...
 
using FuncCFGMap = std::map< ShPtr< Function >, ShPtr< CFG > >
 Mapping of a function into its CFG. More...
 
- Protected Member Functions inherited from retdec::llvmir2hll::CallInfoObtainer
 CallInfoObtainer ()
 Constructs a new obtainer. More...
 
ShPtr< FuncInfoCompOrdergetFuncInfoCompOrder (ShPtr< CG > cg)
 Computes an order in which FuncInfos should be computed. More...
 
- Protected Attributes inherited from retdec::llvmir2hll::CallInfoObtainer
ShPtr< Modulemodule
 The current module. More...
 
ShPtr< CGcg
 Call graph of the current module. More...
 
ShPtr< ValueAnalysisva
 Analysis of values. More...
 
FuncCFGMap funcCFGMap
 Mapping of a function into its CFG. More...
 
ShPtr< CFGBuildercfgBuilder
 The used builder of CFGs. More...
 

Detailed Description

Obtainer of information about functions and function calls that assumes it has access to complete information about the module.

Currently, this obtainer utilizes the following assumptions:

Compare with PessimCallInfoObtainer.

Use create() to create instances. Instances of this class have reference object semantics.

Member Typedef Documentation

◆ CallInfoMap

Mapping of a function call into its info.

◆ FuncInfoMap

Mapping of a function into its info.

Constructor & Destructor Documentation

◆ OptimCallInfoObtainer()

retdec::llvmir2hll::OptimCallInfoObtainer::OptimCallInfoObtainer ( )
private

Constructs a new obtainer.

See create() for the description of parameters.

Member Function Documentation

◆ areDifferent()

bool retdec::llvmir2hll::OptimCallInfoObtainer::areDifferent ( ShPtr< OptimFuncInfo fi1,
ShPtr< OptimFuncInfo fi2 
)
staticprivate

Returns true if fi1 differs from fi2, false otherwise.

◆ computeAllFuncInfos()

void retdec::llvmir2hll::OptimCallInfoObtainer::computeAllFuncInfos ( )
private

Computes funcInfoMap for each function in the module.

Declarations are also considered.

◆ computeCallInfo()

ShPtr< OptimCallInfo > retdec::llvmir2hll::OptimCallInfoObtainer::computeCallInfo ( ShPtr< CallExpr call,
ShPtr< Function caller 
)
private

Computes and returns information about the given function call which occurs in caller.

See the description of getCallInfo() for more information on the preconditions.

◆ computeFuncInfo()

void retdec::llvmir2hll::OptimCallInfoObtainer::computeFuncInfo ( ShPtr< Function func)
private

Computes funcInfoMap[func] for func from the currently known information.

◆ computeFuncInfoDeclaration()

ShPtr< OptimFuncInfo > retdec::llvmir2hll::OptimCallInfoObtainer::computeFuncInfoDeclaration ( ShPtr< Function func)
private

Computes and returns a function info for the given function declaration.

Preconditions
  • func is a declaration

◆ computeFuncInfoDefinition()

ShPtr< OptimFuncInfo > retdec::llvmir2hll::OptimCallInfoObtainer::computeFuncInfoDefinition ( ShPtr< Function func)
private

Computes and returns a function info for the given function definition.

Preconditions
  • func is a definition

◆ computeFuncInfos()

void retdec::llvmir2hll::OptimCallInfoObtainer::computeFuncInfos ( const FuncSet funcs)
private

Computes funcInfoMap[f] for every function f from funcs using the currently known information.

The computation is iterative. The function keeps computing funcInfoMap[f] for every function f from funcs until there is no change (i.e. it performs a fixed-point computation).

◆ create()

ShPtr< CallInfoObtainer > retdec::llvmir2hll::OptimCallInfoObtainer::create ( )
static

Creates a new obtainer.

◆ getCallInfo()

ShPtr< CallInfo > retdec::llvmir2hll::OptimCallInfoObtainer::getCallInfo ( ShPtr< CallExpr call,
ShPtr< Function caller 
)
overridevirtual

Computes and returns information about the given function call which occurs in caller.

Preconditions
  • the call obtainer has been initialized using init()
  • the given call and caller exist in the module

Implements retdec::llvmir2hll::CallInfoObtainer.

◆ getFuncInfo()

ShPtr< FuncInfo > retdec::llvmir2hll::OptimCallInfoObtainer::getFuncInfo ( ShPtr< Function func)
overridevirtual

Computes and returns information about the given function.

Preconditions
  • the call obtainer has been initialized using init()
  • the given function exists in the module

Implements retdec::llvmir2hll::CallInfoObtainer.

◆ getId()

std::string retdec::llvmir2hll::OptimCallInfoObtainer::getId ( ) const
overridevirtual

Returns the ID of the obtainer.

Implements retdec::llvmir2hll::CallInfoObtainer.

◆ hasChanged()

bool retdec::llvmir2hll::OptimCallInfoObtainer::hasChanged ( const FuncInfoMap oldInfo,
const FuncInfoMap newInfo 
)
staticprivate

Returns true if the FuncInfos in newInfo for functions that are also in oldInfo have changed, false otherwise.

◆ init()

void retdec::llvmir2hll::OptimCallInfoObtainer::init ( ShPtr< CG cg,
ShPtr< ValueAnalysis va 
)
overridevirtual

Initializes the obtainer.

Parameters
[in]cgThe obtainer will be initialized with this call graph.
[in]vaThe used analysis of values.

This member function has to be called (1) when an instance of this class (or its subclass) is created and (2) whenever the current module is changed in a way that changes the call graph of the module and/or the variables which are read/modified in a function.

Preconditions
  • both va and cg are non-null
  • va is in a valid state

This function leaves va in a valid state.

Reimplemented from retdec::llvmir2hll::CallInfoObtainer.

◆ skipLocalVars()

VarSet retdec::llvmir2hll::OptimCallInfoObtainer::skipLocalVars ( const VarSet vars)
private

Returns the set of variables that are in both vars and globalVars.

Friends And Related Function Documentation

◆ OptimFuncInfoCFGTraversal

friend class OptimFuncInfoCFGTraversal
friend

Member Data Documentation

◆ callInfoMap

CallInfoMap retdec::llvmir2hll::OptimCallInfoObtainer::callInfoMap
private

Mapping of a call into its info.

◆ funcInfoMap

FuncInfoMap retdec::llvmir2hll::OptimCallInfoObtainer::funcInfoMap
private

Mapping of a function into its info.

◆ globalVars

VarSet retdec::llvmir2hll::OptimCallInfoObtainer::globalVars
private

Global variables in the module, including functions.


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