* Inline Expansion Problem
@ 2011-08-27 2:48 Matt Davis
2011-08-27 7:28 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Matt Davis @ 2011-08-27 2:48 UTC (permalink / raw)
To: gcc
Hello,
I am having the compiler insert a call to a function which is defined inside
another object file. However, during inline expansion via expand_call_inline(),
the following assertion fails in tree-inline.c:
>> 3775: edge = cgraph_edge (id->dst_node, stmt);
>> 3776: gcc_checking_assert (cg_edge);
cg_node comes back as being NULL since there is only one callee and no indirect
calls, the function that has the inserted call is main(). Is there something I
forgot to do after inserting the gimple call statement? This works fine without
optimization.
-Matt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Inline Expansion Problem
2011-08-27 2:48 Inline Expansion Problem Matt Davis
@ 2011-08-27 7:28 ` Richard Guenther
2011-08-27 8:07 ` Matt Davis
0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2011-08-27 7:28 UTC (permalink / raw)
To: Matt Davis; +Cc: gcc
On Sat, Aug 27, 2011 at 4:47 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> Hello,
> I am having the compiler insert a call to a function which is defined inside
> another object file. However, during inline expansion via expand_call_inline(),
> the following assertion fails in tree-inline.c:
>>> 3775: edge = cgraph_edge (id->dst_node, stmt);
>>> 3776: gcc_checking_assert (cg_edge);
>
> cg_node comes back as being NULL since there is only one callee and no indirect
> calls, the function that has the inserted call is main(). Is there something I
> forgot to do after inserting the gimple call statement? This works fine without
> optimization.
Dependent on where you do it you have to add/rebuild cgraph edges.
Richard.
> -Matt
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Inline Expansion Problem
2011-08-27 7:28 ` Richard Guenther
@ 2011-08-27 8:07 ` Matt Davis
2011-08-27 9:26 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Matt Davis @ 2011-08-27 8:07 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc
On Sat, Aug 27, 2011 at 09:27:49AM +0200, Richard Guenther wrote:
> On Sat, Aug 27, 2011 at 4:47 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> > Hello,
> > I am having the compiler insert a call to a function which is defined inside
> > another object file. Â However, during inline expansion via expand_call_inline(),
> > the following assertion fails in tree-inline.c:
> >>> 3775: edge = cgraph_edge (id->dst_node, stmt);
> >>> 3776: gcc_checking_assert (cg_edge);
> >
> > cg_node comes back as being NULL since there is only one callee and no indirect
> > calls, the function that has the inserted call is main(). Â Is there something I
> > forgot to do after inserting the gimple call statement? Â This works fine without
> > optimization.
>
> Dependent on where you do it you have to add/rebuild cgraph edges.
Thanks Richard,
I tired "rebuild_cgraph_edges()" before I sent the initial email.
Unfortunately, when I call that function after I add the statement, in an IPA
pass, the resulting binary does not link, as it does not seem able to resolve
the symbol to the callee. Maybe providing more context would help make more
sense. insert_func_call inserts the call by adding a new gimple call statement.
I've done this tons of times before, but it seems with -O the callgraph isn't
happy.
>> for (node=cgraph_nodes; node; node=node->next)
>> {
>> if (!(func = DECL_STRUCT_FUNCTION(node->decl)))
>> continue;
>>
>> push_cfun(func);
>> old_fn_decl = current_function_decl;
>> current_function_decl = node->decl;
>>
>> insert_func_call(func);
>>
>> rebuild_cgraph_edges();
>> current_function_decl = old_fn_decl;
>> pop_cfun();
>> }
-Matt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Inline Expansion Problem
2011-08-27 8:07 ` Matt Davis
@ 2011-08-27 9:26 ` Richard Guenther
2011-08-27 23:30 ` Matt Davis
0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2011-08-27 9:26 UTC (permalink / raw)
To: Matt Davis; +Cc: gcc
On Sat, Aug 27, 2011 at 10:06 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> On Sat, Aug 27, 2011 at 09:27:49AM +0200, Richard Guenther wrote:
>> On Sat, Aug 27, 2011 at 4:47 AM, Matt Davis <mattdavis9@gmail.com> wrote:
>> > Hello,
>> > I am having the compiler insert a call to a function which is defined inside
>> > another object file. However, during inline expansion via expand_call_inline(),
>> > the following assertion fails in tree-inline.c:
>> >>> 3775: edge = cgraph_edge (id->dst_node, stmt);
>> >>> 3776: gcc_checking_assert (cg_edge);
>> >
>> > cg_node comes back as being NULL since there is only one callee and no indirect
>> > calls, the function that has the inserted call is main(). Is there something I
>> > forgot to do after inserting the gimple call statement? This works fine without
>> > optimization.
>>
>> Dependent on where you do it you have to add/rebuild cgraph edges.
>
> Thanks Richard,
> I tired "rebuild_cgraph_edges()" before I sent the initial email.
> Unfortunately, when I call that function after I add the statement, in an IPA
> pass, the resulting binary does not link, as it does not seem able to resolve
> the symbol to the callee. Maybe providing more context would help make more
> sense. insert_func_call inserts the call by adding a new gimple call statement.
> I've done this tons of times before, but it seems with -O the callgraph isn't
> happy.
If you are doing this from an IPA pass you have to add the edge manually using
update_edges_for_call_stmt.
>>> for (node=cgraph_nodes; node; node=node->next)
>>> {
>>> if (!(func = DECL_STRUCT_FUNCTION(node->decl)))
>>> continue;
>>>
>>> push_cfun(func);
>>> old_fn_decl = current_function_decl;
>>> current_function_decl = node->decl;
>>>
>>> insert_func_call(func);
>>>
>>> rebuild_cgraph_edges();
>>> current_function_decl = old_fn_decl;
>>> pop_cfun();
>>> }
>
> -Matt
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Inline Expansion Problem
2011-08-27 9:26 ` Richard Guenther
@ 2011-08-27 23:30 ` Matt Davis
2011-08-28 8:30 ` Richard Guenther
0 siblings, 1 reply; 6+ messages in thread
From: Matt Davis @ 2011-08-27 23:30 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc
On Sat, Aug 27, 2011 at 11:25:45AM +0200, Richard Guenther wrote:
> On Sat, Aug 27, 2011 at 10:06 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> > On Sat, Aug 27, 2011 at 09:27:49AM +0200, Richard Guenther wrote:
> >> On Sat, Aug 27, 2011 at 4:47 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> >> > Hello,
> >> > I am having the compiler insert a call to a function which is defined inside
> >> > another object file. Â However, during inline expansion via expand_call_inline(),
> >> > the following assertion fails in tree-inline.c:
> >> >>> 3775: edge = cgraph_edge (id->dst_node, stmt);
> >> >>> 3776: gcc_checking_assert (cg_edge);
> >> >
> >> > cg_node comes back as being NULL since there is only one callee and no indirect
> >> > calls, the function that has the inserted call is main(). Â Is there something I
> >> > forgot to do after inserting the gimple call statement? Â This works fine without
> >> > optimization.
> >>
> >> Dependent on where you do it you have to add/rebuild cgraph edges.
> >
> > Thanks Richard,
> > I tired "rebuild_cgraph_edges()" before I sent the initial email.
> > Unfortunately, when I call that function after I add the statement, in an IPA
> > pass, the resulting binary does not link, as it does not seem able to resolve
> > the symbol to the callee. Â Maybe providing more context would help make more
> > sense. Â insert_func_call inserts the call by adding a new gimple call statement.
> > I've done this tons of times before, but it seems with -O the callgraph isn't
> > happy.
>
> If you are doing this from an IPA pass you have to add the edge manually using
> update_edges_for_call_stmt.
Thanks Richard,
I was unable to properly use update_edges_for_call_stmt. It seems that routine
is for updating an existing call. In my case I am inserting a new gimple call
via gsi_insert_before() with GSI_NEW_STMT. As a gimple pass, this works fine.
I appreciate all of your correspondence.
-Matt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Inline Expansion Problem
2011-08-27 23:30 ` Matt Davis
@ 2011-08-28 8:30 ` Richard Guenther
0 siblings, 0 replies; 6+ messages in thread
From: Richard Guenther @ 2011-08-28 8:30 UTC (permalink / raw)
To: Matt Davis; +Cc: gcc
On Sun, Aug 28, 2011 at 1:30 AM, Matt Davis <mattdavis9@gmail.com> wrote:
> On Sat, Aug 27, 2011 at 11:25:45AM +0200, Richard Guenther wrote:
>> On Sat, Aug 27, 2011 at 10:06 AM, Matt Davis <mattdavis9@gmail.com> wrote:
>> > On Sat, Aug 27, 2011 at 09:27:49AM +0200, Richard Guenther wrote:
>> >> On Sat, Aug 27, 2011 at 4:47 AM, Matt Davis <mattdavis9@gmail.com> wrote:
>> >> > Hello,
>> >> > I am having the compiler insert a call to a function which is defined inside
>> >> > another object file. However, during inline expansion via expand_call_inline(),
>> >> > the following assertion fails in tree-inline.c:
>> >> >>> 3775: edge = cgraph_edge (id->dst_node, stmt);
>> >> >>> 3776: gcc_checking_assert (cg_edge);
>> >> >
>> >> > cg_node comes back as being NULL since there is only one callee and no indirect
>> >> > calls, the function that has the inserted call is main(). Is there something I
>> >> > forgot to do after inserting the gimple call statement? This works fine without
>> >> > optimization.
>> >>
>> >> Dependent on where you do it you have to add/rebuild cgraph edges.
>> >
>> > Thanks Richard,
>> > I tired "rebuild_cgraph_edges()" before I sent the initial email.
>> > Unfortunately, when I call that function after I add the statement, in an IPA
>> > pass, the resulting binary does not link, as it does not seem able to resolve
>> > the symbol to the callee. Maybe providing more context would help make more
>> > sense. insert_func_call inserts the call by adding a new gimple call statement.
>> > I've done this tons of times before, but it seems with -O the callgraph isn't
>> > happy.
>>
>> If you are doing this from an IPA pass you have to add the edge manually using
>> update_edges_for_call_stmt.
>
> Thanks Richard,
> I was unable to properly use update_edges_for_call_stmt. It seems that routine
> is for updating an existing call. In my case I am inserting a new gimple call
> via gsi_insert_before() with GSI_NEW_STMT. As a gimple pass, this works fine.
> I appreciate all of your correspondence.
Well, from looking at the function it should work if you pass NULL as
the old stmt.
If it does not, figure out why.
Richard.
> -Matt
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-28 8:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-27 2:48 Inline Expansion Problem Matt Davis
2011-08-27 7:28 ` Richard Guenther
2011-08-27 8:07 ` Matt Davis
2011-08-27 9:26 ` Richard Guenther
2011-08-27 23:30 ` Matt Davis
2011-08-28 8:30 ` 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).