2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Intraprozedural analyses to estimate the call graph.
9 * @author Hubert Schmid
12 * Interprocedural analysis to estimate the calling relation.
14 * This analysis computes all entities representing methods that
15 * can be called at a Call node. Further it computes a set of
16 * methods that are 'free', i.e., their adress is handled by
17 * the program directly, or they are visible external.
19 #ifndef FIRM_ANA_CGANA_H
20 #define FIRM_ANA_CGANA_H
22 #include "firm_types.h"
25 /** @addtogroup callgraph
29 /** Analyses a rough estimation of the possible call graph.
31 * Determines for each Call node the set of possibly called methods.
32 * Stores the result in the field 'callees' of the Call node. If the
33 * address can not be analysed, e.g. because it is loaded from a
34 * variable, the array contains the unknown_entity. (See
35 * set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
36 * the methods that can be called from external or via function
37 * pointers. This datastructure must be freed with 'xfree()' by the
40 * cgana() sets the callee_info_state of each graph and the program to
43 * The algorithm implements roughly Static Class Hierarchy Analysis
44 * as described in "Optimization of Object-Oriented Programs Using
45 * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
48 * Performs some optimizations possible by the analysed information:
49 * - Replace SymConst-name nodes by SymConst-entity nodes if possible.
50 * - Replace (Sel-method(Alloc)) by SymConst-entity.
51 * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
53 FIRM_API size_t cgana(ir_entity ***free_methods);
56 * Frees callee information.
58 * Sets callee_info_state of the graph passed to none. Sets callee field
59 * in all call nodes to NULL. Else it happens that the field contains
60 * pointers to other than firm arrays.
62 FIRM_API void free_callee_info(ir_graph *irg);
63 /** Frees callee information for all graphs in the current program. */
64 FIRM_API void free_irp_callee_info(void);
67 * Optimizes the address expressions passed to call nodes.
68 * Performs only the optimizations done by cgana.
70 FIRM_API void opt_call_addrs(void);