Fix PR ipa/83983 (partially)

Message ID 4738743.96ZptyNmoT@arcturus.home
State New
Headers show
Series
  • Fix PR ipa/83983 (partially)
Related show

Commit Message

Eric Botcazou March 2, 2018, 8:49 a.m.
Hi,

this PR reports the failure of g++.dg/lto/pr83121 on multiple platforms.

There are 2 differents issues and this message is about the missing warning on 
Aarch64 and SPARC.  On these platforms the LTO compiler issues:

/home/ebotcazou/src/gcc/testsuite/g++.dg/lto/pr83121_0.C:6:8: warning: type 
'struct Environment' violates the C++ One Definition Rule [-Wodr]
/home/ebotcazou/src/gcc/testsuite/g++.dg/lto/pr83121_1.C:1:8: note: a type 
with different size is defined in another translation unit

instead of the expected more verbose warning, as for example on x86.  The 
discrepancy between x86 and Aarch64/SPARC comes from:

  /* For ODR types be sure to compare their names.
     To support -wno-odr-type-merging we allow one type to be non-ODR
     and other ODR even though it is a violation.  */
  if (types_odr_comparable (t1, t2, true))
    {
      if (!types_same_for_odr (t1, t2, true))
        return false;
      /* Limit recursion: If subtypes are ODR types and we know
         that they are same, be happy.  */
      if (!odr_type_p (t1) || !get_odr_type (t1, true)->odr_violated)
        return true;
    }

The call to get_odr_type (t1, true) is supposed to yield the warning, but this 
depends on the order in which types t1 and t2 have been inserted in the table.

In other words, get_odr_type (t1, true) works on x86 while on Aarch64/SPARC 
get_odr_type (t2, true) works instead.  Hence the propose fix.

Tested on x86-64/Linux and SPARC64/Linux, OK for the mainline?


2018-03-02  Eric Botcazou  <ebotcazou@adacore.com>

	PR ipa/83983
	* ipa-devirt.c (odr_subtypes_equivalent_p): Get the ODR type of both
 	arguments if they are comparable.

-- 
Eric Botcazou

Comments

Richard Biener March 2, 2018, 9:35 a.m. | #1
On Fri, Mar 2, 2018 at 9:49 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,

>

> this PR reports the failure of g++.dg/lto/pr83121 on multiple platforms.

>

> There are 2 differents issues and this message is about the missing warning on

> Aarch64 and SPARC.  On these platforms the LTO compiler issues:

>

> /home/ebotcazou/src/gcc/testsuite/g++.dg/lto/pr83121_0.C:6:8: warning: type

> 'struct Environment' violates the C++ One Definition Rule [-Wodr]

> /home/ebotcazou/src/gcc/testsuite/g++.dg/lto/pr83121_1.C:1:8: note: a type

> with different size is defined in another translation unit

>

> instead of the expected more verbose warning, as for example on x86.  The

> discrepancy between x86 and Aarch64/SPARC comes from:

>

>   /* For ODR types be sure to compare their names.

>      To support -wno-odr-type-merging we allow one type to be non-ODR

>      and other ODR even though it is a violation.  */

>   if (types_odr_comparable (t1, t2, true))

>     {

>       if (!types_same_for_odr (t1, t2, true))

>         return false;

>       /* Limit recursion: If subtypes are ODR types and we know

>          that they are same, be happy.  */

>       if (!odr_type_p (t1) || !get_odr_type (t1, true)->odr_violated)

>         return true;

>     }

>

> The call to get_odr_type (t1, true) is supposed to yield the warning, but this

> depends on the order in which types t1 and t2 have been inserted in the table.

>

> In other words, get_odr_type (t1, true) works on x86 while on Aarch64/SPARC

> get_odr_type (t2, true) works instead.  Hence the propose fix.

>

> Tested on x86-64/Linux and SPARC64/Linux, OK for the mainline?


Ok with a comment explaining why we call both even though
types_same_for_odr holds true.

Thanks,
Richard.

>

> 2018-03-02  Eric Botcazou  <ebotcazou@adacore.com>

>

>         PR ipa/83983

>         * ipa-devirt.c (odr_subtypes_equivalent_p): Get the ODR type of both

>         arguments if they are comparable.

>

> --

> Eric Botcazou

Patch

Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c	(revision 258068)
+++ ipa-devirt.c	(working copy)
@@ -686,7 +686,10 @@  odr_subtypes_equivalent_p (tree t1, tree t2,
         return false;
       /* Limit recursion: If subtypes are ODR types and we know
          that they are same, be happy.  */
-      if (!odr_type_p (t1) || !get_odr_type (t1, true)->odr_violated)
+      if (!odr_type_p (t1)
+	  || !odr_type_p (t2)
+	  || (!get_odr_type (t1, true)->odr_violated
+	      && !get_odr_type (t2, true)->odr_violated))
         return true;
     }