Commit ea67fe71 by Nathan Sidwell Committed by Nathan Sidwell

gcc.c (cc1_options): Pass output file as auxbase when appropriate.

	* gcc.c (cc1_options): Pass output file as auxbase when
	appropriate.
	* profile.c (init_branch_prob): FILENAME has already had ending
	stripped.
	* final.c (end_final): Likewise.
	* toplev.c (aux_base_name): New global.
	(compile_file): Pass aux_base_name to init init_branch_prob and
	end_final.
	(independent_decode_option, case 'a'): New auxinfo options.
	(case 'd'): Protect against mising basename.
	(do_compile): Initialize aux_base_name.
	* toplev.h (aux_base_name): New global.
	* doc/invoke.texi: Adjust documentation.

From-SVN: r56025
parent b23c054d
2002-08-04 Nathan Sidwell <nathan@codesourcery.com> 2002-08-04 Nathan Sidwell <nathan@codesourcery.com>
* gcc.c (cc1_options): Pass output file as auxbase when
appropriate.
* profile.c (init_branch_prob): FILENAME has already had ending
stripped.
* final.c (end_final): Likewise.
* toplev.c (aux_base_name): New global.
(compile_file): Pass aux_base_name to init init_branch_prob and
end_final.
(independent_decode_option, case 'a'): New auxinfo options.
(case 'd'): Protect against mising basename.
(do_compile): Initialize aux_base_name.
* toplev.h (aux_base_name): New global.
* doc/invoke.texi: Adjust documentation.
2002-08-04 Nathan Sidwell <nathan@codesourcery.com>
* config/i386/i386.c (x86_field_alignment): Remove duplicate test * config/i386/i386.c (x86_field_alignment): Remove duplicate test
of TARGET_ALIGN_DOUBLE. of TARGET_ALIGN_DOUBLE.
......
...@@ -2818,11 +2818,16 @@ allocation when it finishes. ...@@ -2818,11 +2818,16 @@ allocation when it finishes.
@item -fprofile-arcs @item -fprofile-arcs
@opindex fprofile-arcs @opindex fprofile-arcs
Instrument @dfn{arcs} during compilation to generate coverage data Instrument @dfn{arcs} during compilation to generate coverage data or
or for profile-directed block ordering. During execution the program for profile-directed block ordering. During execution the program
records how many times each branch is executed and how many times it is records how many times each branch is executed and how many times it is
taken. When the compiled program exits it saves this data to a file taken. When the compiled program exits it saves this data to a file
called @file{@var{sourcename}.da} for each source file. called @file{@var{auxname}.da} for each source file. @var{auxname} is
generated from the name of the output file, if explicitly specified and
it is not the final executable, otherwise it is the basename of the
source file. In both cases any suffix is removed (e.g. @file{foo.da}
for input file @file{dir/foo.c}, or @file{dir/foo.da} for output file
specified as @option{-o dir/foo.o}).
For profile-directed block ordering, compile the program with For profile-directed block ordering, compile the program with
@option{-fprofile-arcs} plus optimization and code generation options, @option{-fprofile-arcs} plus optimization and code generation options,
...@@ -2863,19 +2868,19 @@ information to estimate all branch probabilities. ...@@ -2863,19 +2868,19 @@ information to estimate all branch probabilities.
@item -ftest-coverage @item -ftest-coverage
@opindex ftest-coverage @opindex ftest-coverage
Create data files for the @code{gcov} code-coverage utility Create data files for the @code{gcov} code-coverage utility
(@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}). (@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}). See
The data file names begin with the name of your source file: @option{-fprofile-arcs} option above for a description of @var{auxname}.
@table @gcctabopt @table @gcctabopt
@item @var{sourcename}.bb @item @var{auxname}.bb
A mapping from basic blocks to line numbers, which @code{gcov} uses to A mapping from basic blocks to line numbers, which @code{gcov} uses to
associate basic block execution counts with line numbers. associate basic block execution counts with line numbers.
@item @var{sourcename}.bbg @item @var{auxname}.bbg
A list of all arcs in the program flow graph. This allows @code{gcov} A list of all arcs in the program flow graph. This allows @code{gcov}
to reconstruct the program flow graph, so that it can compute all basic to reconstruct the program flow graph, so that it can compute all basic
block and arc execution counts from the information in the block and arc execution counts from the information in the
@code{@var{sourcename}.da} file. @file{@var{auxname}.da} file.
@end table @end table
Use @option{-ftest-coverage} with @option{-fprofile-arcs}; the latter Use @option{-ftest-coverage} with @option{-fprofile-arcs}; the latter
...@@ -2883,9 +2888,9 @@ option adds instrumentation to the program, which then writes ...@@ -2883,9 +2888,9 @@ option adds instrumentation to the program, which then writes
execution counts to another data file: execution counts to another data file:
@table @gcctabopt @table @gcctabopt
@item @var{sourcename}.da @item @var{auxname}.da
Runtime arc execution counts, used in conjunction with the arc Runtime arc execution counts, used in conjunction with the arc
information in the file @code{@var{sourcename}.bbg}. information in the file @file{@var{auxname}.bbg}.
@end table @end table
Coverage data will map better to the source files if Coverage data will map better to the source files if
...@@ -2896,8 +2901,12 @@ Coverage data will map better to the source files if ...@@ -2896,8 +2901,12 @@ Coverage data will map better to the source files if
Says to make debugging dumps during compilation at times specified by Says to make debugging dumps during compilation at times specified by
@var{letters}. This is used for debugging the compiler. The file names @var{letters}. This is used for debugging the compiler. The file names
for most of the dumps are made by appending a pass number and a word to for most of the dumps are made by appending a pass number and a word to
the source file name (e.g. @file{foo.c.00.rtl} or @file{foo.c.01.sibling}). the @var{dumpname}. @var{dumpname} is generated from the name of the
Here are the possible letters for use in @var{letters}, and their meanings: output file, if explicitly specified and it is not an executable,
otherwise it is the basename of the source file. In both cases any
suffix is removed (e.g. @file{foo.00.rtl} or @file{foo.01.sibling}).
Here are the possible letters for use in @var{letters}, and their
meanings:
@table @samp @table @samp
@item A @item A
......
...@@ -311,7 +311,6 @@ end_final (filename) ...@@ -311,7 +311,6 @@ end_final (filename)
strcpy (da_filename, cwd); strcpy (da_filename, cwd);
strcat (da_filename, "/"); strcat (da_filename, "/");
strcat (da_filename, filename); strcat (da_filename, filename);
strip_off_ending (da_filename, da_filename_len - 3);
strcat (da_filename, ".da"); strcat (da_filename, ".da");
da_filename_len = strlen (da_filename); da_filename_len = strlen (da_filename);
string_cst = build_string (da_filename_len + 1, da_filename); string_cst = build_string (da_filename_len + 1, da_filename);
......
...@@ -697,6 +697,7 @@ static const char *cpp_debug_options = "%{d*}"; ...@@ -697,6 +697,7 @@ static const char *cpp_debug_options = "%{d*}";
static const char *cc1_options = static const char *cc1_options =
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
%1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
-auxbase%{c|S:%{o*:-strip%*}%{!o*: %b}}%{!c:%{!S: %b}}\
%{g*} %{O*} %{W*&pedantic*} %{w} %{std*} %{ansi}\ %{g*} %{O*} %{W*&pedantic*} %{w} %{std*} %{ansi}\
%{v:-version} %{pg:-p} %{p} %{f*} %{undef}\ %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
%{Qn:-fno-ident} %{--help:--help}\ %{Qn:-fno-ident} %{--help:--help}\
......
...@@ -1196,7 +1196,6 @@ init_branch_prob (filename) ...@@ -1196,7 +1196,6 @@ init_branch_prob (filename)
/* Open an output file for the basic block/line number map. */ /* Open an output file for the basic block/line number map. */
data_file = (char *) alloca (len + 4); data_file = (char *) alloca (len + 4);
strcpy (data_file, filename); strcpy (data_file, filename);
strip_off_ending (data_file, len);
strcat (data_file, ".bb"); strcat (data_file, ".bb");
if ((bb_file = fopen (data_file, "wb")) == 0) if ((bb_file = fopen (data_file, "wb")) == 0)
fatal_io_error ("can't open %s", data_file); fatal_io_error ("can't open %s", data_file);
...@@ -1204,7 +1203,6 @@ init_branch_prob (filename) ...@@ -1204,7 +1203,6 @@ init_branch_prob (filename)
/* Open an output file for the program flow graph. */ /* Open an output file for the program flow graph. */
bbg_file_name = (char *) alloca (len + 5); bbg_file_name = (char *) alloca (len + 5);
strcpy (bbg_file_name, filename); strcpy (bbg_file_name, filename);
strip_off_ending (bbg_file_name, len);
strcat (bbg_file_name, ".bbg"); strcat (bbg_file_name, ".bbg");
if ((bbg_file = fopen (bbg_file_name, "wb")) == 0) if ((bbg_file = fopen (bbg_file_name, "wb")) == 0)
fatal_io_error ("can't open %s", bbg_file_name); fatal_io_error ("can't open %s", bbg_file_name);
...@@ -1221,7 +1219,6 @@ init_branch_prob (filename) ...@@ -1221,7 +1219,6 @@ init_branch_prob (filename)
len = strlen (filename); len = strlen (filename);
da_file_name = (char *) alloca (len + 4); da_file_name = (char *) alloca (len + 4);
strcpy (da_file_name, filename); strcpy (da_file_name, filename);
strip_off_ending (da_file_name, len);
strcat (da_file_name, ".da"); strcat (da_file_name, ".da");
if ((da_file = fopen (da_file_name, "rb")) == 0) if ((da_file = fopen (da_file_name, "rb")) == 0)
warning ("file %s not found, execution counts assumed to be zero", warning ("file %s not found, execution counts assumed to be zero",
......
...@@ -168,6 +168,10 @@ int input_file_stack_tick; ...@@ -168,6 +168,10 @@ int input_file_stack_tick;
const char *dump_base_name; const char *dump_base_name;
/* Name to use as a base for auxiliary output files. */
const char *aux_base_name;
/* Format to use to print dumpfile index value */ /* Format to use to print dumpfile index value */
#ifndef DUMPFILE_FORMAT #ifndef DUMPFILE_FORMAT
#define DUMPFILE_FORMAT ".%02d." #define DUMPFILE_FORMAT ".%02d."
...@@ -2117,7 +2121,7 @@ compile_file () ...@@ -2117,7 +2121,7 @@ compile_file ()
/* Initialize yet another pass. */ /* Initialize yet another pass. */
init_final (main_input_filename); init_final (main_input_filename);
init_branch_prob (dump_base_name); init_branch_prob (aux_base_name);
timevar_push (TV_PARSE); timevar_push (TV_PARSE);
...@@ -2190,7 +2194,7 @@ compile_file () ...@@ -2190,7 +2194,7 @@ compile_file ()
dw2_output_indirect_constants (); dw2_output_indirect_constants ();
end_final (dump_base_name); end_final (aux_base_name);
if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
{ {
...@@ -4297,7 +4301,9 @@ independent_decode_option (argc, argv) ...@@ -4297,7 +4301,9 @@ independent_decode_option (argc, argv)
if (argc == 1) if (argc == 1)
return 0; return 0;
dump_base_name = argv[1]; if (argv[1][0])
dump_base_name = argv[1];
return 2; return 2;
} }
else else
...@@ -4370,6 +4376,30 @@ independent_decode_option (argc, argv) ...@@ -4370,6 +4376,30 @@ independent_decode_option (argc, argv)
else else
return 0; return 0;
} }
else if (!strcmp (arg, "auxbase"))
{
if (argc == 1)
return 0;
if (argv[1][0])
aux_base_name = argv[1];
return 2;
}
else if (!strcmp (arg, "auxbase-strip"))
{
if (argc == 1)
return 0;
if (argv[1][0])
{
strip_off_ending (argv[1], strlen (argv[1]));
if (argv[1][0])
aux_base_name = argv[1];
}
return 2;
}
else else
return 0; return 0;
break; break;
...@@ -5170,7 +5200,7 @@ lang_dependent_init (name) ...@@ -5170,7 +5200,7 @@ lang_dependent_init (name)
{ {
if (dump_base_name == 0) if (dump_base_name == 0)
dump_base_name = name ? name : "gccdump"; dump_base_name = name ? name : "gccdump";
/* Front-end initialization. This hook can assume that GC, /* Front-end initialization. This hook can assume that GC,
identifier hashes etc. are set up, but debug initialization is identifier hashes etc. are set up, but debug initialization is
not done yet. This routine must return the original filename not done yet. This routine must return the original filename
...@@ -5281,6 +5311,19 @@ do_compile (no_backend) ...@@ -5281,6 +5311,19 @@ do_compile (no_backend)
/* The bulk of command line switch processing. */ /* The bulk of command line switch processing. */
process_options (); process_options ();
if (aux_base_name)
/*NOP*/;
else if (filename)
{
char *name = xstrdup (lbasename (filename));
aux_base_name = name;
strip_off_ending (name, strlen (name));
}
else
aux_base_name = "gccaux";
/* We cannot start timing until after options are processed since that /* We cannot start timing until after options are processed since that
says if we run timers or not. */ says if we run timers or not. */
init_timevar (); init_timevar ();
......
...@@ -108,6 +108,8 @@ extern void check_global_declarations PARAMS ((union tree_node **, int)); ...@@ -108,6 +108,8 @@ extern void check_global_declarations PARAMS ((union tree_node **, int));
extern const char *progname; extern const char *progname;
extern const char *dump_base_name; extern const char *dump_base_name;
extern const char *aux_base_name;
extern int target_flags_explicit; extern int target_flags_explicit;
/* The hashtable, so that the C front ends can pass it to cpplib. */ /* The hashtable, so that the C front ends can pass it to cpplib. */
......
Markdown is supported
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