gcc/ChangeLog:

2019-03-27  Martin Liska  <mli...@suse.cz>

        * dbgcnt.c (dbg_cnt_set_limit_by_name): Add new argument
        aux_base and filter based on aux_base_name.
        (dbg_cnt_process_single_pair): Parse aux_base.
        * doc/invoke.texi: Document new extended format.

gcc/testsuite/ChangeLog:

2019-03-27  Martin Liska  <mli...@suse.cz>

        * gcc.dg/dbg-cnt-1.c: New test.
---
 gcc/dbgcnt.c                     | 11 ++++++++---
 gcc/doc/invoke.texi              |  8 ++++++--
 gcc/testsuite/gcc.dg/dbg-cnt-1.c |  6 ++++++
 3 files changed, 20 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/dbg-cnt-1.c

diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c
index e2f65f449e5..5a7c9a8bf6e 100644
--- a/gcc/dbgcnt.c
+++ b/gcc/dbgcnt.c
@@ -24,6 +24,7 @@ See dbgcnt.def for usage information.  */
 #include "coretypes.h"
 #include "diagnostic-core.h"
 #include "dumpfile.h"
+#include "options.h"
 
 #include "dbgcnt.h"
 
@@ -87,8 +88,11 @@ dbg_cnt_set_limit_by_index (enum debug_counter index, int low, int high)
 }
 
 static bool
-dbg_cnt_set_limit_by_name (const char *name, int low, int high)
+dbg_cnt_set_limit_by_name (const char *name, int low, int high, char *aux_base)
 {
+  if (aux_base != NULL && strcmp (aux_base_name, aux_base) != 0)
+    return true;
+
   if (high < low)
     {
       error ("%<-fdbg-cnt=%s:%d:%d%> has smaller upper limit than the lower",
@@ -123,7 +127,7 @@ dbg_cnt_set_limit_by_name (const char *name, int low, int high)
 }
 
 
-/* Process a single "name:value" pair.
+/* Process a single "name:value1[:value2][:aux_base]" tuple.
    Returns NULL if there's no valid pair is found.
    Otherwise returns a pointer to the end of the pair. */
 
@@ -134,6 +138,7 @@ dbg_cnt_process_single_pair (const char *arg)
   char *name = strtok (str, ":");
   char *value1 = strtok (NULL, ":");
   char *value2 = strtok (NULL, ":");
+  char *aux_base = strtok (NULL, ":");
 
   int high, low;
 
@@ -151,7 +156,7 @@ dbg_cnt_process_single_pair (const char *arg)
       high = strtol (value2, NULL, 10);
     }
 
-  return dbg_cnt_set_limit_by_name (name, low, high);
+  return dbg_cnt_set_limit_by_name (name, low, high, aux_base);
 }
 
 void
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4735b0ab673..d2934edd36d 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -15386,10 +15386,14 @@ Print the name and the counter upper bound for all debug counters.
 @item -fdbg-cnt=@var{counter-value-list}
 @opindex fdbg-cnt
 Set the internal debug counter lower and upper bound.  @var{counter-value-list}
-is a comma-separated list of @var{name}:@var{lower_bound}:@var{upper_bound}
+is a comma-separated list of
+@var{name}:@var{lower_bound}:@var{upper_bound}:@var{aux_base_name}
 tuples which sets the lower and the upper bound of each debug
 counter @var{name}.  The @var{lower_bound} is optional and is zero
-initialized if not set.
+initialized if not set.  When @var{aux_base_name} is set, the debug counter
+is only applied to source files that match by @option{-auxbase}.
+The @var{aux_base_name} is also optional.
+
 All debug counters have the initial upper bound of @code{UINT_MAX};
 thus @code{dbg_cnt} returns true always unless the upper bound
 is set by this option.
diff --git a/gcc/testsuite/gcc.dg/dbg-cnt-1.c b/gcc/testsuite/gcc.dg/dbg-cnt-1.c
new file mode 100644
index 00000000000..2afd2428eb9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dbg-cnt-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fdbg-cnt=vect_loop:1:2,vect_slp:2,merged_ipa_icf:7:8:dbg-cnt-1" } */
+/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-prune-output "dbg_cnt 'vect_loop' set to 1-2" } */
+/* { dg-prune-output "dbg_cnt 'vect_slp' set to 0-2" } */
+/* { dg-prune-output "dbg_cnt 'merged_ipa_icf' set to 7-8" } */

Reply via email to