[RFC] Using One Definition Rule for types during LTO devirtualizatoin?

Jason Merrill jason@redhat.com
Mon Jun 17 17:33:00 GMT 2013


On 06/17/2013 10:18 AM, Jan Hubicka wrote:
> Does ODR hold also for extern "C" declarations in C++?

Yes.

>> In C, you can treat all structurally identical types as the same, right?
> In next step we can sort out other reasons they
> are not merged by Richard's merging code but stil equivalent in C++ sense.
> There are easy cases to list - i.e. we will not merge class type from unit that
> defines the keyed method with class type from other unit since the associated
> binfo will differ in types of the declarations (DECL_EXTERNAL versus
> TREE_PUBLIC+STATIC).

I'm surprised the code wouldn't handle that; don't you handle merging 
extern function decls with definitions outside of classes?

> OK, thanks!  I naively assumed that checking DECL_NAME for NULL is enough
> here. I will fix this.

Ah, yes, that ought to work.  I was overlooking that bit.

>> The question is when will two types be "ODR equivalent" but not
>> "tree equivalent".  Certainly there is no such thing as "ODR" for C,
>> so given C++ manually implemented in C you cannot expect same
>> "vtable" contents when the types have the same name.

> yes, that is why I think we need flag specifying if type is ODR or not.

I'm not sure we do.  A manual implementation wouldn't have the "vtable" 
specially associated with the type, so that shouldn't be an issue.

Jason



More information about the Gcc-patches mailing list