X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fcritical_edges.c;h=4717244ebba3bd4cc5713413fb6da6c8ebd5e842;hb=ce6161a7e42a48f7422b7babcc64d8ace18e2687;hp=7a98f9a376d4beab95e8a136296f01e49ea41fc3;hpb=4ea35562c2e46b5a4d5e4c1ddf9b5d7a361400dd;p=libfirm diff --git a/ir/opt/critical_edges.c b/ir/opt/critical_edges.c index 7a98f9a37..4717244eb 100644 --- a/ir/opt/critical_edges.c +++ b/ir/opt/critical_edges.c @@ -24,9 +24,7 @@ * 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 +46,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 */ @@ -74,6 +73,12 @@ static void walk_critical_cf_edges(ir_node *n, void *env) { continue; goto insert; } + if (is_IJmp(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,7 +86,7 @@ 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; @@ -90,7 +95,8 @@ insert: } /* 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; @@ -106,6 +112,7 @@ void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges) { } } -void remove_critical_cf_edges(ir_graph *irg) { +void remove_critical_cf_edges(ir_graph *irg) +{ remove_critical_cf_edges_ex(irg, 1); }