public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* IPA and LTO
@ 2011-07-13 13:47 AJM-2
  0 siblings, 0 replies; 8+ messages in thread
From: AJM-2 @ 2011-07-13 13:47 UTC (permalink / raw)
  To: gcc


Hello,

I have written a simple ipa pass and would like to make use of Link time
optimisation.  My pass requires access to the function bodies and ideally I
would like the driver function to be called once at link time and have
access to functions in all of the files as if they were one compilation
unit.  The documentation would indicate that this is possible, but ad hoc
instrumentation of some of the other simple ipa passes seems to suggest
different behaviour.

My question is whether LTO can be used in this way, to have a simple ipa
pass called once at link time with access to the function bodies, and if so
how is this achieved?  cgraph_function_body_availability seems to only be
half the story.

I am using GCC 4.6.0 with the gold linker plugin (binutils 2.21).

Andrew
-- 
View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052768p32052768.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

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

* Re: IPA and LTO
  2011-07-13 20:40       ` AJM-2
@ 2011-07-13 22:43         ` Richard Guenther
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Guenther @ 2011-07-13 22:43 UTC (permalink / raw)
  To: AJM-2; +Cc: gcc

On Wed, Jul 13, 2011 at 10:09 PM, AJM-2 <mcpherson.aj@gmail.com> wrote:
>
> Putting my "simple IPA pass" adjacent to IPA-PTA does cause it to be called
> as expected.  However for each node in the call graph (with
> cgraph_function_body_availability returning AVAIL_AVAILABLE),
> gimple_has_body_p is always false.
>
> The call graph data seems to be available, but the documentation indicates
> that access to the gimple is also possible, using the standard accessors.
> Is there some extra step that must be taken to access gimple under LTO?

The body should be available.  Make sure to use a recent SVN trunk though.

Richard.

>
>
> Richard Guenther-2 wrote:
>>
>> It depends on where in the pass pipeline you put your IPA pass.  A simple
>> IPA pass that should run at ltrans time (either seeing each partition for
>> the partitioned program or the whole program if you use one partition)
>> needs to be put alongside IPA PTA (that's the only simple IPA pass
>> executed
>> at link LTO time right now).
>>
>> Richard.
>>
>>
>
> --
> View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052838p32056682.html
> Sent from the gcc - Dev mailing list archive at Nabble.com.
>
>

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

* Re: IPA and LTO
  2011-07-13 20:10     ` Richard Guenther
@ 2011-07-13 20:40       ` AJM-2
  2011-07-13 22:43         ` Richard Guenther
  0 siblings, 1 reply; 8+ messages in thread
From: AJM-2 @ 2011-07-13 20:40 UTC (permalink / raw)
  To: gcc


Putting my "simple IPA pass" adjacent to IPA-PTA does cause it to be called
as expected.  However for each node in the call graph (with
cgraph_function_body_availability returning AVAIL_AVAILABLE),
gimple_has_body_p is always false.

The call graph data seems to be available, but the documentation indicates
that access to the gimple is also possible, using the standard accessors. 
Is there some extra step that must be taken to access gimple under LTO?



Richard Guenther-2 wrote:
> 
> It depends on where in the pass pipeline you put your IPA pass.  A simple
> IPA pass that should run at ltrans time (either seeing each partition for
> the partitioned program or the whole program if you use one partition)
> needs to be put alongside IPA PTA (that's the only simple IPA pass
> executed
> at link LTO time right now).
> 
> Richard.
> 
> 

-- 
View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052838p32056682.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

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

* Re: IPA and LTO
  2011-07-13 16:23   ` AJM-2
  2011-07-13 16:35     ` Pierre Vittet
@ 2011-07-13 20:10     ` Richard Guenther
  2011-07-13 20:40       ` AJM-2
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Guenther @ 2011-07-13 20:10 UTC (permalink / raw)
  To: AJM-2; +Cc: gcc

On Wed, Jul 13, 2011 at 5:54 PM, AJM-2 <mcpherson.aj@gmail.com> wrote:
>
> What you say is in line with my understanding, however when I instrument the
> execute function of ipa-function-and-variable-visibility
> (local_function_and_variable_visibility()) I note that:
>
> gcc -flto a.c b.c
> causes the pass to be called twice (presumably once per file).
>
> If I split the compilation into two stages, then in the link stage
> gcc -flto a.o b.o
> the pass is never called.
>
> Conversely, the gate of IPA-Points-to does seem to be called three times at
> link time (presumably once for each file and then once for all together).  I
> cannot discover the cause of the different behaviours here.

It depends on where in the pass pipeline you put your IPA pass.  A simple
IPA pass that should run at ltrans time (either seeing each partition for
the partitioned program or the whole program if you use one partition)
needs to be put alongside IPA PTA (that's the only simple IPA pass executed
at link LTO time right now).

Richard.

>
> Diego Novillo-3 wrote:
>>
>> On Wed, Jul 13, 2011 at 10:22, AJM-2 <mcpherson.aj@gmail.com> wrote:
>>
>>> My question is whether LTO can be used in this way, to have a simple ipa
>>> pass called once at link time with access to the function bodies, and if
>>> so
>>> how is this achieved?  cgraph_function_body_availability seems to only be
>>> half the story.
>>
>> Yes, it can.  You seem to be describing what GCC calls "simple IPA
>> pass".  These are passes that cannot run in partitioned LTO mode, as
>> they require the function bodies to operate.  Look for passes like
>> pass_ipa_function_and_variable_visibility for an example of a simple
>> IPA pass.
>>
>>
>> Diego.
>>
>>
>
> --
> View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052838p32054720.html
> Sent from the gcc - Dev mailing list archive at Nabble.com.
>
>

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

* Re: IPA and LTO
  2011-07-13 16:23   ` AJM-2
