* - execute the pre function before recursion
* - execute the post function after recursion
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
#include "irnode_t.h"
#include "irgraph_t.h"
#include "pset_new.h"
#include "array.h"
+#ifdef INTERPROCEDURAL_VIEW
/**
* Walk over an interprocedural graph (callgraph).
* Visits only graphs in irg_set.
*/
static void irg_walk_cg(ir_node * node, ir_visited_t visited,
pset_new_t *irg_set, irg_walk_func *pre,
- irg_walk_func *post, void * env) {
+ irg_walk_func *post, void * env)
+{
int i;
ir_graph * rem = current_ir_graph;
ir_node * pred;
current_ir_graph = rem;
}
-
+#endif
/**
* Insert all ir_graphs in irg_set, that are (transitive) reachable.
* Returns current_ir_graph and sets it to the irg of predecessor index
* of node n.
*/
-static INLINE ir_graph *
+static inline ir_graph *
switch_irg(ir_node *n, int index) {
ir_graph *old_current = current_ir_graph;
return old_current;
}
+#ifdef INTERPROCEDURAL_VIEW
static void
cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
{
}
}
-#ifdef INTERPROCEDURAL_VIEW
/* Walks all irgs in interprocedural view. Visits each node only once. */
void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) {
int i;
if (!Block_block_visited(node)) {
mark_Block_block_visited(node);
- if(pre) pre(node, env);
+ if (pre) pre(node, env);
for(i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
/* find the corresponding predecessor block. */
ir_node *pred = get_cf_op(get_Block_cfgpred(node, i));
pred = get_nodes_block(pred);
- if(get_irn_opcode(pred) == iro_Block) {
+ if (get_irn_opcode(pred) == iro_Block) {
/* recursion */
irg_block_walk_2(pred, pre, post, env);
}
}
}
- if(post) post(node, env);
+ if (post) post(node, env);
}
}
assert(node);
assert(!get_interprocedural_view()); /* interprocedural_view not implemented, because it
- * interleaves with irg_walk */
+ * interleaves with irg_walk */
ir_reserve_resources(irg, IR_RESOURCE_BLOCK_VISITED);
inc_irg_block_visited(irg);
block = is_Block(node) ? node : get_nodes_block(node);
int arity = get_irn_arity(node);
for (i = 0; i < arity; i++) {
pred = get_irn_n(node, i);
- if (is_Block(pred))
- irg_block_walk_2(pred, pre, post, env);
- }
- /* Sometimes the blocks died, but are still reachable through Phis.
- * Make sure the algorithms that try to remove these reach them. */
- for (i = 0; i < arity; i++) {
- pred = get_irn_n(node, i);
- if (get_irn_op(pred) == op_Phi) {
- ir_node *block = get_nodes_block(pred);
-
- if (! is_Bad(block))
- irg_block_walk_2(block, pre, post, env);
+ if (!is_Block(pred)) {
+ pred = get_nodes_block(pred);
+ if (!is_Block(pred)) {
+ /* if rare cases a kept node might have a bad block input */
+ continue;
+ }
}
+ /* Sometimes the blocks died, but are still reachable through kept nodes.
+ * Make sure the algorithms that try to remove these reach them. */
+ irg_block_walk_2(pred, pre, post, env);
}
}