summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0cfd6be)
added firm_dbg output
[r6878]
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
+/**
+ * @file escape_ana.c
+ * A fast and simple Escape analysis.
#include "irgmod.h"
#include "ircons.h"
#include "escape_ana.h"
#include "irgmod.h"
#include "ircons.h"
#include "escape_ana.h"
+/** debug handle */
+firm_dbg_module_t *dbgHandle;
+
/**
* checks whether a Raise leaves a method
*/
/**
* checks whether a Raise leaves a method
*/
* determine if a value calculated by n "escape", ie
* is stored somewhere we could not track
*/
* determine if a value calculated by n "escape", ie
* is stored somewhere we could not track
*/
-static int do_escape(ir_node *n) {
+static int can_escape(ir_node *n) {
int i, j, k;
/* should always be pointer mode or we made some mistake */
int i, j, k;
/* should always be pointer mode or we made some mistake */
+ else if (get_irn_op(ptr) == op_Sel) {
/* go through all possible callees */
for (k = get_Call_n_callees(succ) - 1; k >= 0; --k) {
ent = get_Call_callee(succ, k);
/* go through all possible callees */
for (k = get_Call_n_callees(succ) - 1; k >= 0; --k) {
ent = get_Call_callee(succ, k);
+ if (ent == unknown_entity) {
+ /* we don't know what will be called, a possible escape */
+ return 1;
+ }
+
for (j = get_Call_n_params(succ) - 1; j >= 0; --j) {
if (get_Call_param(succ, j) == n) {
/* n is the j'th param of the call */
for (j = get_Call_n_params(succ) - 1; j >= 0; --j) {
if (get_Call_param(succ, j) == n) {
/* n is the j'th param of the call */
+ else /* we don't know want will called */
+ return 1;
+
if (! mode_is_reference(get_irn_mode(succ)))
continue;
if (! mode_is_reference(get_irn_mode(succ)))
continue;
- if (! do_escape(adr)) {
+ if (! can_escape(adr)) {
set_irn_link(alloc, env->found_allocs);
env->found_allocs = alloc;
}
set_irn_link(alloc, env->found_allocs);
env->found_allocs = alloc;
}
ir_node *alloc, *next, *mem, *sel;
type *ftp;
entity *ent;
ir_node *alloc, *next, *mem, *sel;
type *ftp;
entity *ent;
unsigned nr = 0;
dbg_info *dbg;
unsigned nr = 0;
dbg_info *dbg;
next = get_irn_link(alloc);
dbg = get_irn_dbg_info(alloc);
next = get_irn_link(alloc);
dbg = get_irn_dbg_info(alloc);
- snprintf(name, sizeof(name), "_not_escaped_%u", nr++);
+ DBG((dbgHandle, LEVEL_1, "%+F allocation of %+F\n", irg, alloc));
+
+ snprintf(name, sizeof(name), "%s_NE_%u", get_entity_name(get_irg_entity(irg)), nr++);
ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg);
sel = new_rd_simpleSel(dbg, irg, get_nodes_block(alloc),
ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg);
sel = new_rd_simpleSel(dbg, irg, get_nodes_block(alloc),
+ if (! dbgHandle)
+ dbgHandle = firm_dbg_register("firm.opt.escape_ana");
+
/*
* We treat memory for speed: we first collect all info in a
* list of environments, than do the transformation.
/*
* We treat memory for speed: we first collect all info in a
* list of environments, than do the transformation.