becopyopt: Fix typos in comments.
[libfirm] / ir / opt / ircgopt.c
index c95e0a5..caef78c 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -22,7 +8,6 @@
  * @brief    Removal of unreachable methods.
  * @author   Hubert Schmid
  * @date     09.06.2002
- * @version  $Id$
  */
 
 /*
@@ -45,7 +30,7 @@
 #include "irtools.h"
 #include "irpass.h"
 
-DEBUG_ONLY(static firm_dbg_module_t *dbg);
+DEBUG_ONLY(static firm_dbg_module_t *dbg;)
 
 /**
  * Walker: adds Call operations to a head's link list.
@@ -64,7 +49,6 @@ static void collect_call(ir_node *node, void *env)
 void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
 {
        void * MARK = &MARK; /* @@@ gefaehrlich!!! Aber wir markieren hoechstens zu viele ... */
-       size_t i, n;
 
        FIRM_DBG_REGISTER(dbg, "firm.opt.cgopt");
 
@@ -102,10 +86,7 @@ void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
                        /* iterate calls */
                        for (node = (ir_node*)get_irn_link(node); node != NULL;
                             node = (ir_node*)get_irn_link(node)) {
-                               size_t i;
-                               assert(is_Call(node));
-
-                               for (i = get_Call_n_callees(node); i > 0;) {
+                               for (size_t i = get_Call_n_callees(node); i > 0;) {
                                        ir_entity *ent = get_Call_callee(node, --i);
 
                                        if (get_entity_irg(ent) && get_entity_link(ent) != MARK) {
@@ -123,7 +104,7 @@ void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
        }
 
        /* clean */
-       for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
+       for (size_t i = get_irp_n_irgs(); i-- != 0;) {
                ir_graph  *irg = get_irp_irg(i);
                ir_entity *ent = get_irg_entity(irg);
 
@@ -131,9 +112,7 @@ void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
                        continue;
 
                DB((dbg, LEVEL_1, "  freeing method %+F\n", ent));
-               remove_irp_irg(irg);
-
-               free_entity(ent);
+               free_ir_graph(irg);
        }
 }