Commit 971bb3d4 authored by Michael Beck's avatar Michael Beck
Browse files

Amendment of r28263 which was committed too early.

Another interface change: gc_irgs() now gets an size_t parameter.
Additionally fixed a memory leak.

[r28264]
parent 5940087c
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
* Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
......@@ -42,7 +42,7 @@
* ueberschrieben.
*
* Frees all interprocedural loop information. */
FIRM_API void gc_irgs(int n_keep, ir_entity *keep_arr[]);
FIRM_API void gc_irgs(size_t n_keep, ir_entity *keep_arr[]);
/**
* Creates an ir_prog pass for gc_irgs().
......
......@@ -1292,12 +1292,12 @@ int get_irg_recursion_depth(const ir_graph *irg)
/* Computes the interprocedural loop nesting information. */
void analyse_loop_nesting_depth(void)
{
ir_entity **free_methods = NULL;
int arr_len;
/* establish preconditions. */
if (get_irp_callee_info_state() != irg_callee_info_consistent) {
cgana(&arr_len, &free_methods);
ir_entity **free_methods = NULL;
cgana(&free_methods);
xfree(free_methods);
}
if (irp_callgraph_consistent != get_irp_callgraph_state()) {
......
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
* Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
......@@ -61,7 +61,7 @@ static void collect_call(ir_node *node, void *env)
}
/* garbage collect methods: mark and remove */
void gc_irgs(int n_keep, ir_entity ** keep_arr)
void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
{
void * MARK = &MARK; /* @@@ gefaehrlich!!! Aber wir markieren hoechstens zu viele ... */
int i;
......@@ -78,10 +78,12 @@ void gc_irgs(int n_keep, ir_entity ** keep_arr)
/* Mark entities that are alive. */
if (n_keep > 0) {
ir_entity **marked = NEW_ARR_F(ir_entity *, n_keep);
for (i = 0; i < n_keep; ++i) {
marked[i] = keep_arr[i];
set_entity_link(marked[i], MARK);
DB((dbg, LEVEL_1, " method %+F kept alive.\n", marked[i]));
size_t idx;
for (idx = 0; idx < n_keep; ++idx) {
marked[i] = keep_arr[idx];
set_entity_link(marked[idx], MARK);
DB((dbg, LEVEL_1, " method %+F kept alive.\n", marked[idx]));
}
for (i = 0; i < ARR_LEN(marked); ++i) {
......@@ -141,17 +143,17 @@ void gc_irgs(int n_keep, ir_entity ** keep_arr)
static void pass_wrapper(void)
{
ir_entity **keep_methods;
int arr_len;
size_t arr_len;
/* Analysis that finds the free methods,
i.e. methods that are dereferenced.
Optimizes polymorphic calls :-). */
cgana(&arr_len, &keep_methods);
arr_len = cgana(&keep_methods);
/* Remove methods that are never called. */
gc_irgs(arr_len, keep_methods);
free(keep_methods);
xfree(keep_methods);
}
ir_prog_pass_t *gc_irgs_pass(const char *name)
......
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
* Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
......@@ -1493,10 +1493,9 @@ static void callgraph_walker(ir_graph *irg, void *data)
static ir_graph **create_irg_list(void)
{
ir_entity **free_methods;
int arr_len;
int n_irgs = get_irp_n_irgs();
cgana(&arr_len, &free_methods);
cgana(&free_methods);
xfree(free_methods);
compute_callgraph();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment