From 6c0d7102d4c915d93dfa1608bffa885716b09a3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Fri, 25 Jul 2003 08:19:59 +0000 Subject: [PATCH] bugfix, comments... [r1566] --- ir/ir/ircgcons.c | 1 + ir/ir/irdump.c | 94 +++++++++++++++++++++++++----------------------- ir/ir/irgwalk.h | 16 ++++----- ir/ir/irnode.h | 4 +-- ir/tr/entity.c | 4 +-- ir/tr/entity.h | 2 +- ir/tr/trvrfy.c | 5 +++ ir/tr/type.c | 2 ++ 8 files changed, 70 insertions(+), 58 deletions(-) diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index bd442c5a5..688c966f3 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -125,6 +125,7 @@ static void collect_phicallproj(void) { ir_graph * irg = get_irp_irg(i); ir_node * start = get_irg_start(irg); ir_node * end = get_irg_end(irg); + current_ir_graph = irg; assert(irg && start); /* Die speziellen Parameter der Start-Operation extra verlinken, * auch wenn sie nicht im intraprozeduralen Graphen erreichbar diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index ffe8e36ea..b769b8b1c 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -76,27 +76,27 @@ #if DEBUG_libfirm && NODEID_AS_LABEL -#define PRINT_NODEID(X) fprintf(F, "\"n%ld\"", get_irn_node_nr(X)) +#define PRINT_NODEID(X) fprintf(F, "n%ld", get_irn_node_nr(X)) #define PRINT_TYPEID(X) fprintf(F, "\"t%ld\"", get_type_nr(X)) -#define PRINT_ENTID(X) fprintf(F, "\"e%ld\"", get_entity_nr(X)) +#define PRINT_ENTID(X) fprintf(F, "e%ld", get_entity_nr(X)) #define PRINT_IRGID(X) fprintf(F, "g%ld", get_irg_graph_nr(X)) #define PRINT_CONSTID(X,Y) fprintf(F, "\"n%ldn%ld\"", get_irn_node_nr(X),get_irn_node_nr(Y)) #else -#define PRINT_NODEID(X) fprintf(F, "\"n%p\"", (void*) X) +#define PRINT_NODEID(X) fprintf(F, "n%p", (void*) X) #define PRINT_TYPEID(X) fprintf(F, "\"t%p\"", (void *) X) -#define PRINT_ENTID(X) fprintf(F, "\"e%p\"", (void*) X) +#define PRINT_ENTID(X) fprintf(F, "e%p", (void*) X) #define PRINT_IRGID(X) fprintf(F, "g%p",(void*) X) #define PRINT_CONSTID(X,Y) fprintf(F, "\"%p%p\"", (void*) X, (void*) Y) #endif #define PRINT_TYPE_TYPE_EDGE(S,T,...){fprintf (F, "edge: { sourcename: "); PRINT_TYPEID(S); fprintf (F, " targetname: "); PRINT_TYPEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_TYPE_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_TYPEID(S); fprintf (F, " targetname: "); PRINT_ENTID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_ENT_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_ENTID(S); fprintf (F, " targetname: "); PRINT_ENTID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_ENT_TYPE_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_ENTID(S); fprintf (F, " targetname: "); PRINT_TYPEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_NODE_TYPE_EDGE(S,T,...){fprintf (F, "edge: { sourcename: "); PRINT_NODEID(S); fprintf (F, " targetname: "); PRINT_TYPEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_NODE_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_NODEID(S); fprintf (F, " targetname: "); PRINT_ENTID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } -#define PRINT_ENT_NODE_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_ENTID(S); fprintf (F, " targetname: "); PRINT_NODEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_TYPE_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: "); PRINT_TYPEID(S); fprintf (F, " targetname: \""); PRINT_ENTID(T); fprintf(F, "\""); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_ENT_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: \""); PRINT_ENTID(S); fprintf (F, "\" targetname: \""); PRINT_ENTID(T); fprintf(F, "\""); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_ENT_TYPE_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: \""); PRINT_ENTID(S); fprintf (F, "\" targetname: "); PRINT_TYPEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_NODE_TYPE_EDGE(S,T,...){fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(S); fprintf (F, "\" targetname: "); PRINT_TYPEID(T); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_NODE_ENT_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(S); fprintf (F, "\" targetname: \""); PRINT_ENTID(T); fprintf(F, "\""); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } +#define PRINT_ENT_NODE_EDGE(S,T,...) {fprintf (F, "edge: { sourcename: \""); PRINT_ENTID(S); fprintf (F, "\" targetname: \""); PRINT_NODEID(T); fprintf(F, "\""); fprintf (F, ##__VA_ARGS__); fprintf(F,"}\n"); } /* A suffix to manipulate the file name. */ @@ -257,6 +257,11 @@ dump_node_vcgattr (ir_node *n) } } +static INLINE void +dump_node_info (ir_node *n) { + fprintf (F, " info1: \"visited: %ld\n\"", get_irn_visited(n)); +} + static bool pred_in_wrong_graph(ir_node *n, int pos, pmap *irgmap) { ir_node *block = (is_Block(n)) ? n : get_nodes_Block(n); @@ -310,6 +315,7 @@ static void dump_const_node_local(ir_node *n, pmap *irgmap) { #endif fprintf (F, "\" "); dump_node_vcgattr(con); + dump_node_info(con); fprintf (F, "}\n"); } } @@ -320,7 +326,7 @@ dump_node (ir_node *n, pmap * map) { if (get_opt_dump_const_local() && is_constlike_node(n)) return; /* dump this node */ - fprintf (F, "node: {title: "); PRINT_NODEID(n); fprintf(F, " label: \""); + fprintf (F, "node: {title: \""); PRINT_NODEID(n); fprintf(F, "\" label: \""); dump_node_opcode(n); dump_node_mode (n); @@ -331,6 +337,7 @@ dump_node (ir_node *n, pmap * map) { #endif fprintf (F, "\" "); dump_node_vcgattr(n); + dump_node_info(n); fprintf (F, "}\n"); dump_const_node_local(n, map); } @@ -340,11 +347,11 @@ static void dump_ir_block_edge(ir_node *n) { if (get_opt_dump_const_local() && is_constlike_node(n)) return; if (is_no_Block(n)) { - fprintf (F, "edge: { sourcename: "); + fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(n); - fprintf (F, " targetname: "); + fprintf (F, "\" targetname: \""); PRINT_NODEID(get_nodes_Block(n)); - fprintf (F, " " BLOCK_EDGE_ATTR "}\n"); + fprintf (F, "\" " BLOCK_EDGE_ATTR "}\n"); } } @@ -451,16 +458,15 @@ dump_ir_data_edges(ir_node *n) { if (is_backedge(n, i)) fprintf (F, "backedge: {sourcename: "); else - fprintf (F, "edge: {sourcename: "); + fprintf (F, "edge: {sourcename: \""); PRINT_NODEID(n); - fprintf (F, " targetname: "); + fprintf (F, " \" targetname: "); if ((get_opt_dump_const_local()) && is_constlike_node(pred)) { PRINT_CONSTID(n,pred); } else - { - PRINT_NODEID(pred); + {fprintf(F, "\""); PRINT_NODEID(pred); fprintf(F, "\""); } fprintf (F, " label: \"%d\" ", i); print_edge_vcgattr(n, i); @@ -474,11 +480,11 @@ dump_out_edge (ir_node *n, void* env) { int i; for (i = 0; i < get_irn_n_outs(n); i++) { assert(get_irn_out(n, i)); - fprintf (F, "edge: {sourcename: "); + fprintf (F, "edge: {sourcename: \""); PRINT_NODEID(n); - fprintf (F, " targetname: "); + fprintf (F, "\" targetname: \""); PRINT_NODEID(get_irn_out(n, i)); - fprintf (F, " color: red linestyle: dashed"); + fprintf (F, "\" color: red linestyle: dashed"); fprintf (F, "}\n"); } } @@ -486,9 +492,9 @@ dump_out_edge (ir_node *n, void* env) { static INLINE void dump_loop_node_edge (ir_loop *loop, int i) { assert(loop); - fprintf (F, "edge: {sourcename: \"%p\" targetname: ", (void*) loop); + fprintf (F, "edge: {sourcename: \"%p\" targetname: \"", (void*) loop); PRINT_NODEID(get_loop_node(loop, i)); - fprintf (F, " color: green"); + fprintf (F, "\" color: green"); fprintf (F, "}\n"); } @@ -555,6 +561,7 @@ static void dump_node2type_edges (ir_node *n, void *env) } +/* @@@@ Does not work as someone kills the visited flag. */ static void dump_const_expression(ir_node *value) { ir_graph *rem = current_ir_graph; int rem_dump_const_local = dump_const_local; @@ -629,12 +636,13 @@ static void print_type_node(type *tp) { } void dump_entity_node(entity *ent) { - fprintf (F, "node: {title: "); - PRINT_ENTID(ent); + fprintf (F, "node: {title: \""); + PRINT_ENTID(ent); fprintf(F, "\""); fprintf (F, DEFAULT_TYPE_ATTRIBUTE); fprintf (F, "label: "); fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , id_to_str(get_entity_ident(ent))); - fprintf (F, "\n info1:\"\nallocation: "); + fprintf (F, "\n info1: \"\nid: "); PRINT_ENTID(ent); + fprintf (F, "\nallocation: "); switch (get_entity_allocation(ent)) { case dynamic_allocated: fprintf (F, "dynamic allocated"); break; case automatic_allocated: fprintf (F, "automatic allocated"); break; @@ -644,8 +652,8 @@ void dump_entity_node(entity *ent) { fprintf (F, "\nvisibility: "); switch (get_entity_visibility(ent)) { case local: fprintf (F, "local"); break; - case external_visible: fprintf (F, "external_visible"); break; - case external_allocated: fprintf (F, "external_allocate"); break; + case external_visible: fprintf (F, "external visible"); break; + case external_allocated: fprintf (F, "external allocated"); break; } fprintf (F, "\nvariability: "); switch (get_entity_variability(ent)) { @@ -708,11 +716,7 @@ dump_type_info (type_or_ent *tore, void *env) { value = get_atomic_ent_value(ent); if (value) { PRINT_ENT_NODE_EDGE(ent, value, ENT_VALUE_EDGE_ATTR, i); - /* - fprintf (F, "edge: { sourcename: \"%p\" targetname: ", GET_ENTID(ent)); - PRINT_NODEID(value); - fprintf(F, " " ENT_VALUE_EDGE_ATTR "\"}\n"); - */ + /* DDMN(value); $$$ */ dump_const_expression(value); } } @@ -1027,9 +1031,9 @@ dump_ir_block (ir_node *block, void *env) { if (get_irn_opcode(block) == iro_Block) { /* This is a block. So dump the vcg information to make a block. */ - fprintf(F, "graph: { title: "); + fprintf(F, "graph: { title: \""); PRINT_NODEID(block); - fprintf(F, " label: \""); + fprintf(F, "\" label: \""); #ifdef DEBUG_libfirm fprintf (F, "%ld", get_irn_node_nr(block)); #else @@ -1113,8 +1117,8 @@ dump_block_to_cfg (ir_node *block, void *env) { if (get_irn_opcode(block) == iro_Block) { /* This is a block. Dump a node for the block. */ - fprintf (F, "node: {title:"); PRINT_NODEID(block); - fprintf (F, " label: \"%s ", get_op_name(get_irn_op(block))); + fprintf (F, "node: {title: \""); PRINT_NODEID(block); + fprintf (F, "\" label: \"%s ", get_op_name(get_irn_op(block))); #ifdef DEBUG_libfirm fprintf (F, "%ld", get_irn_node_nr(block)); #else @@ -1132,21 +1136,21 @@ dump_block_to_cfg (ir_node *block, void *env) { for ( i = 0; i < get_Block_n_cfgpreds(block); i++) if (get_irn_op(skip_Proj(get_Block_cfgpred(block, i))) != op_Bad) { pred = get_nodes_Block(skip_Proj(get_Block_cfgpred(block, i))); - fprintf (F, "edge: { sourcename: "); + fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(block); - fprintf (F, " targetname: "); + fprintf (F, "\" targetname: \""); PRINT_NODEID(pred); - fprintf (F, " }\n"); + fprintf (F, "\"}\n"); } /* Dump dominator edge */ if (dump_dominator_information_flag && get_Block_idom(block)) { pred = get_Block_idom(block); - fprintf (F, "edge: { sourcename: "); + fprintf (F, "edge: { sourcename: \""); PRINT_NODEID(block); - fprintf (F, " targetname: "); + fprintf (F, "\" targetname: \""); PRINT_NODEID(pred); - fprintf (F, " " DOMINATOR_EDGE_ATTR "}\n"); + fprintf (F, "\" " DOMINATOR_EDGE_ATTR "}\n"); } } } @@ -1361,9 +1365,9 @@ static void dump_cg_ir_block(ir_node * block, void * env) { ir_node *node; pmap *irgmap = (pmap *)env; assert(is_Block(block)); - fprintf(F, "graph: { title: "); + fprintf(F, "graph: { title: \""); PRINT_NODEID(block); - fprintf(F, " label: \""); + fprintf(F, "\" label: \""); fprintf (F, "%s ", get_op_name(get_irn_op(block))); #ifdef DEBUG_libfirm fprintf (F, "%ld", get_irn_node_nr(block)); diff --git a/ir/ir/irgwalk.h b/ir/ir/irgwalk.h index bd55265bd..9b2c03ae3 100644 --- a/ir/ir/irgwalk.h +++ b/ir/ir/irgwalk.h @@ -28,7 +28,7 @@ #ifndef _IRG_WALK_FUNC_TYPEDEF_ #define _IRG_WALK_FUNC_TYPEDEF_ /** - * The type of a walk function. + * The type of a walk function. Does not use the link field. * * @param node - the node that is just visited * @param env - an environment pointer passed by the walk functions @@ -56,7 +56,7 @@ void finish_ip_walk(void); * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new * flag. It marks the node as visited before executing pre. * The void* env can be used to pass status information between the - * pre and post functions. + * pre and post functions. Does not use the link field. */ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env); @@ -70,7 +70,7 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) * * Like irg_walk(), but walks over all reachable nodes in the ir * graph, starting at the end operation. During the walk current_ir_graph - * is set to irg. + * is set to irg. Does not use the link field. */ void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env); @@ -84,7 +84,7 @@ void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog. * Sets current_ir_graph properly for each walk. Conserves current * current_ir_graph. In interprocedural view nodes can be visited several - * times. + * times. Does not use the link field. */ void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); @@ -96,7 +96,7 @@ void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); * @param env - environment, passend to pre and post * * This function walks all irgs in interprocedural view. - * Visits each node only once.Sets current_ir_graph properly. + * Visits each node only once. Sets current_ir_graph properly. Does not use the link field. */ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); @@ -111,7 +111,7 @@ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env); * This function Walks only over Block nodes in the graph. Has it's own visited * flag, so that it can be interleaved with the other walker. * If a none block is passed, starts at the block this node belongs to. - * If end is passed also visites kept alive blocks. + * If end is passed also visites kept alive blocks. Does not use the link field. */ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env); @@ -124,7 +124,7 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * @param env - environment, passend to pre and post * * Like irg_block_walk(), but walks over all reachable blocks in the - * ir graph, starting at the end block. + * ir graph, starting at the end block. Does not use the link field. */ void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env); @@ -136,7 +136,7 @@ void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post * @param env - environment, passend to pre and post * * This function walks over all code in const_code_irg. - * Uses visited flag in const_code_irg. + * Uses visited flag in const_code_irg. Does not use the link field. */ void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env); diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index 37a99a6fa..c2743465f 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -589,7 +589,7 @@ ir_node *get_fragile_op_mem(ir_node *node); /* !!!!!!!!! @@@ Don't format with "\", firmjni gets problems */ /** Output location */ -#define DDM(X) printf("%s(l.%i).\n", __MYFUNC__, __LINE__); +#define DDM printf("%s(l.%i).\n", __MYFUNC__, __LINE__); /** Output the firm kind of the node */ #define DDMK(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, print_firm_kind(X), (X)); /** Output information about a node */ @@ -599,7 +599,7 @@ ir_node *get_fragile_op_mem(ir_node *node); /** Output information about a type */ #define DDMT(X) printf("%s(l.%i) %s %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_type_tpop_name(X), get_type_name(X), get_type_nr(X), (X)) /** Output information about an entity */ -#define DDME(X) printf("%s(l.%i) %s: %ld (%p\n", __MYFUNC__, __LINE__, get_entity_name(X), get_entity_nr(X), (X)) +#define DDME(X) printf("%s(l.%i) %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_entity_nr(X), (X)) /** Output information about an entity and its owner */ #define DDMEO(X) printf("%s(l.%i) %s (own: %s): %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_type_name(get_entity_owner(X)), get_entity_nr(X), (X)) /** Output information about a graph */ diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 1dd8826f1..7aab18e6a 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -411,7 +411,7 @@ const char *get_peculiarity_name(peculiarity var) #undef X } -/* Set has no effect for entities of type method. */ +/* Set has no effect for existent entities of type method. */ INLINE ir_node * get_atomic_ent_value(entity *ent) { assert(ent); assert(is_atomic_entity(ent)); @@ -422,7 +422,7 @@ get_atomic_ent_value(entity *ent) { INLINE void set_atomic_ent_value(entity *ent, ir_node *val) { assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized)); - if (is_method_type(ent->type)) return; + if ((is_method_type(ent->type)) && (ent->peculiarity==existent)) return; ent->value = val; } diff --git a/ir/tr/entity.h b/ir/tr/entity.h index 8f5dfbb1a..bc123d4f2 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -322,7 +322,7 @@ const char *get_peculiarity_name(peculiarity var); constant expressions to current_block in current_ir_graph. */ ir_node *copy_const_value(ir_node *n); -/* Set has no effect for entities of type method. */ +/* Set has no effect for existent entities of type method. */ ir_node *get_atomic_ent_value(entity *ent); void set_atomic_ent_value(entity *ent, ir_node *val); diff --git a/ir/tr/trvrfy.c b/ir/tr/trvrfy.c index 99cccf4d7..6d9076f59 100644 --- a/ir/tr/trvrfy.c +++ b/ir/tr/trvrfy.c @@ -75,6 +75,10 @@ static void on_irg_storage(ir_node *n, void *env) { struct myenv * myenv = env; myenv->res = node_is_in_irgs_storage(myenv->irg, n); + + /* We also test whether the setting of the visited flag is legal. */ + assert(get_irn_visited(n) <= get_irg_visited(myenv->irg) && + "Visited flag of node is larger than that of corresponding irg."); } /** @@ -124,6 +128,7 @@ static int constants_on_wrong_irg(entity *ent) { * != 0 else */ static int check_entity(entity *ent) { + current_ir_graph = get_const_code_irg(); if (constants_on_wrong_irg(ent)) { assert(0 && "Contants placed on wrong IRG"); return error_const_on_wrong_irg; diff --git a/ir/tr/type.c b/ir/tr/type.c index 5ca5d7173..967397c6e 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -236,6 +236,8 @@ set_type_state(type *tp, type_state state) { assert(get_type_size(tp) > -1); if (tp != get_glob_type()) for (i = 0; i < get_class_n_members(tp); i++) { + if (get_entity_offset(get_class_member(tp, i)) <= -1) + { DDMT(tp); DDME(get_class_member(tp, i)); } assert(get_entity_offset(get_class_member(tp, i)) > -1); assert(is_method_type(get_entity_type(get_class_member(tp, i))) || (get_entity_allocation(get_class_member(tp, i)) == automatic_allocated)); -- 2.20.1