Re: LTO : question about get_untransformed_body

2019-12-06 Thread Richard Biener
On December 6, 2019 5:46:25 PM GMT+01:00, Erick Ochoa 
 wrote:
>
>
>On 2019-12-06 5:50 a.m., Richard Biener wrote:
>> On Wed, Dec 4, 2019 at 6:03 PM Erick Ochoa
>>  wrote:
>>>
>>>
>>>
>>> On 2019-12-04 7:52 a.m., Richard Biener wrote:
 On Tue, Dec 3, 2019 at 11:51 PM Erick Ochoa
  wrote:
>
> Hi,
>
> I am trying to use the function:
>`cgraph_node::get_untransformed_body` during
> the wpa stage of a SIMPLE_IPA_PASS transformation. While the
>execute function

 I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS
>time
 (WPA transform stage).  So you might simply see that not all bodies
>are
 available in your LTRANS unit?

>>>
>>> This makes a lot of sense, and it is indeed documented in the GCC
>internals
>>> manual:
>>>
>>>   A small inter-procedural pass (SIMPLE_IPA_PASS) is a pass that
>does
>>>   everything at once and thus it can not be executed during WPA in
>WHOPR
>>>   mode. It defines only the Execute stage and during this stage it
>>>   accesses and modifies the function bodies. Such passes are useful
>for
>>>   optimization at LGEN or LTRANS time and are used, for example, to
>>>   implement early optimization before writing object files.
>>>
>>> I got confused because the dump_file for my pass includes the
>substring 'wpa'.
>>> Should I file a bug to change the name of the dumpfile to something
>more like
>>> `ltrans*`?
>> 
>> Well, you probably placed your pass in the IPA pipeline rather than
>the
>> all_late_ipa_passes one?  In principle IPA passes _can_ pull in
>bodies
>> during WPA
>> analysis, that just will be very costly> 
>>> Thanks for your help!
>
>I am a bit confused.
>Can you please clarify:
>
>> I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
>> (WPA transform stage).
>
>I did have a SIMPLE_IPA_PASS and the dump file contained "wpa" in it.
>
>> Well, you probably placed your pass in the IPA pipeline rather than
>the
>> all_late_ipa_passes one?
>
>I did place my pass in the IPA pipeline rather than the
>all_late_ipa_passes
>one.
>
>Are SIMPLE_IPA_PASSes normally used in the all_late_ipa_passes which
>means they are normally scheduled to run at LTRANS time? However, if 
>I place my SIMPLE_IPA_PASS during the IPA pipeline, then my
>SIMPLE_IPA_PASS
>will execute at "WPA" stage?

Yes. 

>> In principle IPA passes _can_ pull in bodies
>> during WPA
>
>So, if SIMPLE_IPA_PASSes are placed in the IPA pipeline, is there a
>reason why `cgraph_node::get_untransformed_body` would crash?

That I have no idea. 

Richard. 

