This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Correct way to access predecessors of a gimple statement?
- From: Sudakshina Das <sudakshina1990 at gmail dot com>
- To: Kartik Singhal <kartiksinghal at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sun, 5 May 2013 12:39:54 +0530
- Subject: Re: Correct way to access predecessors of a gimple statement?
- References: <CAAY3Td6SRR0AoU1xcCzvxq6LYjYp6eL2_0TGODmrh7skKA=xxw at mail dot gmail dot com>
Hello Kartik
You can use the iterator FOR_EACH_EDGE in this form:
FOR_EACH_EDGE (e, ei, bb->preds)
where e is an edge ei is edge iterator bb is a basic block.
I hope that gave you what you were looking for.
Sudakshina Das
On Sun, May 5, 2013 at 10:05 AM, Kartik Singhal <kartiksinghal@gmail.com> wrote:
>
> Hi
>
> I am trying to implement a GVN algorithm as a plugin for GCC 4.6.
>
> With help from GCC IRC channel, internals doc and reading the source,
> I was able to get a prototype working for the case of a single block.
>
> Now, I am trying to handle the case of confluence of multiple edges
> i.e. obtain redundancy information from multiple paths at a merge
> point. I am stuck trying to figure out how to access all the immediate
> predecessors of a statement. I have looked into CFG chapter of
> internals doc (block and edge), though edge data structure seems to
> give a hint, I couldn't clearly find out how to leverage it for my
> purpose. Any hints or code example would be a great help.
>
> If it is of any help, the algorithm is at [1] and my code at [2]
> (*very* naive and not considering performance at all in the first
> implementation attempt).
>
> [1]: http://arxiv.org/abs/1303.1880
> [2]: https://github.com/k4rtik/btp-gvn/blob/master/gvn-plugin/plugin.c
>
> Thanks
> --
> Kartik
> http://k4rtik.wordpress.com/