2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Intraprozedural analyses to estimate the call graph.
23 * @author Hubert Schmid
27 * Interprocedural analysis to estimate the calling relation.
29 * This analysis computes all entities representing methods that
30 * can be called at a Call node. Further it computes a set of
31 * methods that are 'free', i.e., their adress is handled by
32 * the program directly, or they are visible external.
34 #ifndef FIRM_ANA_CGANA_H
35 #define FIRM_ANA_CGANA_H
37 #include "firm_types.h"
40 /** Analyses a rough estimation of the possible call graph.
42 * Determines for each Call node the set of possibly called methods.
43 * Stores the result in the field 'callees' of the Call node. If the
44 * address can not be analysed, e.g. because it is loaded from a
45 * variable, the array contains the unknown_entity. (See
46 * set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
47 * the methods that can be called from external or via function
48 * pointers. This datastructure must be freed with 'xfree()' by the
51 * cgana() sets the callee_info_state of each graph and the program to
54 * The algorithm implements roughly Static Class Hierarchy Analysis
55 * as described in "Optimization of Object-Oriented Programs Using
56 * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
59 * Performs some optimizations possible by the analysed information:
60 * - Replace SymConst-name nodes by SymConst-entity nodes if possible.
61 * - Replace (Sel-method(Alloc)) by SymConst-entity.
62 * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
64 FIRM_API size_t cgana(ir_entity ***free_methods);
67 * Free callee information.
69 * Sets callee_info_state of the graph passed to none. Sets callee field
70 * in all call nodes to NULL. Else it happens that the field contains
71 * pointers to other than firm arrays.
73 FIRM_API void free_callee_info(ir_graph *irg);
74 FIRM_API void free_irp_callee_info(void);
77 * Optimize the address expressions passed to call nodes.
78 * Performs only the optimizations done by cgana.
80 FIRM_API void opt_call_addrs(void);