Loads do not remove any nodes from the exec after sets. Also fix a 'node leak'.
[libfirm] / ir / ana / callgraph.c
index 04cfa77..d7e0715 100644 (file)
@@ -1,13 +1,28 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ana/callgraph.c
- * Purpose:     Representation and computation of the callgraph.
- * Author:      Goetz Lindenmaier
- * Modified by:
- * Created:     21.7.2004
- * CVS-ID:      $Id$
- * Copyright:   (c) 2004-2007 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 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.
+ */
+
+/**
+ * @file
+ * @brief       Representation and computation of the callgraph.
+ * @author      Goetz Lindenmaier
+ * @date        21.7.2004
+ * @version     $Id$
  */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -352,7 +367,8 @@ static void do_walk(ir_graph *irg, callgraph_walk_func *pre, callgraph_walk_func
        if (cg_irg_visited(irg)) return;
        mark_cg_irg_visited(irg);
 
-       pre(irg, env);
+       if (pre)
+               pre(irg, env);
 
        n_callees = get_irg_n_callees(irg);
        for (i = 0; i < n_callees; i++) {
@@ -360,7 +376,8 @@ static void do_walk(ir_graph *irg, callgraph_walk_func *pre, callgraph_walk_func
                do_walk(m, pre, post, env);
        }
 
-       post(irg, env);
+       if (post)
+               post(irg, env);
 }
 
 void callgraph_walk(callgraph_walk_func *pre, callgraph_walk_func *post, void *env) {
@@ -421,6 +438,7 @@ static INLINE scc_info *new_scc_info(void) {
 static INLINE int
 cg_irg_visited(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
+       assert(info && "missing call to init_scc");
        return (info->visited >= master_cg_visited);
 }
 
@@ -430,6 +448,7 @@ cg_irg_visited(ir_graph *irg) {
 static INLINE void
 mark_cg_irg_visited(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
+       assert(info && "missing call to init_scc");
        info->visited = master_cg_visited;
 }
 
@@ -439,6 +458,7 @@ mark_cg_irg_visited(ir_graph *irg) {
 static INLINE void
 set_cg_irg_visited(ir_graph *irg, int i) {
        scc_info *info = get_irg_link(irg);
+       assert(info && "missing call to init_scc");
        info->visited = i;
 }
 
@@ -448,55 +468,56 @@ set_cg_irg_visited(ir_graph *irg, int i) {
 static INLINE int
 get_cg_irg_visited(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
+       assert(info && "missing call to init_scc");
        return info->visited;
 }
 
 static INLINE void
 mark_irg_in_stack(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        info->in_stack = 1;
 }
 
 static INLINE void
 mark_irg_not_in_stack(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        info->in_stack = 0;
 }
 
 static INLINE int
 irg_is_in_stack(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        return info->in_stack;
 }
 
 static INLINE void
 set_irg_uplink(ir_graph *irg, int uplink) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        info->uplink = uplink;
 }
 
 static INLINE int
 get_irg_uplink(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        return info->uplink;
 }
 
 static INLINE void
 set_irg_dfn(ir_graph *irg, int dfn) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        info->dfn = dfn;
 }
 
 static INLINE int
 get_irg_dfn(ir_graph *irg) {
        scc_info *info = get_irg_link(irg);
-       assert(info);
+       assert(info && "missing call to init_scc");
        return info->dfn;
 }