ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VirtualFunctionAnalysis Class Reference

To resolve virtual funcitons correctly we need to answer the question "What are the possible types that an object point to at a call site?" So we basically need to perform Pointer Aliasing Analysis. More...

#include <VirtualFunctionAnalysis.h>

Inheritance diagram for VirtualFunctionAnalysis:
Collaboration diagram for VirtualFunctionAnalysis:

Public Member Functions

 VirtualFunctionAnalysis (SgProject *__project)
 
void run ()
 Function which actually performs the DataFlowAnalyis. More...
 
void reset ()
 DataFlow based Virtual function resolve technique is expensive. More...
 
void pruneCallGraph (CallGraphBuilder &)
 Using the DataFlow based Virtual Function Analysis it prunes the call graph to generate more precise and accurate call graph. More...
 
void resolveFunctionCall (SgExpression *, std::vector< SgFunctionDeclaration * > &)
 Given a Callsite(SgFunctionCallExp or SgConstructionInitializer) it resolves the function calls. More...
 
 ~VirtualFunctionAnalysis ()
 
- Public Member Functions inherited from PtrAliasAnalysis
 PtrAliasAnalysis (SgProject *__project)
 
 ~PtrAliasAnalysis ()
 
void getFunctionDeclarations (std::vector< SgFunctionDeclaration * > &)
 Get the list of function declarations to perform interprocedural DataFlowAnalysis. More...
 
bool runAndCheckIntraProcAnalysis (SgFunctionDeclaration *)
 Execute IntraProc Analysis and check whether something changed. More...
 
- Public Member Functions inherited from InterProcDataFlowAnalysis
 InterProcDataFlowAnalysis (SgProject *_project)
 

Private Attributes

bool isExecuted
 

Additional Inherited Members

- Public Types inherited from PtrAliasAnalysis
enum  COLOR {
  WHITE =0,
  GREY,
  BLACK
}
 Enum used for Topological sorting. More...
 
enum  TRAVERSAL_TYPE {
  TOPOLOGICAL =0,
  REVERSE_TOPOLOGICAL
}
 Enum used for identifying traversal type. More...
 
- Protected Attributes inherited from PtrAliasAnalysis
SgIncidenceDirectedGraphcallGraph
 The stored callGraph for internal processing. More...
 
boost::unordered_map
< SgFunctionDeclaration
*, IntraProcAliasAnalysis * > 
intraAliases
 A map from SgFunctionDeclaration to IntraProcAliasAnalysis. More...
 
boost::unordered_map
< SgExpression *, std::vector
< SgFunctionDeclaration * > > 
resolver
 A map which stores the function call resolve information. More...
 
ClassHierarchyWrapperclassHierarchy
 ClassHierarchy of the project. More...
 
CallGraphBuildercgBuilder
 

Detailed Description

To resolve virtual funcitons correctly we need to answer the question "What are the possible types that an object point to at a call site?" So we basically need to perform Pointer Aliasing Analysis.

For this project we opted to do InterProcedural FlowSensitive DataFlow Analysis as described in

"Flow-Sensitive Interprocedural Type Analysis for C++”, TechReport ‘95  Paul Carini Harini Srinivasan

So we perform Pointer Alias Analysis and Virtual Function Analysis simultenously which in turn complements each other to be more precise. The basic idea is as follows:

  1. Compute a call graph ignoring all the virtual function calls.
  2. Iterate over the nodes of the call graph topologically and reverse topologically in alternative iteration until no Alias information is modified. i. For each function:
    • Compute a Control Flow Graph consists of nodes which can generate new aliases eg. SgAssignOp, SgAssignInitializer, SgFunctionCallExp, SgConstructorInitializer etc.
    • Compute the alias relations for each node ii. Perform IntraProcDataFlowAnalysis util they stabilizes
    • Propagate the Alias relation over the ControlFlow Graph to generate entry and exit CompactRepresentation for each node. iii. Using the Alias Information resolve the possible function callsites within this function
      • Handle the Function Parameters, return types and Constructor parameters correctly. iv. Compute Entry for all the functions called from this function Virutal Function Analysis and PointerAliasAnalysis are dependent on each other for their accuracy. That's why they are done together

Definition at line 42 of file VirtualFunctionAnalysis.h.

Constructor & Destructor Documentation

VirtualFunctionAnalysis::VirtualFunctionAnalysis ( SgProject __project)
inline

Definition at line 47 of file VirtualFunctionAnalysis.h.

VirtualFunctionAnalysis::~VirtualFunctionAnalysis ( )
inline

Definition at line 68 of file VirtualFunctionAnalysis.h.

Member Function Documentation

void VirtualFunctionAnalysis::run ( )
virtual

Function which actually performs the DataFlowAnalyis.

Reimplemented from PtrAliasAnalysis.

void VirtualFunctionAnalysis::reset ( )

DataFlow based Virtual function resolve technique is expensive.

So it's memorized so that subsequent resolve calls can be answered. This function reset the memorization.

void VirtualFunctionAnalysis::pruneCallGraph ( CallGraphBuilder )

Using the DataFlow based Virtual Function Analysis it prunes the call graph to generate more precise and accurate call graph.

void VirtualFunctionAnalysis::resolveFunctionCall ( SgExpression ,
std::vector< SgFunctionDeclaration * > &   
)

Given a Callsite(SgFunctionCallExp or SgConstructionInitializer) it resolves the function calls.

For Virtual Functions it returns the minimal set of functions that may be execute at runtime.

Member Data Documentation

bool VirtualFunctionAnalysis::isExecuted
private

Definition at line 44 of file VirtualFunctionAnalysis.h.


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