Re: Add support to trace comparison instructions and switch statements

2017-09-01 Thread Jakub Jelinek
On Fri, Jul 21, 2017 at 01:38:17PM +0800, 吴潍浠(此彼) wrote:
> Hi Jeff
> 
> I have signed the copyright assignment, and used the name 'Wish Wu' .
> Should I send you a copy of my assignment ?
> 
> The attachment is my new patch with small changes. 
> Codes are checked by ./contrib/check_GNU_style.sh, except some special files.

Please provide a ChangeLog entry, you can use ./contrib/mklog as a start.

@@ -975,6 +974,10 @@ fsanitize=
 Common Driver Report Joined
 Select what to sanitize.
 
+fsanitize-coverage=
+Common Driver Report Joined
+Select what to coverage sanitize.
+

Why Driver?  The reason fsanitize= needs it is that say for
-fsanitize=address we add libraries in the driver, etc., but that
isn't the case for the coverage, right?

--- gcc/flag-types.h(revision 250199)
+++ gcc/flag-types.h(working copy)
@@ -250,6 +250,14 @@ enum sanitize_code {
  | SANITIZE_BOUNDS_STRICT
 };
 
+/* Different trace modes.  */
+enum sanitize_coverage_code {
+  /* Trace PC.  */
+  SANITIZE_COV_TRACE_PC = 1UL << 0,
+  /* Trace Compare.  */
+  SANITIZE_COV_TRACE_CMP = 1UL << 1
+};

No need for UL suffixes, the reason sanitize_code uses them is
that it includes 1 << 16 and above and might be included even in target code
(for host we require 32-bit integers, for target code it might be just
16-bit).

--- gcc/opts.c  (revision 250199)
+++ gcc/opts.c  (working copy)
@@ -1519,6 +1519,17 @@ const struct sanitizer_opts_s sanitizer_opts[] =
   { NULL, 0U, 0UL, false }
 };
 
+/* -f{,no-}sanitize-coverage= suboptions.  */
+const struct sanitizer_opts_s coverage_sanitizer_opts[] =
+{
+#define SANITIZER_OPT(name, flags, recover) \
+{ #name, flags, sizeof #name - 1, recover }
+  SANITIZER_OPT (trace-pc, SANITIZE_COV_TRACE_PC, false),
+  SANITIZER_OPT (trace-cmp, SANITIZE_COV_TRACE_CMP, false),
+#undef SANITIZER_OPT
+  { NULL, 0U, 0UL, false }

No need to have the recover argument for the macro, just add false to it
(unless you want to use a different struct type that wouldn't even include
that member).

+/* Given ARG, an unrecognized coverage sanitizer option, return the best
+   matching coverage sanitizer option, or NULL if there isn't one.  */
+
+static const char *
+get_closest_coverage_sanitizer_option (const string_fragment &arg)
+{
+  best_match  bm (arg);
+  for (int i = 0; coverage_sanitizer_opts[i].name != NULL; ++i)
+{
+  bm.consider (coverage_sanitizer_opts[i].name);
+}

Body which contains just one line shouldn't be wrapped in {}s, just use
  for (int i = 0; coverage_sanitizer_opts[i].name != NULL; ++i)
bm.consider (coverage_sanitizer_opts[i].name);

+unsigned int
+parse_coverage_sanitizer_options (const char *p, location_t loc,
+unsigned int flags, int value, bool complain)

Wrong formatting, unsigned int should go below const char *, like:

parse_coverage_sanitizer_options (const char *p, location_t loc,
  unsigned int flags, int value, bool complain)

+{
+  while (*p != 0)
+{
+  size_t len, i;
+  bool found = false;
+  const char *comma = strchr (p, ',');
+
+  if (comma == NULL)
+   len = strlen (p);
+  else
+   len = comma - p;
+  if (len == 0)
+   {
+ p = comma + 1;
+ continue;
+   }
+
+  /* Check to see if the string matches an option class name.  */
+  for (i = 0; coverage_sanitizer_opts[i].name != NULL; ++i)
+   if (len == coverage_sanitizer_opts[i].len
+   && memcmp (p, coverage_sanitizer_opts[i].name, len) == 0)
+ {
+   if (value)
+ flags |= coverage_sanitizer_opts[i].flag;
+   else
+ flags &= ~coverage_sanitizer_opts[i].flag;
+   found = true;
+   break;
+ }
+
+  if (! found && complain)
+   {
+ const char *hint
+   = get_closest_coverage_sanitizer_option (string_fragment (p, len));
+
+ if (hint)
+   error_at (loc,
+ "unrecognized argument to "
+ "-f%ssanitize-coverage= option: %q.*s;"
+ " did you mean %qs?",
+ value ? "" : "no-",
+ (int) len, p, hint);
+ else
+   error_at (loc,
+ "unrecognized argument to "
+ "-f%ssanitize-coverage= option: %q.*s",
+ value ? "" : "no-",
+ (int) len, p);
+   }
+
+  if (comma == NULL)
+   break;
+  p = comma + 1;
+}
+  return flags;
+}

Though, looking at the above, it sounds like there is just way too much
duplication.  So, maybe better just use the parse_sanitizer_options
and get_closest_coverage_option functions for all of
-f{,no-}sanitize{,-recover,-coverage}= , add
  const struct sanitizer_opts_s *opts = sanitizer_opts;
  if (code == OPT_fsanitize_coverage_)
opts = coverage_sanitizer_opts;
early in both functions, deal with the diagnostics (to print "-coverage

Re: RFC [testsuite] Obey --load-average

2017-09-01 Thread Jeff Law
On 08/06/2017 05:05 PM, Daniel Santos wrote:
> On 08/03/2017 11:45 AM, Jeff Law wrote:
>> On 08/02/2017 11:34 PM, Daniel Santos wrote:
>> So does this perform better than make -j X -l X?  I use that with good
>> success.
>>
>> jeff
> 
> Sorry for my slow response!
> 
> For a short answer, if you have 8 CPU cores and you run make -j8 -l8
> check then everything is fine until cron needs to do something that eats
> 4 CPUs and you end up with a load average of 12.  This is because the
> make jobs of the test harness are very long running and make's only
> control lever for regulating load is to not start new jobs until the
> load falls.  So if all jobs are already launched, make has no way of
> reducing the load until all tests on that test set have completed.
That's not something I typically see in practice.  On my local machine
I'm not usually awake when cron jobs are running, so if the load spikes
due to over-subscription I don't much care :-)

The case that is of most interest to me is the effects on shared servers
and folks that don't consistently use -l to throttle their jobs.  Your
patches would probably help in that situation by throttling parallelism
independent of the -l flags.

The second place where your stuff probably helps in a meaningful way is
over-subscription due to parallelism within the gomp testsuite.

I'll leave it to Mike who does most of the review work for the testing
infrastructure these days.  I won't objects on any philosophical grounds :-)

Jeff