@ 2011-07-13 16:35     ` Pierre Vittet
  2011-07-13 20:10     ` Richard Guenther
  1 sibling, 0 replies; 8+ messages in thread
From: Pierre Vittet @ 2011-07-13 16:35 UTC (permalink / raw)
  To: gcc, mcpherson.aj

Hello,

If local_function_and_variable_visibility was not a simple IPA pass it 
would not have been called once per file but once per function (as it is 
with GIMPLE pass).
I feel this is normal that this pass is run 2 times because it is run 
before any link operations.

However, I don't know exactly how and when ld is called and which passes 
run after this.

Pierre Vittet

On 13/07/2011 17:54, AJM-2 wrote:
>
> What you say is in line with my understanding, however when I instrument the
> execute function of ipa-function-and-variable-visibility
> (local_function_and_variable_visibility()) I note that:
>
> gcc -flto a.c b.c
> causes the pass to be called twice (presumably once per file).
>
> If I split the compilation into two stages, then in the link stage
> gcc -flto a.o b.o
> the pass is never called.
>
> Conversely, the gate of IPA-Points-to does seem to be called three times at
> link time (presumably once for each file and then once for all together).  I
> cannot discover the cause of the different behaviours here.
>

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

* Re: IPA and LTO
  2011-07-13 15:55 ` Diego Novillo
@ 2011-07-13 16:23   ` AJM-2
  2011-07-13 16:35     ` Pierre Vittet
  2011-07-13 20:10     ` Richard Guenther
  0 siblings, 2 replies; 8+ messages in thread
From: AJM-2 @ 2011-07-13 16:23 UTC (permalink / raw)
  To: gcc


What you say is in line with my understanding, however when I instrument the
execute function of ipa-function-and-variable-visibility
(local_function_and_variable_visibility()) I note that:

gcc -flto a.c b.c
causes the pass to be called twice (presumably once per file).

If I split the compilation into two stages, then in the link stage
gcc -flto a.o b.o
the pass is never called.

Conversely, the gate of IPA-Points-to does seem to be called three times at
link time (presumably once for each file and then once for all together).  I
cannot discover the cause of the different behaviours here.


Diego Novillo-3 wrote:
> 
> On Wed, Jul 13, 2011 at 10:22, AJM-2 <mcpherson.aj@gmail.com> wrote:
> 
>> My question is whether LTO can be used in this way, to have a simple ipa
>> pass called once at link time with access to the function bodies, and if
>> so
>> how is this achieved?  cgraph_function_body_availability seems to only be
>> half the story.
> 
> Yes, it can.  You seem to be describing what GCC calls "simple IPA
> pass".  These are passes that cannot run in partitioned LTO mode, as
> they require the function bodies to operate.  Look for passes like
> pass_ipa_function_and_variable_visibility for an example of a simple
> IPA pass.
> 
> 
> Diego.
> 
> 

-- 
View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052838p32054720.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

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

* Re: IPA and LTO
  2011-07-13 14:56 AJM-2
@ 2011-07-13 15:55 ` Diego Novillo
  2011-07-13 16:23   ` AJM-2
  0 siblings, 1 reply; 8+ messages in thread
From: Diego Novillo @ 2011-07-13 15:55 UTC (permalink / raw)
  To: AJM-2; +Cc: gcc

On Wed, Jul 13, 2011 at 10:22, AJM-2 <mcpherson.aj@gmail.com> wrote:

> My question is whether LTO can be used in this way, to have a simple ipa
> pass called once at link time with access to the function bodies, and if so
> how is this achieved?  cgraph_function_body_availability seems to only be
> half the story.

Yes, it can.  You seem to be describing what GCC calls "simple IPA
pass".  These are passes that cannot run in partitioned LTO mode, as
they require the function bodies to operate.  Look for passes like
pass_ipa_function_and_variable_visibility for an example of a simple
IPA pass.


Diego.

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

* IPA and LTO
@ 2011-07-13 14:56 AJM-2
  2011-07-13 15:55 ` Diego Novillo
  0 siblings, 1 reply; 8+ messages in thread
From: AJM-2 @ 2011-07-13 14:56 UTC (permalink / raw)
  To: gcc


Hello,

I have written a simple ipa pass and would like to make use of Link time
optimisation.  My pass requires access to the function bodies and ideally I
would like the driver function to be called once at link time and have
access to functions in all of the files as if they were one compilation
unit.  The documentation would indicate that this is possible, but ad hoc
instrumentation of some of the other simple ipa passes seems to suggest
different behaviour.

My question is whether LTO can be used in this way, to have a simple ipa
pass called once at link time with access to the function bodies, and if so
how is this achieved?  cgraph_function_body_availability seems to only be
half the story.

I am using GCC 4.6.0 with the gold linker plugin (binutils 2.21).

Andrew

-- 
View this message in context: http://old.nabble.com/IPA-and-LTO-tp32052838p32052838.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

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

end of thread, other threads:[~2011-07-13 20:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 13:47 IPA and LTO AJM-2
2011-07-13 14:56 AJM-2
2011-07-13 15:55 ` Diego Novillo
2011-07-13 16:23   ` AJM-2
2011-07-13 16:35     ` Pierre Vittet
2011-07-13 20:10     ` Richard Guenther
2011-07-13 20:40       ` AJM-2
2011-07-13 22:43         ` Richard Guenther

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).