public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Sandeep K Chaudhary <babbusandy2006@gmail.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>, gcc@gcc.gnu.org
Subject: Re: Finding a relevant place for a custom GCC pass
Date: Mon, 06 Jan 2014 06:24:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.10.1401060718110.3878@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <CAEEAEzXzV4XVd6kadrCFq45qi+vK1iKa_6Nu9XdkWNYL5+1+wA@mail.gmail.com>

On Sun, 5 Jan 2014, Sandeep K Chaudhary wrote:

> Hi guys,
>
> I want to write a pass which can find the calculations performed on
> the right hand side of each statement. In the below example -
>
>        VAR1 = 1;
>        VAR1++;
>        VAR1 = VAR1 + 5;
>
> I want to be able to capture the equivalent statements i.e.
>
> VAR1 = 1;
> VAR1 = 2;
> VAR1 = 7;
>
> To achieve this, I dumped various intermediate files using
> "-fdump-tree-all'. I looked at all of them manually and found that
> either the statements are non-evaluated (during initial stages) or
> they are completely optimized, hence losing the intermediate
> assignment calculations (during later stages). There is no pass which
> generates dumps related to the intermediate assignment calculations.
>
> I am not able to understand where I should aim to place my pass in
> order to achieve the above mentioned functionality. Initially, I had
> thought of writing IPA pass but I looked at 'copyprop' and 'forwprop'
> dumps and saw that everything is optimized to the last statement. I am
> not able to understand how a pass should be placed between GIMPLE
> stage and later stages so that intermediate calculations such as the
> ones mentioned above in the example, can be captured. Please provide
> suggestions and help regarding this.

Short answer: you can't.

You can either have your passe before ccp, and duplicate the functionality 
of ccp, or you can hack the ccp pass to insert your code in it, but I 
doubt there is a suitable plugin hook for that, so you may have to edit 
gcc's source code directly.

If you compile with -g and look at debug statements, the information is 
not completely lost after the pass that optimizes this to just VAR1 = 7, 
but it still wouldn't be convenient to use that for your purpose.

-- 
Marc Glisse

  reply	other threads:[~2014-01-06  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06  6:12 Sandeep K Chaudhary
2014-01-06  6:24 ` Marc Glisse [this message]
2014-01-06  6:47   ` Sandeep K Chaudhary
2014-01-06 12:20     ` Richard Biener

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=alpine.DEB.2.10.1401060718110.3878@laptop-mg.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=babbusandy2006@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gcc@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).