call hook_new_entity after copying entity so the firm debugger can catch it
[libfirm] / ir / ana / irconsconfirm.c
index fd70021..9994472 100644 (file)
@@ -57,7 +57,7 @@ typedef struct env_t {
 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
 
 /**
- * Return the effective use block of a node and it's predecessor on
+ * Return the effective use block of a node and its predecessor on
  * position pos.
  *
  * @param node  the node
@@ -308,18 +308,18 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
                                 * left == Const and we found a movable user of left in a
                                 * dominator of the Cond block
                                 */
-                               const ir_edge_t *edge, *next;
-                               for (edge = get_irn_out_edge_first(user); edge; edge = next) {
-                                       ir_node *usr_of_usr = get_edge_src_irn(edge);
-                                       int      npos = get_edge_src_pos(edge);
-                                       ir_node *blk  = get_effective_use_block(usr_of_usr, npos);
-
-                                       next = get_irn_out_edge_next(user, edge);
-                                       if (block_dominates(block, blk)) {
+                               const ir_edge_t *user_edge;
+                               const ir_edge_t *user_next;
+                               foreach_out_edge_safe(user, user_edge, user_next) {
+                                       ir_node *usr_of_usr = get_edge_src_irn(user_edge);
+                                       int      npos       = get_edge_src_pos(user_edge);
+                                       ir_node *user_blk   = get_effective_use_block(usr_of_usr, npos);
+
+                                       if (block_dominates(block, user_blk)) {
                                                /*
                                                 * The user of the user is dominated by our true/false
                                                 * block. So, create a copy of user WITH the constant
-                                                * replacing it's pos'th input.
+                                                * replacing its pos'th input.
                                                 *
                                                 * This is always good for unop's and might be good
                                                 * for binops.
@@ -428,29 +428,23 @@ static void insert_Confirm_in_block(ir_node *block, void *data)
        mode = get_irn_mode(selector);
 
        if (mode == mode_b) {
-               ir_node *cmp;
                ir_relation rel;
 
                handle_modeb(block, selector, (pn_Cond) get_Proj_proj(proj), env);
 
-               /* this should be an IF, check this */
-               if (! is_Proj(selector))
+               if (! is_Cmp(selector))
                        return;
 
-               cmp = get_Proj_pred(selector);
-               if (! is_Cmp(cmp))
-                       return;
-
-               rel = get_Cmp_relation(cmp);
+               rel = get_Cmp_relation(selector);
 
                if (get_Proj_proj(proj) != pn_Cond_true) {
                        /* it's the false branch */
-                       mode = get_irn_mode(get_Cmp_left(cmp));
+                       mode = get_irn_mode(get_Cmp_left(selector));
                        rel = get_negated_relation(rel);
                }
-               DB((dbg, LEVEL_2, "At %+F using %+F Confirm %=\n", block, cmp, rel));
+               DB((dbg, LEVEL_2, "At %+F using %+F Confirm %=\n", block, selector, rel));
 
-               handle_if(block, cmp, rel, env);
+               handle_if(block, selector, rel, env);
        } else if (mode_is_int(mode)) {
                long proj_nr = get_Proj_proj(proj);
 
@@ -598,14 +592,6 @@ void construct_confirms(ir_graph *irg)
                irg_block_walk_graph(irg, insert_Confirm_in_block, NULL, &env);
        }
 
-       if (env.num_confirms | env.num_consts | env.num_eq) {
-               /* we have add nodes or changed DF edges */
-               set_irg_outs_inconsistent(irg);
-
-               /* the new nodes are not in the loop info */
-               set_irg_loopinfo_inconsistent(irg);
-       }
-
        DB((dbg, LEVEL_1, "# Confirms inserted : %u\n", env.num_confirms));
        DB((dbg, LEVEL_1, "# Const replacements: %u\n", env.num_consts));
        DB((dbg, LEVEL_1, "# node equalities   : %u\n", env.num_eq));