Re: Finding a relevant place for a custom GCC pass

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux