aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2013-08-29 13:51:04 +0000
committerTeresa Johnson <tejohnson@google.com>2013-08-29 13:51:04 +0000
commit9b7f3057558587c9303eeb5f96e587bcb59ceb63 (patch)
treefc61cacb307eeb74176a0b795fc6db1199798047
parent539be2c6b77285b63e6de43f14e28715a39249b4 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@202077 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/coverage.c44
-rw-r--r--gcc/doc/invoke.texi3
-rw-r--r--gcc/dumpfile.c10
-rw-r--r--gcc/dumpfile.h3
-rw-r--r--gcc/pass_manager.h1
-rw-r--r--gcc/passes.c5
-rw-r--r--gcc/profile.c9
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C2
-rw-r--r--gcc/testsuite/gcc.dg/inline-dump.c11
-rw-r--r--gcc/testsuite/gcc.dg/pr26570.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr32773.c4
-rw-r--r--gcc/testsuite/gcc.dg/pr40209.c2
-rw-r--r--gcc/value-prof.c14
14 files changed, 97 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 30caf6edf4e..fedf7c42007 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 9b664cf1500..d662e8d0946 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 411c8be66c1..0858f2fee69 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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,
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 9c97512e799..6f15634ab7b 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -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));
}
}
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index da079bad748..ddc770ab947 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -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
diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h
index 41d2c7605d2..04c6237d791 100644
--- a/gcc/pass_manager.h
+++ b/gcc/pass_manager.h
@@ -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. */
diff --git a/gcc/passes.c b/gcc/passes.c
index e3a7212ccce..bffff412c17 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -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);
diff --git a/gcc/profile.c b/gcc/profile.c
index c469df56dba..2abde8aec03 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -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 */
diff --git a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
index 5513d3650c6..91f43ae8c0b 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
@@ -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
{
diff --git a/gcc/testsuite/gcc.dg/inline-dump.c b/gcc/testsuite/gcc.dg/inline-dump.c
new file mode 100644
index 00000000000..e0c9ba6993c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/inline-dump.c
@@ -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(); }
diff --git a/gcc/testsuite/gcc.dg/pr26570.c b/gcc/testsuite/gcc.dg/pr26570.c
index 5768d32cc12..71c16f20744 100644
--- a/gcc/testsuite/gcc.dg/pr26570.c
+++ b/gcc/testsuite/gcc.dg/pr26570.c
@@ -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)
{
diff --git a/gcc/testsuite/gcc.dg/pr32773.c b/gcc/testsuite/gcc.dg/pr32773.c
index e9cdd4c377e..19a90195ad3 100644
--- a/gcc/testsuite/gcc.dg/pr32773.c
+++ b/gcc/testsuite/gcc.dg/pr32773.c
@@ -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)
{
diff --git a/gcc/testsuite/gcc.dg/pr40209.c b/gcc/testsuite/gcc.dg/pr40209.c
index f367f7c2472..afe131fc5eb 100644
--- a/gcc/testsuite/gcc.dg/pr40209.c
+++ b/gcc/testsuite/gcc.dg/pr40209.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fprofile-use" } */
+/* { dg-options "-O2 -fprofile-use -fopt-info" } */
void process(const char *s);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 69fcbbcf41d..3aa5c7469ee 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -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;
}