dumpfile.c (dump_loc): Output column number.

2013-08-29  Teresa Johnson  <tejohnson@google.com>

	* dumpfile.c (dump_loc): Output column number.
	* dumpfile.h (OPTGROUP_OTHER): Add and enable under OPTGROUP_ALL.
	* doc/invoke.texi: Document optall -fopt-info flag.
	* profile.c (read_profile_edge_counts): Use new dump framework.
	(compute_branch_probabilities): Ditto.
	* passes.c (pass_manager::register_one_dump_file): Use OPTGROUP_OTHER
	when pass not in any opt group.
	* pass_manager.h (pass_manager::get_pass_profile): New method.
	* value-prof.c (check_counter): Use new dump framework.
	(check_ic_target): Ditto.
	* coverage.c (get_coverage_counts): Ditto.
	(coverage_init): Setup new dump framework.

	* testsuite/gcc.dg/pr40209.c: Use -fopt-info.
	* testsuite/gcc.dg/pr26570.c: Ditto.
	* testsuite/gcc.dg/pr32773.c: Ditto.
	* testsuite/g++.dg/tree-ssa/dom-invalid.C: Ditto.
	* testsuite/gcc.dg/inline-dump.c: New test.

From-SVN: r202077
This commit is contained in:
Teresa Johnson 2013-08-29 13:51:04 +00:00 committed by Teresa Johnson
parent 301bbc1662
commit 103ff0d65e
14 changed files with 97 additions and 34 deletions

View File

@ -1,3 +1,24 @@
2013-08-29 Teresa Johnson <tejohnson@google.com>
* dumpfile.c (dump_loc): Output column number.
* dumpfile.h (OPTGROUP_OTHER): Add and enable under OPTGROUP_ALL.
* doc/invoke.texi: Document optall -fopt-info flag.
* profile.c (read_profile_edge_counts): Use new dump framework.
(compute_branch_probabilities): Ditto.
* passes.c (pass_manager::register_one_dump_file): Use OPTGROUP_OTHER
when pass not in any opt group.
* pass_manager.h (pass_manager::get_pass_profile): New method.
* value-prof.c (check_counter): Use new dump framework.
(check_ic_target): Ditto.
* coverage.c (get_coverage_counts): Ditto.
(coverage_init): Setup new dump framework.
* testsuite/gcc.dg/pr40209.c: Use -fopt-info.
* testsuite/gcc.dg/pr26570.c: Ditto.
* testsuite/gcc.dg/pr32773.c: Ditto.
* testsuite/g++.dg/tree-ssa/dom-invalid.C: Ditto.
* testsuite/gcc.dg/inline-dump.c: New test.
2013-08-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/58246

View File

@ -43,6 +43,9 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
#include "hash-table.h"
#include "tree-iterator.h"
#include "context.h"
#include "pass_manager.h"
#include "tree-pass.h"
#include "cgraph.h"
#include "dumpfile.h"
#include "diagnostic-core.h"
@ -341,11 +344,13 @@ get_coverage_counts (unsigned counter, unsigned expected,
{
static int warned = 0;
if (!warned++)
inform (input_location, (flag_guess_branch_prob
? "file %s not found, execution counts estimated"
: "file %s not found, execution counts assumed to be zero"),
da_file_name);
if (!warned++ && dump_enabled_p ())
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location,
(flag_guess_branch_prob
? "file %s not found, execution counts estimated"
: "file %s not found, execution counts assumed to "
"be zero"),
da_file_name);
return NULL;
}
@ -369,21 +374,25 @@ get_coverage_counts (unsigned counter, unsigned expected,
warning_at (input_location, OPT_Wcoverage_mismatch,
"the control flow of function %qE does not match "
"its profile data (counter %qs)", id, ctr_names[counter]);
if (warning_printed)
if (warning_printed && dump_enabled_p ())
{
inform (input_location, "use -Wno-error=coverage-mismatch to tolerate "
"the mismatch but performance may drop if the function is hot");
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location,
"use -Wno-error=coverage-mismatch to tolerate "
"the mismatch but performance may drop if the "
"function is hot");
if (!seen_error ()
&& !warned++)
{
inform (input_location, "coverage mismatch ignored");
inform (input_location, flag_guess_branch_prob
? G_("execution counts estimated")
: G_("execution counts assumed to be zero"));
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location,
"coverage mismatch ignored");
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location,
flag_guess_branch_prob
? G_("execution counts estimated")
: G_("execution counts assumed to be zero"));
if (!flag_guess_branch_prob)
inform (input_location,
"this can result in poorly optimized code");
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, input_location,
"this can result in poorly optimized code");
}
}
@ -1125,6 +1134,11 @@ coverage_init (const char *filename)
int len = strlen (filename);
int prefix_len = 0;
/* Since coverage_init is invoked very early, before the pass
manager, we need to set up the dumping explicitly. This is
similar to the handling in finish_optimization_passes. */
dump_start (g->get_passes ()->get_pass_profile ()->static_pass_number, NULL);
if (!profile_data_prefix && !IS_ABSOLUTE_PATH (filename))
profile_data_prefix = getpwd ();
@ -1167,6 +1181,8 @@ coverage_init (const char *filename)
gcov_write_unsigned (bbg_file_stamp);
}
}
dump_finish (g->get_passes ()->get_pass_profile ()->static_pass_number);
}
/* Performs file-level cleanup. Close notes file, generate coverage

View File

@ -6293,6 +6293,9 @@ Enable dumps from all loop optimizations.
Enable dumps from all inlining optimizations.
@item vec
Enable dumps from all vectorization optimizations.
@item optall
Enable dumps from all optimizations. This is a superset of
the optimization groups listed above.
@end table
For example,

View File

@ -259,16 +259,16 @@ dump_open_alternate_stream (struct dump_file_info *dfi)
void
dump_loc (int dump_kind, FILE *dfile, source_location loc)
{
/* Currently vectorization passes print location information. */
if (dump_kind)
{
if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION)
fprintf (dfile, "\n%s:%d: note: ", LOCATION_FILE (loc),
LOCATION_LINE (loc));
fprintf (dfile, "\n%s:%d:%d: note: ", LOCATION_FILE (loc),
LOCATION_LINE (loc), LOCATION_COLUMN (loc));
else if (current_function_decl)
fprintf (dfile, "\n%s:%d: note: ",
fprintf (dfile, "\n%s:%d:%d: note: ",
DECL_SOURCE_FILE (current_function_decl),
DECL_SOURCE_LINE (current_function_decl));
DECL_SOURCE_LINE (current_function_decl),
DECL_SOURCE_COLUMN (current_function_decl));
}
}

