From ac122d9decce63c3e2ff5c401d1078b6d73e17e7 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 4 Aug 2012 10:36:00 +0200 Subject: [PATCH] Return the profile init irg from ir_profile_instrument() instead of guessing that it is the last irg. --- ir/be/bemain.c | 3 +-- ir/ir/irprofile.c | 6 +++--- ir/ir/irprofile.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 2522cdfc5..272a79476 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -583,8 +583,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) } if (num_birgs > 0 && be_options.opt_profile_generate) { - ir_profile_instrument(prof_filename); - ir_graph *prof_init_irg = get_irp_irg(get_irp_n_irgs()-1); + ir_graph *const prof_init_irg = ir_profile_instrument(prof_filename); assert(prof_init_irg->be_data == NULL); initialize_birg(&birgs[num_birgs], prof_init_irg, &env); num_birgs++; diff --git a/ir/ir/irprofile.c b/ir/ir/irprofile.c index 20bd61e96..dd6eb5afc 100644 --- a/ir/ir/irprofile.c +++ b/ir/ir/irprofile.c @@ -472,7 +472,7 @@ static ir_entity *new_static_string_entity(ident *name, const char *string) return result; } -void ir_profile_instrument(const char *filename) +ir_graph *ir_profile_instrument(const char *filename) { int n, n_blocks = 0; ident *counter_id, *filename_id; @@ -483,7 +483,7 @@ void ir_profile_instrument(const char *filename) /* Don't do anything for modules without code. Else the linker will * complain. */ if (get_irp_n_irgs() == 0) - return; + return NULL; /* count the number of block first */ n_blocks = get_irp_n_blocks(); @@ -504,7 +504,7 @@ void ir_profile_instrument(const char *filename) instrument_irg(irg, bblock_counts, &wd); } - gen_initializer_irg(ent_filename, bblock_counts, n_blocks); + return gen_initializer_irg(ent_filename, bblock_counts, n_blocks); } static unsigned int *parse_profile(const char *filename, unsigned int num_blocks) diff --git a/ir/ir/irprofile.h b/ir/ir/irprofile.h index 507179cdb..85a0e2d59 100644 --- a/ir/ir/irprofile.h +++ b/ir/ir/irprofile.h @@ -37,7 +37,7 @@ * incremented in that block. After the program has run the info is written * to @p filename. */ -void ir_profile_instrument(const char *filename); +ir_graph *ir_profile_instrument(const char *filename); /** * Reads the corresponding profile info file if it exists and returns a -- 2.20.1