Message ID | ork4k3qrok.fsf@livre.localdomain |
---|---|
State | New |
Headers | show |
On Wed, Nov 24, 2010 at 5:19 AM, Alexandre Oliva <aoliva@redhat.com> wrote: > While investigating PR debug/46338, I was set down a wrong path because > the dump file I wanted to look at had been clobbered. > > I compiled a .C file with -fcompare-debug -save-temps > -fdump-tree-profile. > > That ran cc1plus four times: preprocessing then compiling with the > wanted options, then preprocessing and compiling with -gtoggle. All the > runs had the -fdump flag pass in the command line. > > (I realize we could generally save the second preprocessing in this > case, but it's probably too much trouble to cover such an unusual case, > and since we do process twice without -save-temps, such an optimization > might turn out to be troublesome) > > The confusing bit was that the .profile dump wanted to look at had no > useful info, only the totals printed at the end of compilation. So > there I go trying to figure out why the initial compilation didn't have > any profile info there, whereas the -gtoggle recompilation did. It > didn't make sense and, indeed, once I took -save-temps out to debug it, > it no longer happened. > > It turned out that it was the second preprocessing that clobbered the > dump file of the first compilation. It doesn't get -auxbase flags like > the compiler run does, so it doesn't create .gk dump files instead. But > then, it shouldn't be touching compilation dump files at all, since > we're not compiling anything. > > This is what the patch fixes: arrange for preprocessing-only compiles to > not call the pass finalizers that emit dump file summaries. > > Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? Ok if you also move statistics_fini () inside the conditional. Thanks, Richard. > > > -- > Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ > You must be the change you wish to see in the world. -- Gandhi > Be Free! -- http://FSFLA.org/ FSF Latin America board member > Free Software Evangelist Red Hat Brazil Compiler Engineer > >
for gcc/ChangeLog from Alexandre Oliva <aoliva@redhat.com> * toplev.c (finalize): Add no_backend parameter. Don't finish passes when preprocessing only. Adjust... (do_compile): ... caller. Index: gcc/toplev.c =================================================================== --- gcc/toplev.c.orig 2010-11-18 10:37:23.166704939 -0200 +++ gcc/toplev.c 2010-11-21 02:33:47.406217662 -0200 @@ -111,7 +111,7 @@ static void process_options (void); static void backend_init (void); static int lang_dependent_init (const char *); static void init_asm_output (const char *); -static void finalize (void); +static void finalize (bool); static void crash_signal (int) ATTRIBUTE_NORETURN; static void setup_core_dumping (void); @@ -2245,7 +2245,7 @@ dump_memory_report (bool final) /* Clean up: close opened files, etc. */ static void -finalize (void) +finalize (bool no_backend) { /* Close the dump files. */ if (flag_gen_aux_info) @@ -2273,9 +2273,12 @@ finalize (void) fclose (stack_usage_file); statistics_fini (); - finish_optimization_passes (); + if (!no_backend) + { + finish_optimization_passes (); - ira_finish_once (); + ira_finish_once (); + } if (mem_report) dump_memory_report (true); @@ -2312,7 +2315,7 @@ do_compile (void) if (lang_dependent_init (main_input_filename)) compile_file (); - finalize (); + finalize (no_backend); } /* Stop timing and print the times. */