X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fcritical_edges.c;h=11b282d551abf6bc26ada9e4c64f0b4825912663;hb=183c08a8d00578cfc700cdd0d8387b920a5996da;hp=7a98f9a376d4beab95e8a136296f01e49ea41fc3;hpb=4ea35562c2e46b5a4d5e4c1ddf9b5d7a361400dd;p=libfirm diff --git a/ir/opt/critical_edges.c b/ir/opt/critical_edges.c index 7a98f9a37..11b282d55 100644 --- a/ir/opt/critical_edges.c +++ b/ir/opt/critical_edges.c @@ -22,11 +22,8 @@ * @brief Remove critical edges. * @author Christian Schaefer, Goetz Lindenmaier, Sebastian Felis, * Michael Beck - * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include "irop_t.h" #include "irnode_t.h" @@ -48,10 +45,11 @@ typedef struct cf_env { * @param n IR node * @param env Environment of walker. */ -static void walk_critical_cf_edges(ir_node *n, void *env) { +static void walk_critical_cf_edges(ir_node *n, void *env) +{ int arity, i; ir_node *pre, *block, *jmp; - cf_env *cenv = env; + cf_env *cenv = (cf_env*)env; ir_graph *irg = get_irn_irg(n); /* Block has multiple predecessors */ @@ -70,10 +68,16 @@ static void walk_critical_cf_edges(ir_node *n, void *env) { cfop = get_irn_op(skip_Proj(pre)); if (is_op_fragile(cfop)) { - if (cenv->ignore_exc_edges && get_Proj_proj(pre) == pn_Generic_X_except) + if (cenv->ignore_exc_edges && is_x_except_Proj(pre)) continue; goto insert; } + if (is_unknown_jump(pre)) { + /* we can't add blocks in between ijmp and its destinations + * TODO: What now, we can't split all critical edges because of this... */ + fprintf(stderr, "libfirm warning: Couldn't split all critical edges (compiler will probably fail now)\n"); + continue; + } /* we don't want place nodes in the start block, so handle it like forking */ if (is_op_forking(cfop) || cfop == op_Start) { /* Predecessor has multiple successors. Insert new control flow edge edges. */ @@ -81,16 +85,17 @@ insert: /* set predecessor of new block */ block = new_r_Block(irg, 1, &pre); /* insert new jmp node to new block */ - jmp = new_r_Jmp(irg, block); + jmp = new_r_Jmp(block); /* set successor of new block */ set_irn_n(n, i, jmp); cenv->changed = 1; - } /* predecessor has multiple successors */ - } /* for all predecessors */ - } /* n is a multi-entry block */ + } + } + } } -void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges) { +void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges) +{ cf_env env; env.ignore_exc_edges = (char)ignore_exception_edges; @@ -99,13 +104,13 @@ void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges) { irg_block_walk_graph(irg, NULL, walk_critical_cf_edges, &env); if (env.changed) { /* control flow changed */ - set_irg_outs_inconsistent(irg); - set_irg_extblk_inconsistent(irg); - set_irg_doms_inconsistent(irg); - set_irg_loopinfo_inconsistent(irg); + clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE + | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS); } + set_irg_state(irg, IR_GRAPH_STATE_NO_CRITICAL_EDGES); } -void remove_critical_cf_edges(ir_graph *irg) { +void remove_critical_cf_edges(ir_graph *irg) +{ remove_critical_cf_edges_ex(irg, 1); }