public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Alexander Monakov <amonakov@ispras.ru>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] gcc_qsort: source code changes
Date: Thu, 10 May 2018 17:01:00 -0000	[thread overview]
Message-ID: <1525971667.2961.61.camel@redhat.com> (raw)
In-Reply-To: <20180510155641.2950-2-amonakov@ispras.ru>

On Thu, 2018-05-10 at 18:56 +0300, Alexander Monakov wrote:
> 	* sort.cc: New file.
>         * system.h [!CHECKING_P] (qsort): Redirect to gcc_qsort.
>         * vec.c (qsort_chk): Use gcc_qsort.

[...snip...]

I'm not a reviewer for this, but there's a lot of fiddly implementation
logic here, so maybe this code could use the selftest framework?

Maybe, in pseudo-code, something like this:

template <typename T>
static void
test_gcc_sort ()
{
   for (creation_strategy in {in-order, backwards}: // and anything else?
     for (int n = 0; n < some_limit; n++)
       {
          make_a_list_of_t (n, creation_strategy)
          gcc_sort (the_list);
          assert that the list is sorted;
	  assert that the number of calls to the callback was sane
     }
}

void
test_gcc_sort_cc ()
{
   test_gcc_sort<int, int_comparator> ();
   test_gcc_sort<long, long_comparator> ();
   // etc; maybe some custom structs to exercise the deterministic property???
}

...or some such, to quickly get coverage of the various list sizes
(which the implementation seems to rely on heavily), in a non-release
build.



Hope this is constructive
Dave

  reply	other threads:[~2018-05-10 17:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 15:57 [PATCH 0/2] Introduce gcc_qsort Alexander Monakov
2018-05-10 15:57 ` [PATCH 2/2] gcc_qsort: build system changes Alexander Monakov
2018-05-11  9:32   ` Richard Biener
2018-05-10 17:01 ` [PATCH 1/2] gcc_qsort: source code changes Alexander Monakov
2018-05-10 17:01   ` David Malcolm [this message]
2018-05-10 17:44   ` Richard Biener
2018-05-10 18:08     ` Alexander Monakov
2018-05-10 18:57       ` DJ Delorie
2018-05-11 12:03   ` Richard Biener
2018-05-11 13:12     ` Alexander Monakov
2018-05-13 23:56   ` H.J. Lu
2018-05-14  8:44     ` Alexander Monakov
2018-05-14  9:08       ` Richard Biener
2018-05-10 17:35 ` [PATCH 0/2] Introduce gcc_qsort Jakub Jelinek
2018-05-10 17:48   ` Alexander Monakov
2018-05-10 17:43 ` Richard Biener
2018-05-10 17:57   ` Alexander Monakov
2018-05-11 10:35   ` Segher Boessenkool
2018-05-11 10:44     ` Alexander Monakov
2018-05-11 12:00       ` Segher Boessenkool
2018-05-11 12:16         ` Alexander Monakov
2018-05-11 12:52           ` Segher Boessenkool
2018-05-11 16:54           ` Eric Botcazou
2018-05-11 11:17     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1525971667.2961.61.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).