* der nicht erreichbaren Methoden wird aus der Abschätzung der
* Aufrufrelation bestimmt.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include "ircgopt.h"
#include "irloop_t.h"
#include "irflag_t.h"
#include "ircons.h"
+#include "cgana.h"
#include "irtools.h"
+#include "irpass.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);
ir_node *node = get_irg_end(irg);
/* collect calls */
- set_using_irn_link(irg);
+ ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
irg_walk_graph(irg, firm_clear_link, collect_call, node);
/* iterate calls */
}
}
}
- clear_using_irn_link(irg);
+ ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
}
}
DEL_ARR_F(marked);
free_loop_information(irg);
}
if ((get_entity_visibility(ent) == visibility_local) && (get_entity_link(ent) != MARK)) {
- remove_irp_irg(irg);
- set_entity_peculiarity(ent, peculiarity_description);
DB((dbg, LEVEL_1, " freeing method %+F\n", ent));
+ remove_irp_irg(irg);
+ set_entity_peculiarity(ent, peculiarity_description);
}
set_entity_link(ent, NULL);
}
}
+
+/**
+ * Wrapper for running gc_irgs() as an ir_prog pass.
+ */
+static void pass_wrapper(void)
+{
+ ir_entity **keep_methods;
+ int arr_len;
+
+ /* Analysis that finds the free methods,
+ i.e. methods that are dereferenced.
+ Optimizes polymorphic calls :-). */
+ cgana(&arr_len, &keep_methods);
+
+ /* Remove methods that are never called. */
+ gc_irgs(arr_len, keep_methods);
+
+ free(keep_methods);
+}
+
+ir_prog_pass_t *gc_irgs_pass(const char *name)
+{
+ return def_prog_pass(name ? name : "cgana", pass_wrapper);
+}