public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Live range information
@ 2011-05-10  7:32 Vijayaraghavan Murali
  2011-05-10  7:54 ` Dominik Psenner
  2011-05-10 14:28 ` Ian Lance Taylor
  0 siblings, 2 replies; 5+ messages in thread
From: Vijayaraghavan Murali @ 2011-05-10  7:32 UTC (permalink / raw)
  To: gcc-help


Hi,

I'm wondering if there is a way to make gcc dump variables' live range
information (using DWARF or otherwise). To be precise what I'm looking for
is something like: 'a' is live from line 3 to 10, 'b' is live from line 4 to
8, etc in some specified format. Is this possible in gcc?

Thanks!

-------------------------
Vijayaraghavan Murali
http://www.comp.nus.edu.sg/~mvijayar
-- 
View this message in context: http://old.nabble.com/Live-range-information-tp31583370p31583370.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Live range information
  2011-05-10  7:32 Live range information Vijayaraghavan Murali
@ 2011-05-10  7:54 ` Dominik Psenner
  2011-05-10  8:49   ` Vijayaraghavan Murali
  2011-05-10 14:28 ` Ian Lance Taylor
  1 sibling, 1 reply; 5+ messages in thread
From: Dominik Psenner @ 2011-05-10  7:54 UTC (permalink / raw)
  To: gcc-help

Hi

The scope of variables is well defined in the abstract syntax tree within
gcc. Thus after gcc has parsed the code, you should be able to easily
extract that information.

Greetings,
D.

> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
> Behalf Of Vijayaraghavan Murali
> Sent: Tuesday, May 10, 2011 9:33 AM
> To: gcc-help@gcc.gnu.org
> Subject: Live range information
> 
> 
> Hi,
> 
> I'm wondering if there is a way to make gcc dump variables' live range
> information (using DWARF or otherwise). To be precise what I'm looking for
> is something like: 'a' is live from line 3 to 10, 'b' is live from line 4
> to
> 8, etc in some specified format. Is this possible in gcc?
> 
> Thanks!
> 
> -------------------------
> Vijayaraghavan Murali
> http://www.comp.nus.edu.sg/~mvijayar
> --
> View this message in context: http://old.nabble.com/Live-range-
> information-tp31583370p31583370.html
> Sent from the gcc - Help mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Live range information
  2011-05-10  7:54 ` Dominik Psenner
@ 2011-05-10  8:49   ` Vijayaraghavan Murali
  2011-05-10 11:21     ` Dominik Psenner
  0 siblings, 1 reply; 5+ messages in thread
From: Vijayaraghavan Murali @ 2011-05-10  8:49 UTC (permalink / raw)
  To: gcc-help



Thanks for your quick reply. Maybe I should have worded my question better,
but I'm not looking for the scope of a variable but its live range. For eg,

main() {
<1>  int a, b, c, d;
<2>  b = a*2;
<3>  c = b+3;
<4>  d = c*b;
}

Here the scope of a is the entire function, but its live range is only till
2, because it's not used after that.

To restate my requirement to avoid confusion: for a program point, does gcc
provide the list of variables live at it?

Thanks!

-------------------------
Vijayaraghavan Murali
http://www.comp.nus.edu.sg/~mvijayar



Dominik Psenner wrote:
> 
> Hi
> 
> The scope of variables is well defined in the abstract syntax tree within
> gcc. Thus after gcc has parsed the code, you should be able to easily
> extract that information.
> 
> Greetings,
> D.
> 
>> -----Original Message-----
>> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
>> Behalf Of Vijayaraghavan Murali
>> Sent: Tuesday, May 10, 2011 9:33 AM
>> To: gcc-help@gcc.gnu.org
>> Subject: Live range information
>> 
>> 
>> Hi,
>> 
>> I'm wondering if there is a way to make gcc dump variables' live range
>> information (using DWARF or otherwise). To be precise what I'm looking
>> for
>> is something like: 'a' is live from line 3 to 10, 'b' is live from line 4
>> to
>> 8, etc in some specified format. Is this possible in gcc?
>> 
>> Thanks!
>> 
>> -------------------------
>> Vijayaraghavan Murali
>> http://www.comp.nus.edu.sg/~mvijayar
>> --
>> View this message in context: http://old.nabble.com/Live-range-
>> information-tp31583370p31583370.html
>> Sent from the gcc - Help mailing list archive at Nabble.com.
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Live-range-information-tp31583370p31583805.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Live range information
  2011-05-10  8:49   ` Vijayaraghavan Murali
@ 2011-05-10 11:21     ` Dominik Psenner
  0 siblings, 0 replies; 5+ messages in thread
