Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
6d3cc33e
Commit
6d3cc33e
authored
Jun 24, 2004
by
Götz Lindenmaier
Browse files
comments, freeing routine
[r3197]
parent
cc1eb794
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/ana/cgana.c
View file @
6d3cc33e
...
...
@@ -37,6 +37,8 @@
#include "dbginfo_t.h"
#include "irdump.h"
/* Eindeutige Adresse zur Markierung von besuchten Knoten und zur
* Darstellung der unbekannten Methode. */
static
void
*
MARK
=
&
MARK
;
...
...
@@ -460,7 +462,10 @@ static void callee_ana_node(ir_node * node, eset * methods) {
entity
*
ent
=
tarval_to_entity
(
get_Const_tarval
(
node
));
assert
(
ent
&&
is_method_type
(
get_entity_type
(
ent
)));
if
(
get_entity_visibility
(
ent
)
!=
visibility_external_allocated
)
{
assert
(
get_entity_irg
(
ent
));
if
(
!
get_entity_irg
(
ent
))
{
dump_entity
(
ent
);
assert
(
get_entity_irg
(
ent
));
}
eset_insert
(
methods
,
ent
);
}
else
{
eset_insert
(
methods
,
MARK
);
/* free method -> unknown */
...
...
@@ -763,13 +768,34 @@ void cgana(int *length, entity ***free_methods) {
DEL_ARR_F
(
free_meths
);
}
static
void
destruct_walker
(
ir_node
*
node
,
void
*
env
)
{
if
(
get_irn_op
(
node
)
==
op_Call
)
{
remove_Call_callee_arr
(
node
);
}
}
void
free_callee_info
(
ir_graph
*
irg
)
{
irg_walk_graph
(
irg
,
destruct_walker
,
NULL
,
NULL
);
set_irg_callee_info_state
(
irg
,
irg_callee_info_none
);
}
/* Optimize the address expressions passed to call nodes.
* Alle SymConst-Operationen, die auf interne Methoden verweisen,
* werden durch Const-Operationen ersetzt.
* Sel Knoten deren entitaeten nicht ueberschrieben werden, werden
* durch Const ersetzt.
* Sel Knoten, fuer die keine Implementierung existiert, werden
* durch Bad ersetzt. */
*
* This optimization performs the following transformations for
* all ir graphs:
* - All SymConst operations that refer to intern methods are replaced
* by Const operations refering to the corresponding entity.
* - Sel nodes, that select entities that are not overwritten are
* replaced by Const nodes refering to the selected entity.
* - Sel nodes, for witch no method exists at all are replaced by Bad
* nodes.
* - Sel nodes with a pointer input that is an Alloc node are replaced
* by Const nodes refering to the entity that implements the method in
* the type given by the Alloc node.
*/
void
opt_call_addrs
(
void
)
{
sel_methods_init
();
sel_methods_dispose
();
...
...
ir/ana/cgana.h
View file @
6d3cc33e
...
...
@@ -38,11 +38,17 @@
/** Analyses a rough estimation of the possible call graph.
*
* Bestimmt fuer jede Call-Operation die Menge der aufrufbaren Methode
* und speichert das Ergebnis in der Call-Operation. (siehe
* "set_Call_callee"). Die Methode gibt die Menge der
* "freien" Methoden zurueck, die vom Aufrufer wieder freigegeben
* werden muss (free).
* Determines for each Call node the set of possibly called methods.
* Stores the result in the field 'callees' of the Call node. If the
* address can not be analysed, e.g. because it is loaded from a
* variable, the array contains NULL. @@@ the array should contain a
* special entity 'unknown'. (See "set_Call_callee"). cgana returns
* the set of 'free' methods, i.e., the methods that can be called
* from external or via function pointers. This datastructure must
* be freed with 'free()' by the caller of cgana.
*
* cgana sets the callee_info_state of each graph to consistent.
*
* The algorithm implements roughly Static Class Hierarchy Analysis
* as described in "Optimization of Object-Oriented Programs Using
* Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
...
...
@@ -56,6 +62,12 @@
/* @@@ I assume this can not be called via JNI :-( -- how to obtain the array pointer? */
void
cgana
(
int
*
len
,
entity
***
free_methods
);
/** Free callee information.
*
* Sets callee_info_state of the graph passed to none.
*/
void
free_callee_info
(
ir_graph
*
irg
);
/* Optimize the address expressions passed to call nodes.
* Performs only the optimizations done by cgana. */
/* @@@ move to irgopt ?! */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment