3 * File name: ir/ana/cgana.h
4 * Purpose: Intraprozedural analyses to estimate the call graph.
5 * Author: Hubert Schmid
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
14 * Intraprozedurale Analyse zur Abschätzung der Aufrulrelation. Es
15 * wird eine Menge von freien Methoden und anschließend die an den
16 * Call-Operationen aufrufbaren Methoden bestimmt.
25 /* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell)
26 * "explizit" bekannt ist, d.h.:
28 * - die Methode ist von aussen sichtbar (external_visible).
30 * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde
31 * nicht ausschliesslich an den entsprechenden Eingang eines
32 * Call-Knotens weitergegeben, sondern z.B. in den Speicher
33 * geschrieben, als Parameter uebergeben, ...
35 * Die main-Methode ist immer in der Menge enthalten.
37 * Die Links an den "ir_node"s werden geloescht.
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 'free()' 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 nodes by Bad if there is no implementation for the
64 * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
65 * - Replaces Calls by Tuple containing Bads if callee array is empty
66 * (there is no implementation to call)
68 * Leaves Bad control predecessors in the graph!
70 void cgana(int *len, entity ***free_methods);
72 /** Free callee information.
74 * Sets callee_info_state of the graph passed to none. Sets callee field
75 * in all call nodes to NULL. Else it happens that the field contains
76 * pointers to other than firm arrays.
78 void free_callee_info(ir_graph *irg);
79 void free_irp_callee_info(void);
81 /* Optimize the address expressions passed to call nodes.
82 * Performs only the optimizations done by cgana. */
83 void opt_call_addrs(void);
86 #endif /* _CGANA_H_ */