Inline Expansion Problem

Richard Guenther richard.guenther@gmail.com
Sun Aug 28 08:30:00 GMT 2011


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
>



More information about the Gcc mailing list