redirect_edge_and_branch questions

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Wed Oct 6 03:46:00 GMT 2004


Hello,

> I am using the edge->aux field to store a pointer to an edge. Its for a
> very short period, and then I clear it. So when I'm done, the field is
> NULL again.  Can I do that OK?  I presume it is OK since edges are GC'd
> (right?), and the aux pointer is declared
>   PTR GTY((skip(""))) aux;

due to "skip" you should have no problem regardless of how the think
stored in aux is allocated, as long as you do not expect the pointer
from aux field to keep it alive (gc simply ignores such fields).
Anyway, keeping something in aux field for so long time that garbage
collection would be needed would be a very bad idea.

> So is it kosher to do this? I don't want to actually allocate aux
> fields, since I only ever need to temporarily store an edge pointer
> while examining a basic block's incoming edge. I then do a couple of
> redirects. Then they are cleared.
> 
> Is this OK, or is it bad Karma?

This should be OK (at least from the point of view of gc).  You need to
be a small bit careful, since some other functions may use them already (so
for example running verify_cfg or verify_ssa while you use the aux field
would not be a good idea, IIRC), but from what you describe you should
not have a problem with this.

Zdenek



More information about the Gcc mailing list