avoid dangerous use of memcmp
[libfirm] / ir / opt / ifconv.c
index b61edfe..2492e85 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -74,9 +74,8 @@ typedef struct block_info {
        int has_pinned; /**< set if the block contains instructions that cannot be moved */
 } block_info;
 
-
-static INLINE block_info* get_block_blockinfo(const ir_node* block)
-{
+/** Returns the additional block info of a block. */
+static INLINE block_info* get_block_blockinfo(const ir_node* block) {
        return get_irn_link(block);
 }
 
@@ -84,8 +83,7 @@ static INLINE block_info* get_block_blockinfo(const ir_node* block)
 /**
  * Returns non-zero if a Block can be emptied.
  */
-static int can_empty_block(ir_node *block)
-{
+static int can_empty_block(ir_node *block) {
        return !get_block_blockinfo(block)->has_pinned;
 }
 
@@ -274,7 +272,7 @@ restart:
        arity = get_irn_arity(block);
        for (i = 0; i < arity; ++i) {
                ir_node* pred0;
-               cdep* cdep;
+               ir_cdep* cdep;
 
                pred0 = get_nodes_block(get_irn_n(block, i));
                for (cdep = find_cdep(pred0); cdep != NULL; cdep = cdep->next) {
@@ -405,10 +403,9 @@ static void init_block_link(ir_node *block, void *env)
 
 /**
  * Daisy-chain all phis in a block
- * If a non-movable node is encountered set the has_pinned flag
+ * If a non-movable node is encountered set the has_pinned flag in its block.
  */
-static void collect_phis(ir_node *node, void *env)
-{
+static void collect_phis(ir_node *node, void *env) {
        (void) env;
 
        if (is_Phi(node)) {
@@ -559,11 +556,15 @@ void opt_if_conv(ir_graph *irg, const ir_settings_if_conv_t *params)
        compute_cdep(irg);
        assure_doms(irg);
 
+       set_using_irn_link(irg);
+
        obstack_init(&obst);
        irg_block_walk_graph(irg, init_block_link, NULL, &obst);
        irg_walk_graph(irg, collect_phis, NULL, NULL);
        irg_block_walk_graph(irg, NULL, if_conv_walker, &p);
 
+       clear_using_irn_link(irg);
+
        local_optimize_graph(irg);
 
        irg_walk_graph(irg, NULL, optimise_psis_0, NULL);
@@ -573,6 +574,9 @@ void opt_if_conv(ir_graph *irg, const ir_settings_if_conv_t *params)
 
        obstack_free(&obst, NULL);
 
+       /* TODO: graph might be changed, handle more gracefull */
+       set_irg_outs_inconsistent(irg);
        free_dom(irg);
+
        free_cdep(irg);
 }