[LTO][PATCH] Fix another undefined reference problem.

Doug Kwan (關振德) dougkwan@google.com
Fri Dec 12 21:07:00 GMT 2008


Hi,

   There reason why DECL_INTERFACE_KNOWN test and the assert were
removed are the original copies of constructor and destructor.
Because of multiple inheritance, the C++ FE clones any constructor or
destructor into a pair of in-charge and not-in-charge clones.  The
clones are emitted but not the original.  It is possible to have DECLs
of original constructor and destructor with no bodies but have
DECL_INTERFACE_SET.  They also trigger the other assert.  Here is some
debugging output of such a DECL.

error in foo (_ZN3fooC1Ev *INTERNAL* )
gimple_body = (nil)
CFG = (nil)
DECL_INTERFACE_KNOWN = 1
DECL_DECLARED_INLINE_P = 0
DECL_IMPLICIT_INSTANTIANTON = 0

I can put back the checks but then we need to exempt the original
constructor and destructor copies.  That should be okay as they can
never cause symbol resolution problem.

-Doug

2008/12/12 Diego Novillo <dnovillo@google.com>:
> 2008/12/11 Doug Kwan (???) <dougkwan@google.com>:
>
>>    This patch fixes another problem where DECLs of unemitted
>> functions are written as exportable in the IL.  The previous code used
>> gimple_body to check for availability of function bodies and that was
>> wrong.
>
> Sorry for having missed that.  I should've suggested using
> gimple_has_body_p().  This predicate will return true if the functions
> has a gimple body whether in CFG form or not.
>
>> +static bool
>> +cp_fix_function_decl_p (tree decl)
>> +{
>> +  /* Skip if DECL is not externally.  */
>
> s/externally/externally visible/
>
>> +  if (!TREE_PUBLIC (decl))
>> +    return false;
>> +
>> +  /* We need to fix DECL if it a appears to be exported but with no
>> +     function body.  Thunks do not have CFGs and we may need to
>> +     handle them specially later.   */
>> +  if ((!DECL_STRUCT_FUNCTION (decl)
>> +       || !DECL_STRUCT_FUNCTION (decl)->cfg)
>
> has_gimple_body_p (decl)
>
>> -      /* This should only happen for inlines or implicit instanitations
>> -      which are not emitted.  When we reach here,  we should have read
>> -      the EOF and expanded all needed functions.  */
>> -      gcc_assert ((DECL_DECLARED_INLINE_P (t)
>> -                || DECL_IMPLICIT_INSTANTIATION (t))
>> -               && at_eof);
>> -
>
> Why are you removing this assertion?  Also, why is it not necessary to check
> for DECL_INTERFACE_KNOWN anymore?
>
>
> Thanks.  Diego.
>



More information about the Gcc-patches mailing list