How does one traverse all the global decls

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How does one traverse all the global decls

Gary Oblock
I'm trying to do some analysis code for an optimization
that involves my code looking at all the declarations and
types there of during the link time optimizations.

Note, doing this for the local variables seems to be trivial
because of FOR_EACH_LOCAL_DECL and there are also
obvious ways of getting at the type information once I have
a decl. However,  I can't seem to find any similar way of
getting at the global level decls.

I'd appreciate your help on this.

Thanks,

Gary Oblock
Reply | Threaded
Open this post in threaded view
|

Re: How does one traverse all the global decls

Martin Jambor-3
Hi,

On Wed, Aug 21 2019, Gary Oblock wrote:

> I'm trying to do some analysis code for an optimization
> that involves my code looking at all the declarations and
> types there of during the link time optimizations.
>
> Note, doing this for the local variables seems to be trivial
> because of FOR_EACH_LOCAL_DECL and there are also
> obvious ways of getting at the type information once I have
> a decl. However,  I can't seem to find any similar way of
> getting at the global level decls.
>
> I'd appreciate your help on this.
>

Look at FOR_EACH_VARIABLE defined in cgraph.h (because symtab.h does not
exist) and it's various uses throughout the compiler.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: How does one traverse all the global decls

Richard Biener-2
On Thu, Aug 22, 2019 at 11:16 AM Martin Jambor <[hidden email]> wrote:

>
> Hi,
>
> On Wed, Aug 21 2019, Gary Oblock wrote:
> > I'm trying to do some analysis code for an optimization
> > that involves my code looking at all the declarations and
> > types there of during the link time optimizations.
> >
> > Note, doing this for the local variables seems to be trivial
> > because of FOR_EACH_LOCAL_DECL and there are also
> > obvious ways of getting at the type information once I have
> > a decl. However,  I can't seem to find any similar way of
> > getting at the global level decls.
> >
> > I'd appreciate your help on this.
> >
>
> Look at FOR_EACH_VARIABLE defined in cgraph.h (because symtab.h does not
> exist) and it's various uses throughout the compiler.

There's also IPA-REFs so you can iterate over references of global
variables (not sure if there's a nice FOR_EACH interface for that).

Richard.

>
> Martin
Reply | Threaded
Open this post in threaded view
|

Re: [EXT] Re: How does one traverse all the global decls

Gary Oblock
In reply to this post by Martin Jambor-3
On 8/22/19 2:16 AM, Martin Jambor wrote:

> External Email
>
> ----------------------------------------------------------------------
> Hi,
>
> On Wed, Aug 21 2019, Gary Oblock wrote:
>> I'm trying to do some analysis code for an optimization
>> that involves my code looking at all the declarations and
>> types there of during the link time optimizations.
>>
>> Note, doing this for the local variables seems to be trivial
>> because of FOR_EACH_LOCAL_DECL and there are also
>> obvious ways of getting at the type information once I have
>> a decl. However,  I can't seem to find any similar way of
>> getting at the global level decls.
>>
>> I'd appreciate your help on this.
>>
> Look at FOR_EACH_VARIABLE defined in cgraph.h (because symtab.h does not
> exist) and it's various uses throughout the compiler.
>
> Martin
>
Martin --

Thanks, even though this wasn't exactly what I was hoping for. :-)

-- Gary