public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Dmitry Vyukov via gcc-patches" <gcc-patches@gcc.gnu.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "吴潍浠(此彼)" <weixi.wwx@antfin.com>, gcc <gcc@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	"Jeff Law" <law@redhat.com>, wishwu007 <wishwu007@gmail.com>
Subject: Re: Add support to trace comparison instructions and switch statements
Date: Sun, 03 Sep 2017 10:19:00 -0000	[thread overview]
Message-ID: <CACT4Y+bf3CT3T1uh+B8hUORtheX+owUPha7+Cme++PP3B=9wQA@mail.gmail.com> (raw)
In-Reply-To: <20170903100121.GU2323@tucnak>

On Sun, Sep 3, 2017 at 12:01 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sun, Sep 03, 2017 at 10:50:16AM +0200, Dmitry Vyukov wrote:
>> What we instrument in LLVM is _comparisons_ rather than control
>> structures. So that would be:
>>     _4 = x_8(D) == 98;
>> For example, result of the comparison can be stored into a bool struct
>> field, and then used in branching long time after. We still want to
>> intercept this comparison.
>
> Then we need to instrument not just GIMPLE_COND, which is the stmt
> where the comparison decides to which of the two basic block successors to
> jump, but also GIMPLE_ASSIGN with tcc_comparison class
> gimple_assign_rhs_code (the comparison above), and maybe also
> GIMPLE_ASSIGN with COND_EXPR comparison code (that is say
>   _4 = x_1 == y_2 ? 23 : _3;
> ).
>
>> > Perhaps for -fsanitize-coverage= it might be a good idea to force
>> > LOGICAL_OP_NON_SHORT_CIRCUIT/BRANCH_COST or whatever affects GIMPLE
>> > decisions mentioned above so that the IL is closer to what the user wrote.
>>
>> If we recurse down to comparison operations and instrument them, this
>> will not be so important, right?
>
> Well, if you just handle tcc_comparison GIMPLE_ASSIGN and not GIMPLE_COND,
> then you don't handle many comparisons from the source code.  And if you
> handle both, some of the GIMPLE_CONDs might be just artificial comparisons.
> By pretending small branch cost for the tracing case you get fewer
> artificial comparisons.


Are these artificial comparisons on BOOLEAN_TYPE? I think BOOLEAN_TYPE
needs to be ignored entirely, there is just like 2 combinations of
possible values.
If not, then what it is? Is it a dup of previous comparisons?

I am not saying these modes should not be enabled. You know much
better. I just wanted to point that that integer comparisons is what
we should be handling.

Your example:

  _1 = x_8(D) == 21;
  _2 = x_8(D) == 64;
  _3 = _1 | _2;
  if (_3 != 0)

raises another point. Most likely we don't want to see speculative
comparisons. At least not yet (we will see them once we get through
the first comparison). So that may be another reason to enable these
modes (make compiler stick closer to original code).

  reply	other threads:[~2017-09-03 10:19 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 12:08 吴潍浠(此彼)
2017-07-11 12:00 ` Wish Wu
2017-07-13  8:10   ` Dmitry Vyukov via gcc-patches
2017-07-13 10:04     ` Wish Wu
2017-07-13 10:41       ` Wish Wu
2017-07-13 10:47         ` Dmitry Vyukov via gcc-patches
     [not found]     ` <CAN=P9pj-PUHS_UWU8cS5VLNuJrL3LSq8Wj3G+G7cr-kCNV_4jQ@mail.gmail.com>
2017-07-14 12:23       ` Dmitry Vyukov via gcc-patches
2017-07-14 21:17         ` Kostya Serebryany via gcc-patches
2017-07-15  5:41           ` Dmitry Vyukov via gcc-patches
2017-07-15  7:22           ` 吴潍浠(此彼)
2017-07-15  7:43             ` Dmitry Vyukov via gcc-patches
2017-07-14  7:37 ` Jeff Law
2017-07-21  5:38 ` 吴潍浠(此彼)
2017-07-21 13:14   ` David Edelsohn
2017-09-01 16:23   ` Jakub Jelinek
2017-09-03  8:50     ` Dmitry Vyukov via gcc-patches
2017-09-03 10:01       ` Jakub Jelinek
2017-09-03 10:19         ` Dmitry Vyukov via gcc-patches [this message]
2017-09-03 10:21           ` Dmitry Vyukov via gcc-patches
2017-09-03 10:38           ` 吴潍浠(此彼)
2017-09-03 11:05             ` Dmitry Vyukov via gcc-patches
2017-09-04 13:17             ` 吴潍浠(此彼)
2017-09-04 13:37             ` 吴潍浠(此彼)
2017-09-04 17:34               ` Jakub Jelinek
2017-09-05 13:04               ` 吴潍浠(此彼)
2017-09-05 21:44                 ` Jakub Jelinek
2017-09-06 11:47                 ` 吴潍浠(此彼)
2017-09-06 14:37                   ` Jakub Jelinek
2017-09-06 14:38                     ` Jakub Jelinek
2017-09-07  7:02                   ` 吴潍浠(此彼)
2017-09-12 14:33                     ` Dmitry Vyukov via gcc-patches
2017-09-12 14:50                       ` Dmitry Vyukov via gcc-patches
2017-09-12 16:35                       ` Kostya Serebryany via gcc-patches
     [not found]                         ` <DB6PR0802MB23094E428EAB2B1D9206B8C3FF600@DB6PR0802MB2309.eurprd08.prod.outlook.com>
2017-09-19 13:14                           ` Tamar Christina
2017-09-19 13:31                             ` Martin Liška
2017-09-19 13:41                               ` Tamar Christina
2017-08-05  9:53 ` 吴潍浠(此彼)
2017-08-30 22:36   ` Dmitry Vyukov via gcc-patches
2017-09-06 20:08 David Edelsohn
2017-09-06 21:24 ` Jakub Jelinek
2017-09-07 16:58   ` Rainer Orth
2017-09-07 20:17     ` David Edelsohn
2017-09-08  8:38       ` Rainer Orth

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='CACT4Y+bf3CT3T1uh+B8hUORtheX+owUPha7+Cme++PP3B=9wQA@mail.gmail.com' \
    --to=gcc-patches@gcc.gnu.org \
    --cc=dvyukov@google.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=law@redhat.com \
    --cc=weixi.wwx@antfin.com \
    --cc=wishwu007@gmail.com \
    /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).