* @brief Intraprozedural analyses to estimate the call graph.
* @author Hubert Schmid
* @date 09.06.2002
- * @version $Id$
* @brief
* Interprocedural analysis to estimate the calling relation.
*
#include <string.h>
#include "cgana.h"
-#include "rta.h"
#include "xmalloc.h"
#include "irnode_t.h"
*/
static void free_mark(ir_node *node, eset * set)
{
- size_t i, n;
-
if (get_irn_link(node) == MARK)
return; /* already visited */
case iro_Sel: {
ir_entity *ent = get_Sel_entity(node);
if (is_method_entity(ent)) {
+ size_t i, n;
for (i = 0, n = get_Sel_n_methods(node); i < n; ++i) {
eset_insert(set, get_Sel_method(node, i));
}
static void free_ana_walker(ir_node *node, void *env)
{
eset *set = (eset*) env;
- int i;
if (get_irn_link(node) == MARK) {
/* already visited */
/* nothing */
break;
case iro_Call:
+ {
+ size_t i, n;
/* we must handle Call nodes specially, because their call address input
do not expose a method address. */
set_irn_link(node, MARK);
- for (i = get_Call_n_params(node) - 1; i >= 0; --i) {
+ for (i = 0, n = get_Call_n_params(node); i < n; ++i) {
ir_node *pred = get_Call_param(node, i);
if (mode_is_reference(get_irn_mode(pred))) {
free_mark(pred, set);
}
}
break;
- default:
+ }
+ default: {
+ int i;
/* other nodes: Alle anderen Knoten nehmen wir als Verr�ter an, bis
* jemand das Gegenteil implementiert. */
set_irn_link(node, MARK);
}
break;
}
+ }
}
/**
* Add all method addresses in global new style initializers to the set.
*
* @note
- * We do NOT check the type here, just it it's an entity address.
+ * We do NOT check the type here, just if it's an entity address.
* The reason for this is code like:
*
* void *p = function;
n = initializer->consti.value;
/* let's check if it's the address of a function */
- if (is_Global(n)) {
- ir_entity *ent = get_Global_entity(n);
+ if (is_SymConst_addr_ent(n)) {
+ ir_entity *ent = get_SymConst_entity(n);
if (is_Method_type(get_entity_type(ent)))
eset_insert(set, ent);
* Add all method addresses in global initializers to the set.
*
* @note
- * We do NOT check the type here, just it it's an entity address.
+ * We do NOT check the type here, just if it's an entity address.
* The reason for this is code like:
*
* void *p = function;
{
ir_type *tp;
- /* ignore methods: these of course reference it's address
+ /* ignore methods: these of course reference their addresses
* TODO: remove this later once this incorrect self-initialisation is gone
*/
tp = get_entity_type(ent);
ir_node *irn = get_compound_ent_value(ent, i);
/* let's check if it's the address of a function */
- if (is_Global(irn)) {
- ir_entity *ent = get_Global_entity(irn);
+ if (is_SymConst_addr_ent(irn)) {
+ ir_entity *ent2 = get_SymConst_entity(irn);
- if (is_Method_type(get_entity_type(ent)))
- eset_insert(set, ent);
+ if (is_Method_type(get_entity_type(ent2)))
+ eset_insert(set, ent2);
}
}
}
static size_t get_free_methods(ir_entity ***free_methods)
{
eset *free_set = eset_create();
- size_t i, n;
- int j;
+ size_t i, n, j, m;
ir_entity **arr;
ir_entity *ent;
ir_graph *irg;
/* insert all methods that are used in global variables initializers */
tp = get_glob_type();
- for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
+ for (j = 0, m = get_class_n_members(tp); j < m; ++j) {
ent = get_class_member(tp, j);
add_method_address(ent, free_set);
}
tp = get_tls_type();
- for (j = get_class_n_members(tp) - 1; j >= 0; --j) {
- ent = get_class_member(tp, j);
+ for (j = 0, m = get_compound_n_members(tp); j < m; ++j) {
+ ent = get_compound_member(tp, j);
add_method_address(ent, free_set);
}