From 2153915d0ab419d1e0b67f9e0e302368820d76f6 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Mon, 8 Jun 2009 07:46:02 +0000 Subject: common.opt (fcompare-debug=, [...]): New. gcc/ChangeLog: * common.opt (fcompare-debug=, fcompare-debug-second): New. (fdump-final-insns=, gtoggle): New. * doc/invoke.texi: Document them. * final.c (rest_of_clean_state): Dump final insn stream. * gcc.c (invoke_as): Hook in -fcompare-debug. (static_spec_functions): Add compare-debug-dump-opt, compare-debug-self-opt and compare-debug-auxbase-opt. (compare_debug, compare_debug_second, compare_debug_opt): New. (switches_debug_check, n_switches_debug_check): New. (debug_auxbase_opt, debug_check_temp_file): New. (process_command): Handle -fno-compare-debug, -fcompare-debug and -fcompare-debug=*. (do_self_spec): Handle arguments after switches. (do_spec_1): Add .gk extension to temp file basenames for compare. (check_live_switch): Take SWITCH_IGNORE into account, and earlier. (cc1_options): Use it instead of normal auxbase computation for the second compare-debug compilation. (compare_files): New. (main): Set up and implement compare debug mode. (compare_debug_dump_opt_spec_function): New. (compare_debug_self_opt_spec_function): New. (compare_debug_auxbase_opt_spec_function): New. * toplev.c (process_options): Handle flag_gtoggle, flag_dump_final_insns. * coverage.c (coverage_begin_output): Don't overwrite .gcno file during -fcompare-debug-second compilation. gcc/cp/ChangeLog: * repo.c (get_base_filename): Use aux_base_name rather than alternate temporary file during second compare debug compilation. (finish_repo): Skip during -fcompare-debug-second. gcc/ada/ChangeLog: * lib-writ.adb (flag_compare_debug): Import. (Write_ALI): Skip during -fcompare-debug-second. gcc/fortran/ChangeLog: * options.c (gfc_post_options): Disable dump_parse_tree during -fcompare-debug-second. gcc/objc/ChangeLog: * objc-act.c (objc_init): Skip print_struct_values during -fcompare-debug-second. From-SVN: r148271 --- gcc/final.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'gcc/final.c') diff --git a/gcc/final.c b/gcc/final.c index 1fae1b4e238..b113bc90a39 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4313,6 +4313,41 @@ static unsigned int rest_of_clean_state (void) { rtx insn, next; + FILE *final_output = NULL; + int save_unnumbered = flag_dump_unnumbered; + int save_noaddr = flag_dump_noaddr; + + if (flag_dump_final_insns) + { + final_output = fopen (flag_dump_final_insns, "a"); + if (!final_output) + { + error ("could not open final insn dump file %qs: %s", + flag_dump_final_insns, strerror (errno)); + flag_dump_final_insns = NULL; + } + else + { + const char *aname; + + aname = (IDENTIFIER_POINTER + (DECL_ASSEMBLER_NAME (current_function_decl))); + fprintf (final_output, "\n;; Function (%s) %s\n\n", aname, + cfun->function_frequency == FUNCTION_FREQUENCY_HOT + ? " (hot)" + : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED + ? " (unlikely executed)" + : ""); + + flag_dump_noaddr = flag_dump_unnumbered = 1; + + for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) + if (LABEL_P (insn)) + INSN_UID (insn) = CODE_LABEL_NUMBER (insn); + else + INSN_UID (insn) = 0; + } + } /* It is very important to decompose the RTL instruction chain here: debug information keeps pointing into CODE_LABEL insns inside the function @@ -4323,6 +4358,27 @@ rest_of_clean_state (void) next = NEXT_INSN (insn); NEXT_INSN (insn) = NULL; PREV_INSN (insn) = NULL; + + if (final_output + && (!NOTE_P (insn) || + (NOTE_KIND (insn) != NOTE_INSN_VAR_LOCATION + && NOTE_KIND (insn) != NOTE_INSN_BLOCK_BEG + && NOTE_KIND (insn) != NOTE_INSN_BLOCK_END))) + print_rtl_single (final_output, insn); + + } + + if (final_output) + { + flag_dump_noaddr = save_noaddr; + flag_dump_unnumbered = save_unnumbered; + + if (fclose (final_output)) + { + error ("could not close final insn dump file %qs: %s", + flag_dump_final_insns, strerror (errno)); + flag_dump_final_insns = NULL; + } } /* In case the function was not output, -- cgit v1.2.1