dumpfile.c (dump_loc): Output column number.
authorTeresa Johnson <tejohnson@google.com>
Thu, 29 Aug 2013 13:51:04 +0000 (13:51 +0000)
committerTeresa Johnson <tejohnson@gcc.gnu.org>
Thu, 29 Aug 2013 13:51:04 +0000 (13:51 +0000)
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

14 files changed:
gcc/ChangeLog
gcc/coverage.c
gcc/doc/invoke.texi
gcc/dumpfile.c
gcc/dumpfile.h
gcc/pass_manager.h
gcc/passes.c
gcc/profile.c
gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
gcc/testsuite/gcc.dg/inline-dump.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr26570.c
gcc/testsuite/gcc.dg/pr32773.c
gcc/testsuite/gcc.dg/pr40209.c
gcc/value-prof.c

index 30caf6edf4e05498dc8a36355075d68cdd3ffda3..fedf7c42007a4336f28261607fe6f64f52c5f40a 100644 (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
index 9b664cf1500a23fe46a36fc37f1f4ff9e524598c..d662e8d094622e7e6c407b42899964bec73649ff 100644 (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
index 411c8be66c15ba54056828ae1f33336b0cff1539..0858f2fee69742388c04ef4ee5ce53e5be2661c4 100644 (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,
index 9c97512e7999aa980a552c34852219623f474003..6f15634ab7b20f268bdf0b159702fd60d2d136ac 100644 (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));
     }
 }
 
index da079bad7483f574d89a12fb3d31b1e83f870bab..ddc770ab947be5a310218447a3d9ad55cce4ad55 100644 (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
index 41d2c7605d24e08dd4341b0649f4f03e4c1129c9..04c6237d791fb8a19eed19e2db3034a16c80740c 100644 (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.  */
index e3a7212ccce3574bcf56973cdc238a253a1cc314..bffff412c1748163f02e1b52978282ba7da82be6 100644 (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);
index c469df56dba70c754d4f2be80e2ee8ccbbd0400b..2abde8aec03c949f6c8093a1df06d7e5ec165c50 100644 (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 */
index 5513d3650c6803ee8cebb6349ab312e99a8d2505..91f43ae8c0bf5033bab4cb5ad0127982ea2681d3 100644 (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
 {
diff --git a/gcc/testsuite/gcc.dg/inline-dump.c b/gcc/testsuite/gcc.dg/inline-dump.c
new file mode 100644 (file)
index 0000000..e0c9ba6
--- /dev/null
@@ -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(); }
index 5768d32cc1251517f342ff1c636fb2cdcfb655e3..71c16f20744d789b7417e931695b16b5c5980503 100644 (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)
 {
index e9cdd4c377e7507d36d6fafb7172d7459972def6..19a90195ad39f4efb94d6c42af30bb5fab4fc37e 100644 (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)
 {
index f367f7c247245239805850a9058503b3f80b8f76..afe131fc5eb74fa3e66b2b4c380a0d344664db39 100644 (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);
 
index 69fcbbcf41d6e1ed6f1746451b9ba3acb0042d0f..3aa5c7469eeddbba174441bfe1c3aaf3972c29ce 100644 (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;
 }