From: Dominik Psenner @ 2011-05-10 11:21 UTC (permalink / raw)
  To: 'Vijayaraghavan Murali', gcc-help


> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
> Behalf Of Vijayaraghavan Murali
> Sent: Tuesday, May 10, 2011 10:49 AM
> To: gcc-help@gcc.gnu.org
> Subject: RE: Live range information
> 
> 
> 
> Thanks for your quick reply. Maybe I should have worded my question
> better,
> but I'm not looking for the scope of a variable but its live range. For
> eg,
> 
> main() {
> <1>  int a, b, c, d;
> <2>  b = a*2;
> <3>  c = b+3;
> <4>  d = c*b;
> }
> 
> Here the scope of a is the entire function, but its live range is only
> till
> 2, because it's not used after that.
> 
> To restate my requirement to avoid confusion: for a program point, does
> gcc
> provide the list of variables live at it?

Don't know for sure, but I would doubt that since finding that out equals a
breadth-first search across the AST for each variable and further I can't
imagine any use a optimizer could have for that information. Therefore it
would be a useless operation that only consumes time for nothing. Someone
correct me please if I'm wrong! :-)

Anyway I'm only familiar with compiler/optimizer theory and not with the gcc
implementation. If you feel to do so, you should peek at the sourcecode of
gcc to find out more.

> 
> Thanks!
> 
> -------------------------
> Vijayaraghavan Murali
> http://www.comp.nus.edu.sg/~mvijayar
> 
> 
> 
> Dominik Psenner wrote:
> >
> > Hi
> >
> > The scope of variables is well defined in the abstract syntax tree
> within
> > gcc. Thus after gcc has parsed the code, you should be able to easily
> > extract that information.
> >
> > Greetings,
> > D.
> >
> >> -----Original Message-----
> >> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
> >> Behalf Of Vijayaraghavan Murali
> >> Sent: Tuesday, May 10, 2011 9:33 AM
> >> To: gcc-help@gcc.gnu.org
> >> Subject: Live range information
> >>
> >>
> >> Hi,
> >>
> >> I'm wondering if there is a way to make gcc dump variables' live range
> >> information (using DWARF or otherwise). To be precise what I'm looking
> >> for
> >> is something like: 'a' is live from line 3 to 10, 'b' is live from line
> 4
> >> to
> >> 8, etc in some specified format. Is this possible in gcc?
> >>
> >> Thanks!
> >>
> >> -------------------------
> >> Vijayaraghavan Murali
> >> http://www.comp.nus.edu.sg/~mvijayar
> >> --
> >> View this message in context: http://old.nabble.com/Live-range-
> >> information-tp31583370p31583370.html
> >> Sent from the gcc - Help mailing list archive at Nabble.com.
> >
> >
> >
> >
> 
> --
> View this message in context: http://old.nabble.com/Live-range-
> information-tp31583370p31583805.html
> Sent from the gcc - Help mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Live range information
  2011-05-10  7:32 Live range information Vijayaraghavan Murali
  2011-05-10  7:54 ` Dominik Psenner
@ 2011-05-10 14:28 ` Ian Lance Taylor
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2011-05-10 14:28 UTC (permalink / raw)
  To: Vijayaraghavan Murali; +Cc: gcc-help

Vijayaraghavan Murali <vijayaraghavan2k5@gmail.com> writes:

> I'm wondering if there is a way to make gcc dump variables' live range
> information (using DWARF or otherwise). To be precise what I'm looking for
> is something like: 'a' is live from line 3 to 10, 'b' is live from line 4 to
> 8, etc in some specified format. Is this possible in gcc?

There is nothing so simple, no.  You could take a look at
-fdump-rtl-vartrack-details.  That file will only be generated if you
compile with -g -fvar-tracking.

The information is there if you modify the source code.  The file
gcc/var-tracking.c would be a good place to start.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-10 14:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-10  7:32 Live range information Vijayaraghavan Murali
2011-05-10  7:54 ` Dominik Psenner
2011-05-10  8:49   ` Vijayaraghavan Murali
2011-05-10 11:21     ` Dominik Psenner
2011-05-10 14:28 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).