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 <kartiksing...@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/