[PATCH] Support lower and upper limit for -fdbg-cnt flag.
Martin Liška
mliska@suse.cz
Wed May 16 13:37:00 GMT 2018
On 05/16/2018 02:56 PM, Alexander Monakov wrote:
> On Wed, 16 May 2018, Martin Liška wrote:
>>> I recall Jakub recently applied a tree-wide change of A < B && B < C to read
>>> B > A && B < C.
>>
>> Can you please point to a revision where it was done?
>
> It is SVN r255831, mailing list thread here ("Replace Yoda conditions"):
> https://gcc.gnu.org/ml/gcc-patches/2017-12/msg01257.html
Thanks, fix according to that.
>
> In your revised patch:
>
>> --- a/gcc/dbgcnt.c
>> +++ b/gcc/dbgcnt.c
>> @@ -41,53 +41,90 @@ static struct string2counter_map map[debug_counter_number_of_counters] =
>> #undef DEBUG_COUNTER
>>
>> #define DEBUG_COUNTER(a) UINT_MAX,
>> -static unsigned int limit[debug_counter_number_of_counters] =
>> +static unsigned int limit_high[debug_counter_number_of_counters] =
>> {
>> #include "dbgcnt.def"
>> };
>> #undef DEBUG_COUNTER
>>
>> +#define DEBUG_COUNTER(a) 0,
>> +static unsigned int limit_low[debug_counter_number_of_counters] =
>> +{
>> +#include "dbgcnt.def"
>> +};
>> +#undef DEBUG_COUNTER
>
> No need to spell out the all-zeros initializer of a static object:
>
> static unsigned int limit_low[debug_counter_number_of_counters];
Got it.
>
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -14326,14 +14326,17 @@ 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 upper bound. @var{counter-value-list}
>> -is a comma-separated list of @var{name}:@var{value} pairs
>> -which sets the upper bound of each debug counter @var{name} to @var{value}.
>> +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}
>> +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.
>> 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.
>> -For example, with @option{-fdbg-cnt=dce:10,tail_call:0},
>> -@code{dbg_cnt(dce)} returns true only for first 10 invocations.
>> +For example, with @option{-fdbg-cnt=dce:9:10,tail_call:10},
>> +@code{dbg_cnt(dce)} returns true only for 10th and 11th invocation.
>> +For @code{dbg_cnt(tail_call)} true is returned for first 11 invocations.
>
> Hm, is the off-by-one in the new explanatory text really intended? I think
> the previous text was accurate, and the new text should say "9th and 10th"
> and then "first 10 invocations", unless I'm missing something?
I've reconsidered that once more time and having zero-based values:
* -fdbg-cnt=event:N - trigger event N-times
* -fdbg-cnt=event:N:(N+M) - skip even N-times and then enable it M-1 times
Does that make sense?
Martin
>
> Alexander
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Support-lower-and-upper-limit-for-fdbg-cnt-flag.patch
Type: text/x-patch
Size: 10417 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180516/17d747bf/attachment.bin>
More information about the Gcc-patches
mailing list