View File

@ -98,8 +98,9 @@ enum tree_dump_index
#define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
#define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
#define OPTGROUP_VEC (1 << 4) /* Vectorization passes */
#define OPTGROUP_OTHER (1 << 5) /* All other passes */
#define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
| OPTGROUP_VEC)
| OPTGROUP_VEC | OPTGROUP_OTHER)
/* Define a tree dump switch. */
struct dump_file_info

View File

@ -74,6 +74,7 @@ public:
return pass_mode_switching_1;
}
opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; }
opt_pass *get_pass_profile () const { return pass_profile_1; }
public:
/* The root of the compilation pass tree, once constructed. */

View File

@ -676,6 +676,11 @@ pass_manager::register_one_dump_file (struct opt_pass *pass)
flag_name = concat (prefix, name, num, NULL);
glob_name = concat (prefix, name, NULL);
optgroup_flags |= pass->optinfo_flags;
/* For any passes that do not have an optgroup set, and which are not
IPA passes setup above, set the optgroup to OPTGROUP_OTHER so that
any dump messages are emitted properly under -fopt-info(-optall). */
if (optgroup_flags == OPTGROUP_NONE)
optgroup_flags = OPTGROUP_OTHER;
id = dump_register (dot_name, flag_name, glob_name, flags, optgroup_flags);
set_pass_for_id (id, pass);
full_name = concat (prefix, pass->name, num, NULL);

View File

@ -432,8 +432,8 @@ read_profile_edge_counts (gcov_type *exec_counts)
if (flag_profile_correction)
{
static bool informed = 0;
if (!informed)
inform (input_location,
if (dump_enabled_p () && !informed)
dump_printf_loc (MSG_NOTE, input_location,
"corrupted profile info: edge count exceeds maximal count");
informed = 1;
}
@ -692,10 +692,11 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
{
/* Inconsistency detected. Make it flow-consistent. */
static int informed = 0;
if (informed == 0)
if (dump_enabled_p () && informed == 0)
{
informed = 1;
inform (input_location, "correcting inconsistent profile data");
dump_printf_loc (MSG_NOTE, input_location,
"correcting inconsistent profile data");
}
correct_negative_edge_counts ();
/* Set bb counts to the sum of the outgoing edge counts */

View File

@ -1,7 +1,7 @@
// PR tree-optimization/39557
// invalid post-dom info leads to infinite loop
// { dg-do run }
// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fno-rtti" }
// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fopt-info -fno-rtti" }
struct C
{

View File

@ -0,0 +1,11 @@
/* Verify that -fopt-info can output correct inline info. */
/* { dg-do compile } */
/* { dg-options "-Wall -fopt-info-inline=stderr -O2 -fno-early-inlining" } */
static inline int leaf() {
int i, ret = 0;
for (i = 0; i < 10; i++)
ret += i;
return ret;
}
static inline int foo(void) { return leaf(); } /* { dg-message "note: leaf .*inlined into bar .*via inline instance foo.*\n" } */
int bar(void) { return foo(); }

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fprofile-generate -fprofile-use" } */
/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info" } */
unsigned test (unsigned a, unsigned b)
{

View File

@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -fprofile-use" } */
/* { dg-options "-O -m4 -fprofile-use" { target sh-*-* } } */
/* { dg-options "-O -fprofile-use -fopt-info" } */
/* { dg-options "-O -m4 -fprofile-use -fopt-info" { target sh-*-* } } */
void foo (int *p)
{

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fprofile-use" } */
/* { dg-options "-O2 -fprofile-use -fopt-info" } */
void process(const char *s);

View File

@ -585,9 +585,11 @@ check_counter (gimple stmt, const char * name,
: DECL_SOURCE_LOCATION (current_function_decl);
if (flag_profile_correction)
{
inform (locus, "correcting inconsistent value profile: "
"%s profiler overall count (%d) does not match BB count "
"(%d)", name, (int)*all, (int)bb_count);
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, locus,
"correcting inconsistent value profile: %s "
"profiler overall count (%d) does not match BB "
"count (%d)", name, (int)*all, (int)bb_count);
*all = bb_count;
if (*count > *all)
*count = *all;
@ -1271,8 +1273,10 @@ check_ic_target (gimple call_stmt, struct cgraph_node *target)
return true;
locus = gimple_location (call_stmt);
inform (locus, "Skipping target %s with mismatching types for icall ",
cgraph_node_name (target));
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, locus,
"Skipping target %s with mismatching types for icall ",
cgraph_node_name (target));
return false;
}