This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: make_decl_one_only and inlining


On Sat, Feb 16, 2013 at 12:00 AM, Johannes Pfau <johannespfau@gmail.com> wrote:
> Ian Lance Taylor <iant <at> google.com> writes:
>
>>
>> Why is that?  decl_replaceable_p is supposed to be true for a function
>> that may be replaced by an entirely different function at runtime.
>> This is mainly to implement the correct semantics for weak functions.
>> You can't inline a weak function, but at runtime the runtime linker
>> might have resolved the weak function to something completely
>> different.
>
> AFAICS make_decl_one_only also sets DECL_WEAK which ultimately
> causes decl_replaceable_p to return false. I understand why weak
> functions are replaceable but is this also true for DECL_ONE_ONLY
> functions? Couldn'tdecl_replaceable_p check for DECL_ONE_ONLY in
> addition to DECL_COMDAT?

Sorry, you're right, make_decl_one_only does set DECL_WEAK.  I managed
to confuse myself.

>> Set DECL_COMDAT.  You said that didn't work but you didn't fully
>> explain why.  A DECL_COMDAT function should be output in every object
>> file in which it is referenced.
>
> I wasn't sure if that's the correct approach. If it is, some
> further investigation will be necessary why it doesn't work. We
> should of course find the places where template instances are
> used in the frontend and not put out, but that's too much effort
> right now only to make inlining work.

Yes, setting the DECL_COMDAT flag is supposed to do the right thing.
That is what the C++ frontend does; see comdat_linkage.

> How does this approach work for explicitly instantiated templates?
> Those might seem to be not referenced but they should still be always put
> out?

The C++ frontend does not set the DECL_COMDAT flag on an explicit
function instantiation.  See mark_decl_instantiated.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]