Enhance syntax of -fdbg-cnt.
2019-11-13 Martin Liska <mliska@suse.cz> * common.opt: Document change of -fdbg-cnt option. * dbgcnt.c (DEBUG_COUNTER): Remove. (dbg_cnt_is_enabled): Remove. (dbg_cnt): Work with new intervals. (dbg_cnt_set_limit_by_index): Set to new list of intervals. (dbg_cnt_set_limit_by_name): Likewise. (dbg_cnt_process_single_pair): Process new format. (dbg_cnt_process_opt): Likewise. (dbg_cnt_list_all_counters): Likewise. * doc/invoke.texi: Document change of -fdbg-cnt option. (cmp_tuples): New. 2019-11-13 Martin Liska <mliska@suse.cz> * gcc.dg/ipa/ipa-icf-39.c: Update -fdbg-cnt to the new format. * gcc.dg/pr68766.c: Likewise. From-SVN: r278140
This commit is contained in:
parent
2895b172d5
commit
83a49336c6
@ -1,3 +1,18 @@
|
|||||||
|
2019-11-13 Martin Liska <mliska@suse.cz>
|
||||||
|
|
||||||
|
* common.opt: Document change of -fdbg-cnt option.
|
||||||
|
* dbgcnt.c (DEBUG_COUNTER): Remove.
|
||||||
|
(dbg_cnt_is_enabled): Remove.
|
||||||
|
(dbg_cnt): Work with new intervals.
|
||||||
|
(dbg_cnt_set_limit_by_index): Set to new
|
||||||
|
list of intervals.
|
||||||
|
(dbg_cnt_set_limit_by_name): Likewise.
|
||||||
|
(dbg_cnt_process_single_pair): Process new format.
|
||||||
|
(dbg_cnt_process_opt): Likewise.
|
||||||
|
(dbg_cnt_list_all_counters): Likewise.
|
||||||
|
* doc/invoke.texi: Document change of -fdbg-cnt option.
|
||||||
|
(cmp_tuples): New.
|
||||||
|
|
||||||
2019-11-13 Jan Hubicka <hubicka@ucw.cz>
|
2019-11-13 Jan Hubicka <hubicka@ucw.cz>
|
||||||
|
|
||||||
* ipa-inline.c (ipa_inline): Check that function is defined before
|
* ipa-inline.c (ipa_inline): Check that function is defined before
|
||||||
|
@ -1188,7 +1188,7 @@ List all available debugging counters with their limits and counts.
|
|||||||
|
|
||||||
fdbg-cnt=
|
fdbg-cnt=
|
||||||
Common RejectNegative Joined Var(common_deferred_options) Defer
|
Common RejectNegative Joined Var(common_deferred_options) Defer
|
||||||
-fdbg-cnt=<counter>[:<lower_limit>]:<upper_limit>[,<counter>:...] Set the debug counter limit.
|
-fdbg-cnt=<counter>[:<lower_limit1>-]<upper_limit1>[:<lower_limit2>-<upper_limit2>:...][,<counter>:...] Set the debug counter limit.
|
||||||
|
|
||||||
fdebug-prefix-map=
|
fdebug-prefix-map=
|
||||||
Common Joined RejectNegative Var(common_deferred_options) Defer
|
Common Joined RejectNegative Var(common_deferred_options) Defer
|
||||||
|
170
gcc/dbgcnt.c
170
gcc/dbgcnt.c
@ -40,24 +40,12 @@ static struct string2counter_map map[debug_counter_number_of_counters] =
|
|||||||
};
|
};
|
||||||
#undef DEBUG_COUNTER
|
#undef DEBUG_COUNTER
|
||||||
|
|
||||||
#define DEBUG_COUNTER(a) UINT_MAX,
|
typedef std::pair<unsigned int, unsigned int> limit_tuple;
|
||||||
static unsigned int limit_high[debug_counter_number_of_counters] =
|
|
||||||
{
|
|
||||||
#include "dbgcnt.def"
|
|
||||||
};
|
|
||||||
#undef DEBUG_COUNTER
|
|
||||||
|
|
||||||
static unsigned int limit_low[debug_counter_number_of_counters];
|
static vec<limit_tuple> limits[debug_counter_number_of_counters];
|
||||||
|
|
||||||
static unsigned int count[debug_counter_number_of_counters];
|
static unsigned int count[debug_counter_number_of_counters];
|
||||||
|
|
||||||
bool
|
|
||||||
dbg_cnt_is_enabled (enum debug_counter index)
|
|
||||||
{
|
|
||||||
unsigned v = count[index];
|
|
||||||
return v > limit_low[index] && v <= limit_high[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_limit_reach (const char *counter, int limit, bool upper_p)
|
print_limit_reach (const char *counter, int limit, bool upper_p)
|
||||||
{
|
{
|
||||||
@ -72,50 +60,89 @@ print_limit_reach (const char *counter, int limit, bool upper_p)
|
|||||||
bool
|
bool
|
||||||
dbg_cnt (enum debug_counter index)
|
dbg_cnt (enum debug_counter index)
|
||||||
{
|
{
|
||||||
count[index]++;
|
unsigned v = ++count[index];
|
||||||
|
|
||||||
/* Do not print the info for default lower limit. */
|
if (!limits[index].exists ())
|
||||||
if (count[index] == limit_low[index] && limit_low[index] > 0)
|
return true;
|
||||||
print_limit_reach (map[index].name, limit_low[index], false);
|
else if (limits[index].is_empty ())
|
||||||
else if (count[index] == limit_high[index])
|
return false;
|
||||||
print_limit_reach (map[index].name, limit_high[index], true);
|
|
||||||
|
|
||||||
return dbg_cnt_is_enabled (index);
|
unsigned last = limits[index].length () - 1;
|
||||||
|
unsigned int min = limits[index][last].first;
|
||||||
|
unsigned int max = limits[index][last].second;
|
||||||
|
|
||||||
|
if (v < min)
|
||||||
|
return false;
|
||||||
|
else if (v == min)
|
||||||
|
{
|
||||||
|
print_limit_reach (map[index].name, v, false);
|
||||||
|
if (min == max)
|
||||||
|
limits[index].pop ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (v < max)
|
||||||
|
return true;
|
||||||
|
else if (v == max)
|
||||||
|
{
|
||||||
|
print_limit_reach (map[index].name, v, true);
|
||||||
|
limits[index].pop ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Compare limit_tuple intervals by first item in descending order. */
|
||||||
dbg_cnt_set_limit_by_index (enum debug_counter index, int low, int high)
|
|
||||||
{
|
|
||||||
limit_low[index] = low;
|
|
||||||
limit_high[index] = high;
|
|
||||||
|
|
||||||
fprintf (stderr, "dbg_cnt '%s' set to %d-%d\n", map[index].name, low, high);
|
static int
|
||||||
|
cmp_tuples (const void *ptr1, const void *ptr2)
|
||||||
|
{
|
||||||
|
const limit_tuple *p1 = (const limit_tuple *)ptr1;
|
||||||
|
const limit_tuple *p2 = (const limit_tuple *)ptr2;
|
||||||
|
|
||||||
|
if (p1->first < p2->first)
|
||||||
|
return 1;
|
||||||
|
else if (p1->first > p2->first)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
dbg_cnt_set_limit_by_name (const char *name, int low, int high)
|
dbg_cnt_set_limit_by_index (enum debug_counter index, const char *name,
|
||||||
|
unsigned int low, unsigned int high)
|
||||||
|
{
|
||||||
|
if (!limits[index].exists ())
|
||||||
|
limits[index].create (1);
|
||||||
|
|
||||||
|
limits[index].safe_push (limit_tuple (low, high));
|
||||||
|
limits[index].qsort (cmp_tuples);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < limits[index].length () - 1; i++)
|
||||||
|
{
|
||||||
|
limit_tuple t1 = limits[index][i];
|
||||||
|
limit_tuple t2 = limits[index][i + 1];
|
||||||
|
if (t1.first <= t2.second)
|
||||||
|
{
|
||||||
|
error ("Interval overlap of %<-fdbg-cnt=%s%>: [%u, %u] and "
|
||||||
|
"[%u, %u]\n", name, t2.first, t2.second, t1.first, t1.second);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
dbg_cnt_set_limit_by_name (const char *name, unsigned int low,
|
||||||
|
unsigned int high)
|
||||||
{
|
{
|
||||||
if (high < low)
|
if (high < low)
|
||||||
{
|
{
|
||||||
error ("%<-fdbg-cnt=%s:%d:%d%> has smaller upper limit than the lower",
|
error ("%<-fdbg-cnt=%s:%d-%d%> has smaller upper limit than the lower",
|
||||||
name, low, high);
|
name, low, high);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (low < 0)
|
|
||||||
{
|
|
||||||
error ("Lower limit %d of %<-fdbg-cnt=%s%> must be a non-negative "
|
|
||||||
"number", low, name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (high < 0)
|
|
||||||
{
|
|
||||||
error ("Upper limit %d of %<-fdbg-cnt=%s%> must be a non-negative "
|
|
||||||
"number", high, name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = debug_counter_number_of_counters - 1; i >= 0; i--)
|
for (i = debug_counter_number_of_counters - 1; i >= 0; i--)
|
||||||
if (strcmp (map[i].name, name) == 0)
|
if (strcmp (map[i].name, name) == 0)
|
||||||
@ -124,31 +151,27 @@ dbg_cnt_set_limit_by_name (const char *name, int low, int high)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dbg_cnt_set_limit_by_index ((enum debug_counter) i, low, high);
|
return dbg_cnt_set_limit_by_index ((enum debug_counter) i, name, low, high);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Process a single "low:high" pair.
|
||||||
/* Process a single "name:value" pair.
|
|
||||||
Returns NULL if there's no valid pair is found.
|
Returns NULL if there's no valid pair is found.
|
||||||
Otherwise returns a pointer to the end of the pair. */
|
Otherwise returns a pointer to the end of the pair. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
dbg_cnt_process_single_pair (const char *arg)
|
dbg_cnt_process_single_pair (char *name, char *str)
|
||||||
{
|
{
|
||||||
char *str = xstrdup (arg);
|
char *value1 = strtok (str, "-");
|
||||||
char *name = strtok (str, ":");
|
char *value2 = strtok (NULL, "-");
|
||||||
char *value1 = strtok (NULL, ":");
|
|
||||||
char *value2 = strtok (NULL, ":");
|
|
||||||
|
|
||||||
int high, low;
|
unsigned int high, low;
|
||||||
|
|
||||||
if (value1 == NULL)
|
if (value1 == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (value2 == NULL)
|
if (value2 == NULL)
|
||||||
{
|
{
|
||||||
low = 0;
|
low = 1;
|
||||||
high = strtol (value1, NULL, 10);
|
high = strtol (value1, NULL, 10);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,17 +189,24 @@ dbg_cnt_process_opt (const char *arg)
|
|||||||
char *str = xstrdup (arg);
|
char *str = xstrdup (arg);
|
||||||
unsigned int start = 0;
|
unsigned int start = 0;
|
||||||
|
|
||||||
auto_vec<const char *> tokens;
|
auto_vec<char *> tokens;
|
||||||
for (const char *next = strtok (str, ","); next != NULL;
|
for (char *next = strtok (str, ","); next != NULL; next = strtok (NULL, ","))
|
||||||
next = strtok (NULL, ","))
|
|
||||||
tokens.safe_push (next);
|
tokens.safe_push (next);
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < tokens.length (); i++)
|
for (i = 0; i < tokens.length (); i++)
|
||||||
{
|
{
|
||||||
if (!dbg_cnt_process_single_pair (tokens[i]))
|
auto_vec<char *> ranges;
|
||||||
break;
|
char *name = strtok (tokens[i], ":");
|
||||||
start += strlen (tokens[i]) + 1;
|
for (char *part = strtok (NULL, ":"); part; part = strtok (NULL, ":"))
|
||||||
|
ranges.safe_push (part);
|
||||||
|
|
||||||
|
for (unsigned j = 0; j < ranges.length (); j++)
|
||||||
|
{
|
||||||
|
if (!dbg_cnt_process_single_pair (name, ranges[j]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
start += strlen (tokens[i]) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != tokens.length ())
|
if (i != tokens.length ())
|
||||||
@ -195,11 +225,23 @@ void
|
|||||||
dbg_cnt_list_all_counters (void)
|
dbg_cnt_list_all_counters (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
printf (" %-32s %-11s %-12s\n", "counter name", "low limit",
|
printf (" %-30s %s\n", "counter name", "closed intervals");
|
||||||
"high limit");
|
|
||||||
printf ("-----------------------------------------------------------------\n");
|
printf ("-----------------------------------------------------------------\n");
|
||||||
for (i = 0; i < debug_counter_number_of_counters; i++)
|
for (i = 0; i < debug_counter_number_of_counters; i++)
|
||||||
printf (" %-30s %11u %12u\n",
|
{
|
||||||
map[i].name, limit_low[map[i].counter], limit_high[map[i].counter]);
|
printf (" %-30s ", map[i].name);
|
||||||
|
if (limits[i].exists ())
|
||||||
|
{
|
||||||
|
for (int j = limits[i].length () - 1; j >= 0; j--)
|
||||||
|
{
|
||||||
|
printf ("[%u, %u]", limits[i][j].first, limits[i][j].second);
|
||||||
|
if (j > 0)
|
||||||
|
printf (", ");
|
||||||
|
}
|
||||||
|
putchar ('\n');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf ("unset\n");
|
||||||
|
}
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
@ -15656,15 +15656,14 @@ Print the name and the counter upper bound for all debug counters.
|
|||||||
@item -fdbg-cnt=@var{counter-value-list}
|
@item -fdbg-cnt=@var{counter-value-list}
|
||||||
@opindex fdbg-cnt
|
@opindex fdbg-cnt
|
||||||
Set the internal debug counter lower and upper bound. @var{counter-value-list}
|
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_bound1}-@var{upper_bound1}
|
||||||
tuples which sets the lower and the upper bound of each debug
|
[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
|
||||||
counter @var{name}. The @var{lower_bound} is optional and is zero
|
the name of the counter and list of closed intervals.
|
||||||
|
The @var{lower_bound} is optional and is zero
|
||||||
initialized if not set.
|
initialized if not set.
|
||||||
All debug counters have the initial upper bound of @code{UINT_MAX};
|
For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
|
||||||
thus @code{dbg_cnt} returns true always unless the upper bound
|
@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
|
||||||
is set by this option.
|
eleventh invocation.
|
||||||
For example, with @option{-fdbg-cnt=dce:2:4,tail_call:10},
|
|
||||||
@code{dbg_cnt(dce)} returns true only for third and fourth invocation.
|
|
||||||
For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
|
For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
|
||||||
|
|
||||||
@item -print-file-name=@var{library}
|
@item -print-file-name=@var{library}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2019-11-13 Martin Liska <mliska@suse.cz>
|
||||||
|
|
||||||
|
* gcc.dg/ipa/ipa-icf-39.c: Update -fdbg-cnt to the new format.
|
||||||
|
* gcc.dg/pr68766.c: Likewise.
|
||||||
|
|
||||||
2019-11-13 Jan Hubicka <hubicka@ucw.cz>
|
2019-11-13 Jan Hubicka <hubicka@ucw.cz>
|
||||||
|
|
||||||
* gcc.c-torture/compile/flatten.c: New testcase.
|
* gcc.c-torture/compile/flatten.c: New testcase.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-require-alias "" } */
|
/* { dg-require-alias "" } */
|
||||||
/* { dg-options "-O2 -fdump-ipa-icf-optimized -fmerge-all-constants -fdbg-cnt=merged_ipa_icf:1:3" } */
|
/* { dg-options "-O2 -fdump-ipa-icf-optimized -fmerge-all-constants -fdbg-cnt=merged_ipa_icf:1-2" } */
|
||||||
/* { dg-prune-output "dbg_cnt 'merged_ipa_icf' set to 1-3" } */
|
|
||||||
/* { dg-prune-output "\\*\\*\\*dbgcnt:.*limit.*reached" } */
|
/* { dg-prune-output "\\*\\*\\*dbgcnt:.*limit.*reached" } */
|
||||||
|
|
||||||
static int a;
|
static int a;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -ftree-vectorize -fdbg-cnt=vect_loop:1" } */
|
/* { dg-options "-O2 -ftree-vectorize -fdbg-cnt=vect_loop:1" } */
|
||||||
/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */
|
/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */
|
||||||
/* { dg-prune-output "dbg_cnt 'vect_loop' set to 0-1" } */
|
|
||||||
/* { dg-prune-output "\\*\\*\\*dbgcnt:.*limit.*reached" } */
|
/* { dg-prune-output "\\*\\*\\*dbgcnt:.*limit.*reached" } */
|
||||||
|
|
||||||
int a, b, g, h;
|
int a, b, g, h;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user