we have code duplication in determine_entity_usage and is_address_taken (from scalar_...
[libfirm] / ir / ana / irscc.c
index 4494289..4ccbe9a 100644 (file)
@@ -209,18 +209,13 @@ static INLINE void init_stack(void) {
        tos = 0;
 }
 
-#if 0
 /**
  * Frees the stack.
  */
-static INLINE void free_stack(void) {
-       if (stack != NULL) {
-               DEL_ARR_F(stack);
-               stack = NULL;
-       }
-       tos = 0;
+static void finish_stack(void) {
+       DEL_ARR_F(stack);
+       stack = NULL;
 }
-#endif
 
 /**
  * push a node onto the stack
@@ -350,6 +345,11 @@ static INLINE void init_scc(ir_graph *irg, struct obstack *obst) {
        */
 }
 
+static INLINE void finish_scc(void)
+{
+       finish_stack();
+}
+
 #ifdef INTERPROCEDURAL_VIEW
 static INLINE void init_ip_scc(struct obstack *obst) {
        init_scc_common();
@@ -393,11 +393,12 @@ static INLINE int get_start_index(ir_node *n) {
           not reachable.
           I.e., with this code, the order on the loop tree is correct. But a (single)
           test showed the loop tree is deeper.   */
-       if (get_irn_op(n) == op_Phi   ||
-           get_irn_op(n) == op_Block ||
-           (get_irn_op(n) == op_Filter && get_interprocedural_view()) ||
-           (get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats &&
-           get_irn_pinned(n) == op_pin_state_floats))
+       if (get_irn_op(n) == op_Phi                      ||
+           is_Block(n)                                  ||
+           (is_Filter(n) && get_interprocedural_view()) || (
+             get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats &&
+             get_irn_pinned(n)              == op_pin_state_floats
+           ))
                // Here we could test for backedge at -1 which is illegal
                return 0;
        else
@@ -410,7 +411,7 @@ static INLINE int get_start_index(ir_node *n) {
           But it guarantees that Blocks are analysed before nodes contained in the
           block.  If so, we can set the value to undef if the block is not \
           executed. */
-       if (is_cfop(n) || is_fragile_op(n) || get_irn_op(n) == op_Start)
+       if (is_cfop(n) || is_fragile_op(n) || is_Start(n))
                return -1;
        else
                return 0;
@@ -833,7 +834,7 @@ static void my_scc(ir_node *n) {
                        ir_node *m;
                        if (is_backedge(n, i)) continue;
                        m = get_irn_n(n, i); /* get_irn_ip_pred(n, i); */
-                       /* if ((!m) || (get_irn_op(m) == op_Unknown)) continue; */
+                       /* if (!m || is_Unknown(m)) continue; */
                        my_scc(m);
                        if (irn_is_in_stack(m)) {
                                /* Uplink of m is smaller if n->m is a backedge.
@@ -931,6 +932,8 @@ int construct_backedges(ir_graph *irg) {
        inc_irg_visited(irg);
 
        scc(get_irg_end(irg));
+
+       finish_scc();
        obstack_free(&temp, NULL);
 
        assert(head_rem == current_loop);
@@ -1248,8 +1251,8 @@ int is_loop_variant(ir_loop *l, ir_loop *b) {
  *
  * Returns non-zero, if the node n is not changed in the loop block
  * belongs to or in inner loops of this blocks loop. */
-int is_loop_invariant(ir_node *n, ir_node *block) {
+int is_loop_invariant(const ir_node *n, const ir_node *block) {
        ir_loop *l = get_irn_loop(block);
-       ir_node *b = is_Block(n) ? n : get_nodes_block(n);
+       const ir_node *b = is_Block(n) ? n : get_nodes_block(n);
        return !is_loop_variant(l, get_irn_loop(b));
 }