>Thanks again!
>
>>>
> is running, I need to access the body of a function in order to
>iterate over
> the gimple instructions in the first basic block. I have found
>that the
> majority of the cgraph_node will return successfully. However,
>there are some
> functions which consistently produce a segmentation fault
>following this
> stacktrace:
>
> ```
> 0xbc2adb crash_signal
> /home/eochoa/code/gcc/gcc/toplev.c:328
> 0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char
>const*)
> /home/eochoa/code/gcc/gcc/lto-section-in.c:367
> 0x7030e7 cgraph_node::get_untransformed_body()
> /home/eochoa/code/gcc/gcc/cgraph.c:3516
> 0x150613f get_bb1_callees
> /home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
> 0x150613f reach_nodes_via_bb1_dfs
> ```
>
> Is there a way for `cgraph_node::get_untransformed_body` to
>succeed
> consistently? (I.e. are there some preconditions that I need to
>make sure are
> in place before calling cgraph_node::get_untransformed_body?
>
> I am using gcc version 10.0.0 20191127 (experimental)
>
> Thanks



Re: LTO : question about get_untransformed_body

2019-12-06 Thread Erick Ochoa



On 2019-12-06 5:50 a.m., Richard Biener wrote:
> On Wed, Dec 4, 2019 at 6:03 PM Erick Ochoa
>  wrote:
>>
>>
>>
>> On 2019-12-04 7:52 a.m., Richard Biener wrote:
>>> On Tue, Dec 3, 2019 at 11:51 PM Erick Ochoa
>>>  wrote:

 Hi,

 I am trying to use the function: `cgraph_node::get_untransformed_body` 
 during
 the wpa stage of a SIMPLE_IPA_PASS transformation. While the execute 
 function
>>>
>>> I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
>>> (WPA transform stage).  So you might simply see that not all bodies are
>>> available in your LTRANS unit?
>>>
>>
>> This makes a lot of sense, and it is indeed documented in the GCC internals
>> manual:
>>
>>   A small inter-procedural pass (SIMPLE_IPA_PASS) is a pass that does
>>   everything at once and thus it can not be executed during WPA in WHOPR
>>   mode. It defines only the Execute stage and during this stage it
>>   accesses and modifies the function bodies. Such passes are useful for
>>   optimization at LGEN or LTRANS time and are used, for example, to
>>   implement early optimization before writing object files.
>>
>> I got confused because the dump_file for my pass includes the substring 
>> 'wpa'.
>> Should I file a bug to change the name of the dumpfile to something more like
>> `ltrans*`?
> 
> Well, you probably placed your pass in the IPA pipeline rather than the
> all_late_ipa_passes one?  In principle IPA passes _can_ pull in bodies
> during WPA
> analysis, that just will be very costly> 
>> Thanks for your help!

I am a bit confused.
Can you please clarify:

> I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
> (WPA transform stage).

I did have a SIMPLE_IPA_PASS and the dump file contained "wpa" in it.

> Well, you probably placed your pass in the IPA pipeline rather than the
> all_late_ipa_passes one?

I did place my pass in the IPA pipeline rather than the all_late_ipa_passes
one.

Are SIMPLE_IPA_PASSes normally used in the all_late_ipa_passes which
means they are normally scheduled to run at LTRANS time? However, if 
I place my SIMPLE_IPA_PASS during the IPA pipeline, then my SIMPLE_IPA_PASS
will execute at "WPA" stage?

> In principle IPA passes _can_ pull in bodies
> during WPA

So, if SIMPLE_IPA_PASSes are placed in the IPA pipeline, is there a
reason why `cgraph_node::get_untransformed_body` would crash?

Thanks again!

>>
 is running, I need to access the body of a function in order to iterate 
 over
 the gimple instructions in the first basic block. I have found that the
 majority of the cgraph_node will return successfully. However, there are 
 some
 functions which consistently produce a segmentation fault following this
 stacktrace:

 ```
 0xbc2adb crash_signal
 /home/eochoa/code/gcc/gcc/toplev.c:328
 0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char const*)
 /home/eochoa/code/gcc/gcc/lto-section-in.c:367
 0x7030e7 cgraph_node::get_untransformed_body()
 /home/eochoa/code/gcc/gcc/cgraph.c:3516
 0x150613f get_bb1_callees
 /home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
 0x150613f reach_nodes_via_bb1_dfs
 ```

 Is there a way for `cgraph_node::get_untransformed_body` to succeed
 consistently? (I.e. are there some preconditions that I need to make sure 
 are
 in place before calling cgraph_node::get_untransformed_body?

 I am using gcc version 10.0.0 20191127 (experimental)

 Thanks


Re: LTO : question about get_untransformed_body

2019-12-06 Thread Richard Biener
On Wed, Dec 4, 2019 at 6:03 PM Erick Ochoa
 wrote:
>
>
>
> On 2019-12-04 7:52 a.m., Richard Biener wrote:
> > On Tue, Dec 3, 2019 at 11:51 PM Erick Ochoa
> >  wrote:
> >>
> >> Hi,
> >>
> >> I am trying to use the function: `cgraph_node::get_untransformed_body` 
> >> during
> >> the wpa stage of a SIMPLE_IPA_PASS transformation. While the execute 
> >> function
> >
> > I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
> > (WPA transform stage).  So you might simply see that not all bodies are
> > available in your LTRANS unit?
> >
>
> This makes a lot of sense, and it is indeed documented in the GCC internals
> manual:
>
>   A small inter-procedural pass (SIMPLE_IPA_PASS) is a pass that does
>   everything at once and thus it can not be executed during WPA in WHOPR
>   mode. It defines only the Execute stage and during this stage it
>   accesses and modifies the function bodies. Such passes are useful for
>   optimization at LGEN or LTRANS time and are used, for example, to
>   implement early optimization before writing object files.
>
> I got confused because the dump_file for my pass includes the substring 'wpa'.
> Should I file a bug to change the name of the dumpfile to something more like
> `ltrans*`?

Well, you probably placed your pass in the IPA pipeline rather than the
all_late_ipa_passes one?  In principle IPA passes _can_ pull in bodies
during WPA
analysis, that just will be very costly.

> Thanks for your help!
>
> >> is running, I need to access the body of a function in order to iterate 
> >> over
> >> the gimple instructions in the first basic block. I have found that the
> >> majority of the cgraph_node will return successfully. However, there are 
> >> some
> >> functions which consistently produce a segmentation fault following this
> >> stacktrace:
> >>
> >> ```
> >> 0xbc2adb crash_signal
> >> /home/eochoa/code/gcc/gcc/toplev.c:328
> >> 0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char const*)
> >> /home/eochoa/code/gcc/gcc/lto-section-in.c:367
> >> 0x7030e7 cgraph_node::get_untransformed_body()
> >> /home/eochoa/code/gcc/gcc/cgraph.c:3516
> >> 0x150613f get_bb1_callees
> >> /home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
> >> 0x150613f reach_nodes_via_bb1_dfs
> >> ```
> >>
> >> Is there a way for `cgraph_node::get_untransformed_body` to succeed
> >> consistently? (I.e. are there some preconditions that I need to make sure 
> >> are
> >> in place before calling cgraph_node::get_untransformed_body?
> >>
> >> I am using gcc version 10.0.0 20191127 (experimental)
> >>
> >> Thanks


Re: LTO : question about get_untransformed_body

2019-12-04 Thread Erick Ochoa



On 2019-12-04 7:52 a.m., Richard Biener wrote:
> On Tue, Dec 3, 2019 at 11:51 PM Erick Ochoa
>  wrote:
>>
>> Hi,
>>
>> I am trying to use the function: `cgraph_node::get_untransformed_body` during
>> the wpa stage of a SIMPLE_IPA_PASS transformation. While the execute function
> 
> I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
> (WPA transform stage).  So you might simply see that not all bodies are
> available in your LTRANS unit?
> 

This makes a lot of sense, and it is indeed documented in the GCC internals
manual:

  A small inter-procedural pass (SIMPLE_IPA_PASS) is a pass that does
  everything at once and thus it can not be executed during WPA in WHOPR
  mode. It defines only the Execute stage and during this stage it
  accesses and modifies the function bodies. Such passes are useful for
  optimization at LGEN or LTRANS time and are used, for example, to
  implement early optimization before writing object files.

I got confused because the dump_file for my pass includes the substring 'wpa'.
Should I file a bug to change the name of the dumpfile to something more like
`ltrans*`?

Thanks for your help!

>> is running, I need to access the body of a function in order to iterate over
>> the gimple instructions in the first basic block. I have found that the
>> majority of the cgraph_node will return successfully. However, there are some
>> functions which consistently produce a segmentation fault following this
>> stacktrace:
>>
>> ```
>> 0xbc2adb crash_signal
>> /home/eochoa/code/gcc/gcc/toplev.c:328
>> 0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char const*)
>> /home/eochoa/code/gcc/gcc/lto-section-in.c:367
>> 0x7030e7 cgraph_node::get_untransformed_body()
>> /home/eochoa/code/gcc/gcc/cgraph.c:3516
>> 0x150613f get_bb1_callees
>> /home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
>> 0x150613f reach_nodes_via_bb1_dfs
>> ```
>>
>> Is there a way for `cgraph_node::get_untransformed_body` to succeed
>> consistently? (I.e. are there some preconditions that I need to make sure are
>> in place before calling cgraph_node::get_untransformed_body?
>>
>> I am using gcc version 10.0.0 20191127 (experimental)
>>
>> Thanks


Re: LTO : question about get_untransformed_body

2019-12-04 Thread Richard Biener
On Tue, Dec 3, 2019 at 11:51 PM Erick Ochoa
 wrote:
>
> Hi,
>
> I am trying to use the function: `cgraph_node::get_untransformed_body` during
> the wpa stage of a SIMPLE_IPA_PASS transformation. While the execute function

I think SIMPLE_IPA_PASSes have no "WPA" stage but run at LTRANS time
(WPA transform stage).  So you might simply see that not all bodies are
available in your LTRANS unit?

> is running, I need to access the body of a function in order to iterate over
> the gimple instructions in the first basic block. I have found that the
> majority of the cgraph_node will return successfully. However, there are some
> functions which consistently produce a segmentation fault following this
> stacktrace:
>
> ```
> 0xbc2adb crash_signal
> /home/eochoa/code/gcc/gcc/toplev.c:328
> 0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char const*)
> /home/eochoa/code/gcc/gcc/lto-section-in.c:367
> 0x7030e7 cgraph_node::get_untransformed_body()
> /home/eochoa/code/gcc/gcc/cgraph.c:3516
> 0x150613f get_bb1_callees
> /home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
> 0x150613f reach_nodes_via_bb1_dfs
> ```
>
> Is there a way for `cgraph_node::get_untransformed_body` to succeed
> consistently? (I.e. are there some preconditions that I need to make sure are
> in place before calling cgraph_node::get_untransformed_body?
>
> I am using gcc version 10.0.0 20191127 (experimental)
>
> Thanks


Re: LTO : question about get_untransformed_body

2019-12-04 Thread Martin Liška

CC'ing Honza and Martin.


LTO : question about get_untransformed_body

2019-12-03 Thread Erick Ochoa
Hi,

I am trying to use the function: `cgraph_node::get_untransformed_body` during
the wpa stage of a SIMPLE_IPA_PASS transformation. While the execute function
is running, I need to access the body of a function in order to iterate over
the gimple instructions in the first basic block. I have found that the
majority of the cgraph_node will return successfully. However, there are some
functions which consistently produce a segmentation fault following this
stacktrace:

```
0xbc2adb crash_signal
/home/eochoa/code/gcc/gcc/toplev.c:328
0xa54858 lto_get_decl_name_mapping(lto_file_decl_data*, char const*)
/home/eochoa/code/gcc/gcc/lto-section-in.c:367
0x7030e7 cgraph_node::get_untransformed_body()
/home/eochoa/code/gcc/gcc/cgraph.c:3516
0x150613f get_bb1_callees
/home/eochoa/code/gcc/gcc/ipa-initcall-cp.c:737
0x150613f reach_nodes_via_bb1_dfs
```

Is there a way for `cgraph_node::get_untransformed_body` to succeed
consistently? (I.e. are there some preconditions that I need to make sure are
in place before calling cgraph_node::get_untransformed_body?

I am using gcc version 10.0.0 20191127 (experimental)

Thanks