From f75c9d04c9b10670c0456bb61727f25ee7c2aac0 Mon Sep 17 00:00:00 2001 From: Florian Liekweg Date: Mon, 10 Jan 2005 17:26:34 +0000 Subject: [PATCH] fixup printfs, don't put environments on the stack [r4841] --- ir/ana2/ecg.c | 32 ++++++++------ ir/ana2/irmemwalk.c | 11 +++-- ir/ana2/pto.c | 5 ++- ir/ana2/pto_comp.c | 102 +++++++++++++++++++++++++------------------- ir/ana2/pto_init.c | 59 ++++++++++++++++--------- ir/ana2/pto_util.c | 18 +++++--- ir/ana2/typalise.c | 9 ++-- 7 files changed, 148 insertions(+), 88 deletions(-) diff --git a/ir/ana2/ecg.c b/ir/ana2/ecg.c index 39aded9ab..3dc249114 100644 --- a/ir/ana2/ecg.c +++ b/ir/ana2/ecg.c @@ -82,7 +82,7 @@ void set_main_ctx (ctx_info_t*); ==================== */ static void append_alloc (graph_info_t *ginfo, ir_node *alloc, type *tp) { - alloc_info_t *ainfo = xmalloc(sizeof(*ainfo)); + alloc_info_t *ainfo = (alloc_info_t*) xmalloc (sizeof (alloc_info_t)); ainfo->graph = ginfo->graph; ainfo->alloc = alloc; @@ -101,7 +101,7 @@ static void append_alloc (graph_info_t *ginfo, ir_node *alloc, type *tp) */ static callEd_info_t *append_callEd_info (callEd_info_t *ced, ir_graph *callEd) { - callEd_info_t *nced = xmalloc(sizeof(*nced)); + callEd_info_t *nced = (callEd_info_t*) xmalloc (sizeof (callEd_info_t)); nced->callEd = callEd; nced->prev = ced; @@ -114,7 +114,7 @@ static callEd_info_t *append_callEd_info (callEd_info_t *ced, ir_graph *callEd) */ static void append_calls (graph_info_t *info, ir_node *call, lset_t *callEds) { - call_info_t *cinfo = xmalloc(sizeof(*cinfo)); + call_info_t *cinfo = (call_info_t*) xmalloc (sizeof (call_info_t)); ir_graph *callEd; /* setup */ @@ -124,8 +124,13 @@ static void append_calls (graph_info_t *info, ir_node *call, lset_t *callEds) cinfo->callEds = NULL; /* enter */ - for (callEd = lset_first (callEds); callEd; callEd = lset_next(callEds)) + callEd = lset_first (callEds); + + while (NULL != callEd) { cinfo->callEds = append_callEd_info (cinfo->callEds, callEd); + callEd = lset_next(callEds); + } + } /** @@ -133,7 +138,7 @@ static void append_calls (graph_info_t *info, ir_node *call, lset_t *callEds) */ static void append_call (graph_info_t *info, ir_node *call, ir_graph *callEd) { - call_info_t *cinfo = xmalloc (sizeof(*cinfo)); + call_info_t *cinfo = (call_info_t*) xmalloc (sizeof (call_info_t)); cinfo->call = call; cinfo->prev = info->calls; @@ -347,7 +352,7 @@ static void ecg_calls_act (ir_node *node, void *env) */ static void ecg_fill_graph_calls (ir_graph *graph) { - graph_info_t *ginfo = xmalloc(sizeof(*ginfo)); + graph_info_t *ginfo = (graph_info_t*) xmalloc (sizeof (graph_info_t)); /* memset (ginfo, 0x00, sizeof (graph_info_t)); */ assert (ginfo != graph_infos_list); @@ -389,7 +394,7 @@ static void ecg_fill_calls (void) */ static ctx_info_t *new_ctx (ir_graph *graph, ir_node *call, ctx_info_t *enc) { - ctx_info_t *res = xmalloc(sizeof(*res)); + ctx_info_t *res = (ctx_info_t *) xmalloc (sizeof (ctx_info_t)); res->graph = graph; res->call = call; @@ -442,7 +447,7 @@ static void ecg_fill_ctxs_alloc (void) graph_info_t *ginfo = graph_infos_list; while (NULL != ginfo) { - ginfo->ctxs = xcalloc(ginfo->n_ctxs, sizeof(ginfo->ctxs[0])); + ginfo->ctxs = (ctx_info_t **) xcalloc (ginfo->n_ctxs, sizeof (ctx_info_t *)); /* fprintf (stdout, "graph of \"%s\": n_ctxs = %i\n", @@ -481,7 +486,7 @@ static void ecg_fill_ctxs_write (ir_graph *graph, ctx_info_t *enc_ctx) callEd_info->ctxs [callEd_info->n_ctxs] = ctx; callEd_info->n_ctxs ++; - /* Calling graph -> callEd_graph */ + /* CallR graph -> callEd_graph */ ecg_fill_ctxs_write (callEd_graph, ctx); ced = ced->prev; @@ -514,7 +519,7 @@ static void ecg_fill_ctxs (void) /* Grrr, have to add this ctx manually to main.ginfo ... */ ginfo = ecg_get_info (main_irg); ginfo->n_ctxs = 1; - ginfo->ctxs = xcalloc(1, sizeof(ginfo->ctxs[0])); + ginfo->ctxs = (ctx_info_t **) xcalloc (1, sizeof (ctx_info_t *)); ginfo->ctxs [0] = main_ctx; ecg_fill_ctxs_write (main_irg, main_ctx); @@ -1078,7 +1083,7 @@ void ecg_report () const int n_ctxs = (ginfo->n_ctxs > max_ctxs) ? max_ctxs : ginfo->n_ctxs; fprintf (dot, "\t/* now the ctxs */\n"); - fprintf (dot, "\tctx_0x%08x [label=\"", (void*) graph); + fprintf (dot, "\tctx_0x%08x [label=\"", (int) graph); assert (ginfo->ctxs && "no ctx"); for (i = 0; i < n_ctxs; i ++) { @@ -1107,7 +1112,7 @@ void ecg_report () fprintf (dot, "\tgraph_0x%08x -> ctx_0x%08x:HEAD [label=\"ctx\", dir=\"none\", style=\"dotted\"];\n", - (void*) graph, (void*) graph); + (int) graph, (int) graph); } } else { fprintf (dot, "\t/* graph is not called */\n"); @@ -1175,6 +1180,9 @@ void ecg_ecg (void) /* $Log$ + Revision 1.16 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.15 2004/12/23 15:40:03 beck used new xcalloc diff --git a/ir/ana2/irmemwalk.c b/ir/ana2/irmemwalk.c index a3648f5c8..6720d3028 100644 --- a/ir/ana2/irmemwalk.c +++ b/ir/ana2/irmemwalk.c @@ -41,7 +41,8 @@ /** environment for a single memory walker */ typedef struct walk_mem_env_str { ir_graph *graph; /**< the graph we're visiting */ - unsigned long visited; /**< 'visited' marker */ + unsigned long visited; /**< 'visited' marker + (unsigned long in case we walk more than 2^32 graphs) */ irg_walk_func *pre; /**< pre action */ irg_walk_func *post; /**< post action */ void *env; /**< user-defined environment */ @@ -177,7 +178,8 @@ static void irg_walk_mem_node (ir_node *node, } } break; default: { - fprintf (stderr, "irg_walk_mem_node(): not handled: node[%li].op = %s\n", + fprintf (stderr, "%s: not handled: node[%li].op = %s\n", + __FUNCTION__, get_irn_node_nr (node), get_op_name (get_irn_op (node))); @@ -219,7 +221,7 @@ void irg_walk_mem (ir_graph *graph, void *env) { ir_node *end_block = get_irg_end_block (graph); - walk_mem_env_t *walk_env = xmalloc(sizeof(*walk_env)); + walk_mem_env_t *walk_env = (walk_mem_env_t*) xmalloc (sizeof (walk_mem_env_t)); assert (! get_irg_is_mem_visited (graph)); @@ -261,6 +263,9 @@ void irg_walk_mem (ir_graph *graph, /* $Log$ + Revision 1.9 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.8 2004/12/22 14:43:14 beck made allocations C-like diff --git a/ir/ana2/pto.c b/ir/ana2/pto.c index a4b655544..12547832e 100644 --- a/ir/ana2/pto.c +++ b/ir/ana2/pto.c @@ -80,7 +80,7 @@ void pto_init (int lvl) ecg_iterate_graphs (pto_init_graph_wrapper, NULL); /* debugging only */ - spaces = xmalloc (512 * sizeof(spaces[0])); + spaces = xmalloc (512 * sizeof (char)); memset (spaces, ' ', 512); spaces += 511; *spaces = '\0'; @@ -137,6 +137,9 @@ void pto_cleanup (void) /* $Log$ + Revision 1.17 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.16 2004/12/22 14:43:14 beck made allocations C-like diff --git a/ir/ana2/pto_comp.c b/ir/ana2/pto_comp.c index fc1fd4c41..d7b573182 100644 --- a/ir/ana2/pto_comp.c +++ b/ir/ana2/pto_comp.c @@ -78,8 +78,8 @@ static int add_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env) n_args = get_Call_n_params (call); - DBGPRINT (1, (stdout, "add_graph_args(): args of %s[%li] -> 0x%08x\n", - OPNAME (call), OPNUM (call), (void*) graph)); + DBGPRINT (1, (stdout, "add_graph_args(/*todo*/): args of %s[%li] -> 0x%08x\n", + OPNAME (call), OPNUM (call), (int) graph)); for (i = 0; i < n_args; i ++) { if (NULL != args [i]) { @@ -93,7 +93,7 @@ static int add_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env) change |= qset_insert_all (frm_pto->values, arg_pto->values); - DBGPRINT (2, (stdout, "add_graph_args(): arg [%i]: -> %s[%li] (%i) -> %s[%li] (%i)\n", + DBGPRINT (2, (stdout, "add_graph_args(/*todo*/): arg [%i]: -> %s[%li] (%i) -> %s[%li] (%i)\n", i, OPNAME (call_arg), OPNUM (call_arg), arg_pto->values->id, @@ -125,7 +125,7 @@ static void set_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env) assert (pto); set_node_pto (args [i], pto); - DBGPRINT (1, (stdout, "set_graph_args(): arg [%i]: %s[%li] -> %s[%li] (%i)\n", + DBGPRINT (1, (stdout, "set_graph_args(/*todo*/): arg [%i]: %s[%li] -> %s[%li] (%i)\n", i, OPNAME (call_arg), OPNUM (call_arg), OPNAME (args [i]), OPNUM (args [i]), @@ -162,14 +162,14 @@ static int set_graph_result (ir_graph *graph, ir_node *call) assert (call_pto); - DBGPRINT (0, (stdout, "set_graph_result(): before change args\n")); + DBGPRINT (0, (stdout, "set_graph_result(/*todo*/): before change args\n")); DBGEXE (0, pto_print_pto (end_block)); DBGEXE (0, pto_print_pto (call)); change = qset_insert_all (call_pto->values, ret_pto->values); if (change) { - DBGPRINT (0, (stdout, "set_graph_result(): after change args\n")); + DBGPRINT (0, (stdout, "set_graph_result(/*todo*/): after change args\n")); DBGEXE (0, pto_print_pto (end_block)); DBGEXE (0, pto_print_pto (call)); /* assert (0); */ @@ -244,7 +244,7 @@ static pto_t *get_pto_proj (ir_node *proj, pto_env_t *env) return (in_pto); } default: - fprintf (stderr, "get_pto_proj(): not handled: proj (%s[%li])\n", + fprintf (stderr, "get_pto_proj(/*todo*/): not handled: proj (%s[%li])\n", get_op_name (get_irn_op (proj_in)), get_irn_node_nr (proj_in)); assert (0 && "Proj(?)"); @@ -306,7 +306,7 @@ static pto_t *get_pto_ret (ir_node *ret, pto_env_t *env) assert (pto); - DBGPRINT (9, (stdout, "get_pto_ret(): ")); + DBGPRINT (9, (stdout, "get_pto_ret(/*todo*/): ")); DBGEXE (9, pto_print_pto (ret)); return (pto); @@ -340,7 +340,7 @@ static pto_t *get_pto (ir_node *node, pto_env_t *env) } default: /* stopgap measure */ - fprintf (stderr, "get_pto(): not handled: node[%li].op = %s\n", + fprintf (stderr, "get_pto(/*todo*/): not handled: node[%li].op = %s\n", get_irn_node_nr (node), get_op_name (get_irn_op (node))); assert (0 && "something not handled"); @@ -356,8 +356,8 @@ static void pto_load (ir_node *load, pto_env_t *pto_env) entity *ent; /* perform load */ - DBGPRINT (2, (stdout, "pto_load() (%s[%li]): pto = 0x%08x\n", - OPNAME (load), OPNUM (load), (void*) get_node_pto (load))); + DBGPRINT (2, (stdout, "pto_load(/*todo*/) (%s[%li]): pto = 0x%08x\n", + OPNAME (load), OPNUM (load), (int) get_node_pto (load))); ptr = get_Load_ptr (load); @@ -372,8 +372,8 @@ static void pto_load (ir_node *load, pto_env_t *pto_env) assert (ptr_pto); - DBGPRINT (1, (stdout, "pto_load() (%s[%li]): ptr = 0x%08x\n", - OPNAME (ptr), OPNUM (ptr), (void*) ptr_pto)); + DBGPRINT (1, (stdout, "pto_load(/*todo*/) (%s[%li]): ptr = 0x%08x\n", + OPNAME (ptr), OPNUM (ptr), (int) ptr_pto)); pto_env->change |= mod_load (load, ent, ptr_pto); } @@ -386,7 +386,7 @@ static void pto_store (ir_node *store, pto_env_t *pto_env) pto_t *ptr_pto, *val_pto; /* perform store */ - DBGPRINT (2, (stdout, "pto_store() (%s[%li]) (no pto)\n", + DBGPRINT (2, (stdout, "pto_store(/*todo*/) (%s[%li]) (no pto)\n", OPNAME (store), OPNUM (store))); ptr = get_Store_ptr (store); @@ -404,10 +404,10 @@ static void pto_store (ir_node *store, pto_env_t *pto_env) assert (ptr_pto); assert (val_pto); - DBGPRINT (2, (stdout, "pto_store() (%s[%li]): ptr_pto = 0x%08x\n", - OPNAME (ptr), OPNUM (ptr), (void*) ptr_pto)); - DBGPRINT (2, (stdout, "pto_store() (%s[%li]): val_pto = 0x%08x\n", - OPNAME (val), OPNUM (val), (void*) val_pto)); + DBGPRINT (2, (stdout, "pto_store(/*todo*/) (%s[%li]): ptr_pto = 0x%08x\n", + OPNAME (ptr), OPNUM (ptr), (int) ptr_pto)); + DBGPRINT (2, (stdout, "pto_store(/*todo*/) (%s[%li]): val_pto = 0x%08x\n", + OPNAME (val), OPNUM (val), (int) val_pto)); pto_env->change |= mod_store (store, ent, ptr_pto, val_pto); } @@ -417,20 +417,20 @@ static void pto_method (ir_node *call, pto_env_t *pto_env) int i; callEd_info_t *callEd_info; - DBGPRINT (2, (stdout, "pto_method():%i (%s[%li]): pto = 0x%08x\n", + DBGPRINT (2, (stdout, "pto_method(/*todo*/):%i (%s[%li]): pto = 0x%08x\n", __LINE__, OPNAME (call), OPNUM (call), - (void*) get_node_pto (call))); + (int) get_node_pto (call))); callEd_info = ecg_get_callEd_info (call); if (NULL == callEd_info) { - DBGPRINT (2, (stdout, "pto_method():%i (%s[%li]), no graph\n", + DBGPRINT (2, (stdout, "pto_method(/*todo*/):%i (%s[%li]), no graph\n", __LINE__, OPNAME (call), OPNUM (call))); } i = 0; while (NULL != callEd_info) { - DBGPRINT (2, (stdout, "pto_method():%i (%s[%li]), graph %i\n", + DBGPRINT (2, (stdout, "pto_method(/*todo*/):%i (%s[%li]), graph %i\n", __LINE__, OPNAME (call), OPNUM (call), i ++)); pto_call (callEd_info->callEd, call, pto_env); @@ -444,7 +444,7 @@ static void pto_node_node(ir_node *node, pto_env_t *pto_env) { opcode op = get_irn_opcode (node); - DBGPRINT (1, (stdout, "pto_node_node() (%s[%li])\n", + DBGPRINT (1, (stdout, "pto_node_node(/*todo*/) (%s[%li])\n", OPNAME (node), OPNUM (node))); switch (op) { @@ -491,7 +491,8 @@ static void pto_node_node(ir_node *node, pto_env_t *pto_env) default: /* stopgap measure */ - fprintf (stderr, "pto_node_node(): not handled: node[%li].op = %s\n", + fprintf (stderr, "%s: not handled: node[%li].op = %s\n", + __FUNCTION__, get_irn_node_nr (node), get_op_name (get_irn_op (node))); assert (0 && "something not handled"); @@ -510,7 +511,8 @@ static void pto_node_post (ir_node *node, void *env) { pto_env_t *pto_env = (pto_env_t*) env; - DBGPRINT (999, (stdout, "pto_node_post() (%s[%li])\n", + DBGPRINT (999, (stdout, "%s (%s[%li])\n", + __FUNCTION__, OPNAME (node), OPNUM (node))); pto_node_node (node, pto_env); @@ -533,7 +535,8 @@ static void pto_call (ir_graph *graph, ir_node *call, pto_env_t *pto_env) const char *own_name = (char*) get_type_name (get_entity_owner (ent)); /* perform call */ - DBGPRINT (2, (stdout, "pto_call() (%s[%li]) to \"%s.%s\"\n", + DBGPRINT (2, (stdout, "%s (%s[%li]) to \"%s.%s\"\n", + __FUNCTION__, OPNAME (call), OPNUM (call), own_name, ent_name)); @@ -573,7 +576,8 @@ static void pto_call (ir_graph *graph, ir_node *call, pto_env_t *pto_env) int rec_change; /* handle recursion */ - DBGPRINT (0, (stdout, "pto_call(): recursion into \"%s.%s\"\n", + DBGPRINT (0, (stdout, "%s: recursion into \"%s.%s\"\n", + __FUNCTION__, own_name, ent_name)); /* Find 'right' enclosing pto_env */ enc_env = pto_env; @@ -587,17 +591,17 @@ static void pto_call (ir_graph *graph, ir_node *call, pto_env_t *pto_env) /* Re-Set arguments */ rec_change = add_graph_args (graph, call, pto_env); - DBGPRINT (1, (stdout, "pto_call(): return in:")); + DBGPRINT (1, (stdout, "%s: return in:", __FUNCTION__)); DBGEXE (1, pto_print_pto (get_irg_end_block (graph))); if (rec_change) { - DBGPRINT (0, (stdout, "pto_call(): change args")); + DBGPRINT (0, (stdout, "%s: change args", __FUNCTION__)); } rec_change |= set_graph_result (graph, call); if (rec_change) { - DBGPRINT (0, (stdout, "pto_call(): return out:")); + DBGPRINT (0, (stdout, "%s: return out:", __FUNCTION__)); DBGEXE (0, pto_print_pto (get_irg_end_block (graph))); } @@ -616,8 +620,9 @@ static void pto_call (ir_graph *graph, ir_node *call, pto_env_t *pto_env) static void pto_raise (ir_node *raise, pto_env_t *pto_env) { /* perform raise */ - DBGPRINT (2, (stdout, "pto_raise() (%s[%li]): pto = 0x%08x\n", - OPNAME (raise), OPNUM (raise), (void*) get_node_pto (raise))); + DBGPRINT (2, (stdout, "%s (%s[%li]): pto = 0x%08x\n", + __FUNCTION__, + OPNAME (raise), OPNUM (raise), (int) get_node_pto (raise))); } static void pto_end_block (ir_node *end_block, pto_env_t *pto_env) @@ -637,9 +642,10 @@ static void pto_end_block (ir_node *end_block, pto_env_t *pto_env) return; } - DBGPRINT (2, (stdout, "pto_end_block() (%s[%li]): pto = 0x%08x\n", + DBGPRINT (2, (stdout, "%s (%s[%li]): pto = 0x%08x\n", + __FUNCTION__, OPNAME (end_block), OPNUM (end_block), - (void*) get_node_pto (end_block))); + (int) get_node_pto (end_block))); end_pto = get_node_pto (end_block); @@ -664,31 +670,36 @@ static void pto_end_block (ir_node *end_block, pto_env_t *pto_env) void pto_graph (ir_graph *graph, int ctx_idx, pto_env_t *enc_env) { int run; + pto_env_t *pto_env; /* Also exported, since we need it in 'pto.c' */ - pto_env_t pto_env; - pto_env.enc_env = enc_env; - pto_env.graph = graph; - pto_env.ctx_idx = ctx_idx; - pto_env.change = TRUE; + pto_env = (pto_env_t*) xmalloc (sizeof (pto_env_t*)); + pto_env->enc_env = enc_env; + pto_env->graph = graph; + pto_env->ctx_idx = ctx_idx; + pto_env->change = TRUE; /* HERE ("start"); */ - DBGPRINT (2, (stdout, "pto_graph(): start for ctx %i\n", + DBGPRINT (2, (stdout, "%s: start for ctx %i\n", + __FUNCTION__, ctx_idx)); /* todo (here): iterate, obey 'changed' attribute */ run = 0; - while (0 != pto_env.change) { + while (0 != pto_env->change) { run ++; - pto_env.change = FALSE; - pto_graph_pass (graph, &pto_env); + pto_env->change = FALSE; + pto_graph_pass (graph, pto_env); } - DBGPRINT (1, (stdout, "pto_graph(): %i runs on \"%s.%s\"\n", + DBGPRINT (1, (stdout, "%s: %i runs on \"%s.%s\"\n", + __FUNCTION__, run, get_type_name (get_entity_owner (get_irg_entity (graph))), get_entity_name (get_irg_entity (graph)))); + memset (pto_env, 0, sizeof(*pto_env)); + free (pto_env); /* HERE ("end"); */ } @@ -733,6 +744,9 @@ pto_t *get_alloc_pto (ir_node *alloc) /* $Log$ + Revision 1.13 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.12 2004/12/23 15:46:19 beck removed unneeded allocations diff --git a/ir/ana2/pto_init.c b/ir/ana2/pto_init.c index 0d416206b..6a5514ce1 100644 --- a/ir/ana2/pto_init.c +++ b/ir/ana2/pto_init.c @@ -72,7 +72,7 @@ static pto_t *new_pto (ir_node *node) static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs) { int i; - alloc_pto_t *alloc_pto = obstack_alloc (pto_obst, sizeof(*alloc_pto)); + alloc_pto_t *alloc_pto = obstack_alloc (pto_obst, sizeof (alloc_pto_t)); type *tp; assert (op_Alloc == get_irn_op(alloc)); @@ -116,7 +116,8 @@ static pto_t* new_symconst_pto (ir_node *symconst) } else if (is_Class_type (get_entity_type (ent))) { desc = new_name (get_entity_type (ent), symconst, -1); } else { - fprintf (stderr, "new_symconst_pto(): not handled: %s[%li] (\"%s\")\n", + fprintf (stderr, "%s: not handled: %s[%li] (\"%s\")\n", + __FUNCTION__, get_op_name (get_irn_op (symconst)), get_irn_node_nr (symconst), get_entity_name (ent)); @@ -137,7 +138,8 @@ static void clear_type_link (type_or_ent *thing, void *_unused) type *tp = (type*) thing; if (is_Class_type (tp)) { - DBGPRINT (1, (stdout, "clear_type_link() (\"%s\")\n", + DBGPRINT (1, (stdout, "%s (\"%s\")\n", + __FUNCTION__, get_type_name (tp))); set_type_link (tp, NULL); @@ -145,7 +147,8 @@ static void clear_type_link (type_or_ent *thing, void *_unused) } else if (is_entity (thing)) { entity *ent = (entity*) thing; - DBGPRINT (1, (stdout, "clear_type_link() (\"%s\")\n", + DBGPRINT (1, (stdout, "%s (\"%s\")\n", + __FUNCTION__, get_entity_name (ent))); set_entity_link (ent, NULL); @@ -188,7 +191,8 @@ static void reset_node_pto (ir_node *node, void *env) alloc_pto_t *alloc_pto = (alloc_pto_t*) get_irn_link (node); alloc_pto->curr_pto = alloc_pto->ptos [ctx_idx]; - DBGPRINT (1, (stdout, "reset_node_pto(): setting pto of \"%s[%li]\" for ctx %i\n", + DBGPRINT (1, (stdout, "%s: setting pto of \"%s[%li]\" for ctx %i\n", + __FUNCTION__, OPNAME (node), OPNUM (node), ctx_idx)); @@ -201,7 +205,8 @@ static void reset_node_pto (ir_node *node, void *env) default: { /* basically, nothing */ - DBGPRINT (2, (stdout, "reset_node_pto(): resetting pto of \"%s[%li]\"\n", + DBGPRINT (2, (stdout, "%s: resetting pto of \"%s[%li]\"\n", + __FUNCTION__, OPNAME (node), OPNUM (node))); set_node_pto (node, NULL); @@ -229,7 +234,8 @@ static void init_pto (ir_node *node, void *env) set_node_pto (node, symconst_pto); /* debugging only */ - DBGPRINT (1, (stdout, "init_pto(): new name \"%s\" for \"%s[%li]\"\n", + DBGPRINT (1, (stdout, "%s: new name \"%s\" for \"%s[%li]\"\n", + __FUNCTION__, get_entity_name (ent), OPNAME (node), OPNUM (node))); @@ -244,7 +250,8 @@ static void init_pto (ir_node *node, void *env) set_alloc_pto (node, alloc_pto); tp = get_Alloc_type (node); /* debugging only */ - DBGPRINT (1, (stdout, "init_pto(): %i names \"%s\" for \"%s[%li]\"\n", + DBGPRINT (1, (stdout, "%s: %i names \"%s\" for \"%s[%li]\"\n", + __FUNCTION__, n_ctxs, get_type_name (tp), OPNAME (node), @@ -267,15 +274,18 @@ static void init_pto (ir_node *node, void *env) static void pto_init_graph_allocs (ir_graph *graph) { graph_info_t *ginfo = ecg_get_info (graph); - init_env_t init_env; + init_env_t *init_env; - init_env.n_ctxs = ginfo->n_ctxs; + init_env = xmalloc (sizeof (init_env_t)); + init_env->n_ctxs = ginfo->n_ctxs; /* HERE ("start"); */ - irg_walk_graph (graph, init_pto, NULL, &init_env); + irg_walk_graph (graph, init_pto, NULL, init_env); /* HERE ("end"); */ + memset (init_env, 0x00, sizeof (init_env_t)); + free (init_env); } /* =================================================== @@ -309,8 +319,9 @@ void fake_main_args (ir_graph *graph) set_node_pto (args [1], arg_pto); - DBGPRINT (1, (stdout, "fake_main_args():%i (%s[%li])\n", - __LINE__, OPNAME (args [1]), OPNUM (args [1]))); + DBGPRINT (1, (stdout, "%s:%i (%s[%li])\n", + __FUNCTION__, __LINE__, + OPNAME (args [1]), OPNUM (args [1]))); # ifdef TEST_MAIN_TYPE ctp = get_array_element_type (ctp); /* ctp == char[]* */ @@ -330,18 +341,18 @@ void fake_main_args (ir_graph *graph) } /* Initialise the Init module */ -void pto_init_init (void) +void pto_init_init () { - pto_obst = xmalloc(sizeof(*pto_obst)); + pto_obst = (struct obstack*) xmalloc (sizeof (struct obstack)); obstack_init (pto_obst); } /* Cleanup the Init module */ -void pto_init_cleanup (void) +void pto_init_cleanup () { obstack_free (pto_obst, NULL); - memset (pto_obst, 0, sizeof (*pto_obst)); + memset (pto_obst, 0x00, sizeof (struct obstack)); free (pto_obst); pto_obst = NULL; } @@ -367,7 +378,8 @@ void pto_init_graph (ir_graph *graph) const char *ent_name = (char*) get_entity_name (ent); const char *own_name = (char*) get_type_name (get_entity_owner (ent)); - DBGPRINT (2, (stdout, "pto_init_graph(): init \"%s.%s\" for %i ctxs\n", + DBGPRINT (2, (stdout, "%s: init \"%s.%s\" for %i ctxs\n", + __FUNCTION__, own_name, ent_name, n_ctxs)); /* HERE ("start"); */ @@ -386,19 +398,26 @@ void pto_init_graph (ir_graph *graph) /* Reset the given graph for a new pass run */ void pto_reset_graph_pto (ir_graph *graph, int ctx_idx) { - reset_env_t reset_env; - reset_env.ctx_idx = ctx_idx; + reset_env_t *reset_env; + + reset_env = (reset_env_t*) xmalloc (sizeof (reset_env_t)); + reset_env->ctx_idx = ctx_idx; /* HERE ("start"); */ irg_walk_graph (graph, reset_node_pto, NULL, &reset_env); /* HERE ("end"); */ + memset (reset_env, 0x00, sizeof (reset_env_t)); + free (reset_env); } /* $Log$ + Revision 1.15 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.14 2005/01/05 14:25:54 beck renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG fronten diff --git a/ir/ana2/pto_util.c b/ir/ana2/pto_util.c index 8642d45a8..3b900f082 100644 --- a/ir/ana2/pto_util.c +++ b/ir/ana2/pto_util.c @@ -76,21 +76,26 @@ ir_node **find_irg_args (ir_graph *graph) { type *tp = get_entity_type (get_irg_entity (graph)); const int n_args = get_method_n_params (tp); - ir_node **args = xcalloc (n_args + 1, sizeof(args[0])); + ir_node **args = xcalloc (n_args + 1, sizeof (ir_node*)); ir_node *arg = get_irg_args (graph); - find_irg_args_env_t arg_env; + find_irg_args_env_t *arg_env; - arg_env.args = args; - arg_env.arg = arg; + arg_env = (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t)); + + arg_env->args = args; + arg_env->arg = arg; { ir_graph *save = get_current_ir_graph (); set_current_ir_graph (graph); - irg_walk (get_irg_end (graph), find_irg_arg, NULL, &arg_env); + irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env); set_current_ir_graph (save); } + memset (arg_env, 0x00, sizeof (find_irg_args_env_t)); + free (arg_env); + args [n_args] = NULL; return (args); @@ -147,6 +152,9 @@ int is_dummy_load_ptr (ir_node *ptr) /* $Log$ + Revision 1.15 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.14 2004/12/23 15:47:09 beck removed uneeded allocations used new xcalloc diff --git a/ir/ana2/typalise.c b/ir/ana2/typalise.c index 00109be23..2dc9f7391 100644 --- a/ir/ana2/typalise.c +++ b/ir/ana2/typalise.c @@ -52,7 +52,7 @@ static typalise_t *typalise_proj (ir_node*); */ static typalise_t *ta_exact (type *tp) { - typalise_t *ta = xmalloc (sizeof(*ta)); + typalise_t *ta = xmalloc (sizeof (typalise_t)); ta->kind = type_exact; ta->res.type = tp; ta->id = ta_id ++; @@ -64,7 +64,7 @@ static typalise_t *ta_exact (type *tp) static typalise_t *ta_types (lset_t *set) { - typalise_t *ta = xmalloc (sizeof(*ta)); + typalise_t *ta = xmalloc (sizeof (typalise_t)); ta->kind = type_types; ta->res.types = set; ta->id = ta_id ++; @@ -74,7 +74,7 @@ static typalise_t *ta_types (lset_t *set) static typalise_t *ta_type (type *tp) { - typalise_t *ta = xmalloc (sizeof(*ta)); + typalise_t *ta = xmalloc (sizeof (typalise_t)); ta->kind = type_type; ta->res.type = tp; ta->id = ta_id ++; @@ -706,6 +706,9 @@ typalise_t *typalise (ir_node *node) /* $Log$ + Revision 1.7 2005/01/10 17:26:34 liekweg + fixup printfs, don't put environments on the stack + Revision 1.6 2005/01/05 14:25:54 beck renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG fronten -- 2.20.1