[PATCH][LTO] Fix PR41761

Richard Guenther rguenther@suse.de
Tue Oct 20 13:26:00 GMT 2009


This fixes aforementioned PR by making sure we always register the
TYPE_MAIN_VARIANT type first.  It is the canonical one for all
typedef-ed variants, choosing one of those as the canonical one
will lead to later merging mismatches and complaints from the
type verifier.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2009-10-20  Richard Guenther  <rguenther@suse.de>

	* gimple.c (gimple_register_type): Make sure we register
	the types main variant first.

	* gcc.dg/lto/20091020-1_0.c: New testcase.
	* gcc.dg/lto/20091020-1_1.c: Likewise.
	* gcc.dg/lto/20091020-2_0.c: Likewise.
	* gcc.dg/lto/20091020-2_1.c: Likewise.

Index: gcc/gimple.c
===================================================================
*** gcc/gimple.c	(revision 153007)
--- gcc/gimple.c	(working copy)
*************** gimple_register_type (tree t)
*** 3814,3819 ****
--- 3814,3825 ----
  
    gcc_assert (TYPE_P (t));
  
+   /* Always register the main variant first.  This is important so we
+      pick up the non-typedef variants as canonical, otherwise we'll end
+      up taking typedef ids for structure tags during comparison.  */
+   if (TYPE_MAIN_VARIANT (t) != t)
+     gimple_register_type (TYPE_MAIN_VARIANT (t));
+ 
    if (gimple_types == NULL)
      gimple_types = htab_create (16381, gimple_type_hash, gimple_type_eq, 0);
  
Index: gcc/testsuite/gcc.dg/lto/20091020-1_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20091020-1_0.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20091020-1_0.c	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ /* { dg-lto-do link } */
+ /* { dg-lto-options {{-fPIC -shared -flto}} } */
+ 
+ typedef struct {
+     int NumPackStreams;
+ } CSzAr;
+ void cli_7unz (CSzAr db) { }
+ 
Index: gcc/testsuite/gcc.dg/lto/20091020-1_1.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20091020-1_1.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20091020-1_1.c	(revision 0)
***************
*** 0 ****
--- 1,15 ----
+ typedef struct {
+     int NumPackStreams;
+ } CSzAr;
+ typedef struct {
+     CSzAr db;
+ } CSzArEx;
+ int SzArEx_Init(CSzArEx *p)
+ {
+   return p->db.NumPackStreams;
+ }
+ int SzArEx_GetFolderFullPackSize(const CSzArEx *p)
+ {
+   return p->db.NumPackStreams;
+ }
+ 
Index: gcc/testsuite/gcc.dg/lto/20091020-2_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20091020-2_0.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20091020-2_0.c	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-lto-do link } */
+ /* { dg-lto-options {{-fPIC -shared -flto}} } */
+ 
+ typedef struct {
+     int NumPackStreams;
+ } CSzAr;
+ typedef struct {
+     CSzAr db;
+ } CSzArEx;
+ int SzArEx_Init(CSzArEx *p)
+ {
+   return p->db.NumPackStreams;
+ }
+ int SzArEx_GetFolderFullPackSize(const CSzArEx *p)
+ {
+   return p->db.NumPackStreams;
+ }
+ 
Index: gcc/testsuite/gcc.dg/lto/20091020-2_1.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20091020-2_1.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/20091020-2_1.c	(revision 0)
***************
*** 0 ****
--- 1,5 ----
+ typedef struct {
+     int NumPackStreams;
+ } CSzAr;
+ void cli_7unz (CSzAr db) { }
+ 



More information about the Gcc-patches mailing list