+ ent = get_irn_entity_attr(node);
+ if (ent)
+ do_type_walk((type_or_ent *)ent, pre, post, env);
+ tp = get_irn_type_attr(node);
+ if (tp)
+ do_type_walk((type_or_ent *)tp, pre, post, env);
+}
+
+/** Check whether node contains types or entities as an attribute.
+ If so start a walk over that information. */
+static void start_type_walk(ir_node *node, void *ctx) {
+ type_walk_env *env = ctx;
+ type_walk_func *pre;
+ type_walk_func *post;
+ void *envi;
+
+ pre = env->pre;
+ post = env->post;
+ envi = env->env;
+
+ irn_type_walker(node, pre, post, envi);
+}
+
+/* walker: walks over all types */
+void type_walk(type_walk_func *pre, type_walk_func *post, void *env) {
+ int i, n_types = get_irp_n_types();
+
+ inc_master_type_visited();
+ for (i = 0; i < n_types; ++i) {
+ do_type_walk((type_or_ent *)get_irp_type(i), pre, post, env);
+ }
+ do_type_walk((type_or_ent *)get_glob_type(), pre, post, env);
+}
+
+void type_walk_irg (ir_graph *irg,
+ void (*pre)(type_or_ent*, void*),
+ void (*post)(type_or_ent*, void*),
+ void *env)
+{
+ ir_graph *rem = current_ir_graph;
+ /* this is needed to pass the parameters to the walker that actually
+ walks the type information */
+ type_walk_env type_env;
+
+ type_env.pre = pre;
+ type_env.post = post;
+ type_env.env = env;
+
+ current_ir_graph = irg;
+
+ /* We walk over the irg to find all irnodes that contain an attribute
+ with type information. If we find one we call a type walker to
+ touch the reachable type information.
+ The same type can be referenced by several irnodes. To avoid
+ repeated visits of the same type node we must decrease the
+ type visited flag for each walk. This is done in start_type_walk().
+ Here we initially increase the flag. We only call do_type_walk that does
+ not increase the flag.
+ */
+ inc_master_type_visited();
+ irg_walk(get_irg_end(irg), start_type_walk, NULL, &type_env);
+
+ do_type_walk((type_or_ent *)get_irg_entity(irg), pre, post, env);
+
+ do_type_walk((type_or_ent *)get_irg_frame_type(irg), pre, post, env);
+
+ current_ir_graph = rem;
+ return;
+}
+
+static void type_walk_s2s_2(type_or_ent *tore,
+ void (*pre)(type_or_ent*, void*),
+ void (*post)(type_or_ent*, void*),
+ void *env)
+{
+ int i, n;
+
+ /* marked? */
+ switch (get_kind(tore)) {
+ case k_entity:
+ if (entity_visited((entity *)tore)) return;