[PATCH][LTO] Fix PRs 41808 and 41839

Richard Guenther rguenther@suse.de
Tue Oct 27 14:10:00 GMT 2009


This fixes more gimple type verification errors with LTO.  The issue
is again completing pointer types.  We have no choice but to have
explicit conversions for conversions to incomplete pointed-to types
again - otherwise if we complete pointers from another TU we get
ICEs for the now invalid gimple IL.  I explored some other options
but they did not work.  The other thing is that we should use
struct tags for name comparison, not typedef names.

Bootstrapped and tested on x86_64-unknonw-linux-gnu, SPEC 2006 tested.

Ok for trunk?

Thanks,
Richard.

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

	PR lto/41808
	PR lto/41839
	* tree-ssa.c (useless_type_conversion_p): Do not treat
	conversions to pointers to incomplete types as useless.
	* gimple.c (gimple_types_compatible_p): Compare struct tags,
	not typedef names.

	* gcc.dg/lto/20091027-1_0.c: New testcase.
	* gcc.dg/lto/20091027-1_1.c: Likewise.
	* g++.dg/lto/20091026-1_0.C: Likewise.
	* g++.dg/lto/20091026-1_1.C: Likewise.
	* g++.dg/lto/20091026-1_a.h: Likewise.

Index: trunk/gcc/tree-ssa.c
===================================================================
*** trunk.orig/gcc/tree-ssa.c	2009-10-27 10:42:09.000000000 +0100
--- trunk/gcc/tree-ssa.c	2009-10-27 10:43:43.000000000 +0100
*************** useless_type_conversion_p (tree outer_ty
*** 1201,1211 ****
  	 record type or a pointer to an unprototyped function,
  	 then the conversion is not necessary.  */
        if (VOID_TYPE_P (TREE_TYPE (outer_type))
- 	  || (AGGREGATE_TYPE_P (TREE_TYPE (outer_type))
- 	      && TREE_CODE (TREE_TYPE (outer_type)) != ARRAY_TYPE
- 	      && (TREE_CODE (TREE_TYPE (outer_type))
- 		  == TREE_CODE (TREE_TYPE (inner_type)))
- 	      && !COMPLETE_TYPE_P (TREE_TYPE (outer_type)))
  	  || ((TREE_CODE (TREE_TYPE (outer_type)) == FUNCTION_TYPE
  	       || TREE_CODE (TREE_TYPE (outer_type)) == METHOD_TYPE)
  	      && (TREE_CODE (TREE_TYPE (outer_type))
--- 1201,1206 ----
Index: trunk/gcc/gimple.c
===================================================================
*** trunk.orig/gcc/gimple.c	2009-10-27 10:56:48.000000000 +0100
--- trunk/gcc/gimple.c	2009-10-27 10:57:45.000000000 +0100
*************** gimple_types_compatible_p (tree t1, tree
*** 3357,3363 ****
  	    && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t1))
  	    && (!COMPLETE_TYPE_P (TREE_TYPE (t1))
  		|| !COMPLETE_TYPE_P (TREE_TYPE (t2)))
! 	    && compare_type_names_p (TREE_TYPE (t1), TREE_TYPE (t2), true))
  	  {
  	    /* Replace the pointed-to incomplete type with the
  	       complete one.  */
--- 3357,3364 ----
  	    && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t1))
  	    && (!COMPLETE_TYPE_P (TREE_TYPE (t1))
  		|| !COMPLETE_TYPE_P (TREE_TYPE (t2)))
! 	    && compare_type_names_p (TYPE_MAIN_VARIANT (TREE_TYPE (t1)),
! 				     TYPE_MAIN_VARIANT (TREE_TYPE (t2)), true))
  	  {
  	    /* Replace the pointed-to incomplete type with the
  	       complete one.  */
Index: trunk/gcc/testsuite/gcc.dg/lto/20091027-1_0.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/gcc.dg/lto/20091027-1_0.c	2009-10-27 11:01:32.000000000 +0100
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-lto-do link } */
+ /* { dg-extra-ld-options "-r -nostdlib" } */
+ 
+ typedef struct _xmlDict xmlDict;
+ struct _xmlDict {
+  int ref_counter;
+ };
+ void xmlDictCreate(void) {
+   xmlDict * dict;
+ }
+ 
Index: trunk/gcc/testsuite/gcc.dg/lto/20091027-1_1.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/gcc.dg/lto/20091027-1_1.c	2009-10-27 11:01:59.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ typedef struct _xmlDict xmlDict;
+ struct _xmlDoc {
+   struct _xmlDict *dict;
+ };
+ void xmlAddEntity(struct _xmlDoc *a) {
+   xmlDict * dict = a->dict;
+   xmlHashCreateDict(0, dict);
+ }
+ 
Index: trunk/gcc/testsuite/g++.dg/lto/20091026-1_0.C
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/g++.dg/lto/20091026-1_0.C	2009-10-26 14:48:08.000000000 +0100
***************
*** 0 ****
--- 1,11 ----
+ // { dg-lto-do link }
+ // { dg-extra-ld-options "-r -nostdlib" }
+ 
+ #include "20091026-1_a.h"
+ cObject *cHead::find(const char *objname) const
+ {
+     return firstchildp;
+ }
+ class cNetworkType : public cObject { };
+ cNetworkType *networktype;
+ 
Index: trunk/gcc/testsuite/g++.dg/lto/20091026-1_1.C
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/g++.dg/lto/20091026-1_1.C	2009-10-26 15:51:24.000000000 +0100
***************
*** 0 ****
--- 1,14 ----
+ #include "20091026-1_a.h"
+ extern cHead networks;
+ class cNetworkType;
+ inline cNetworkType *findNetwork(const char *s)
+ {
+   return (cNetworkType *)networks.find(s);
+ }
+ int run(const char *opt_network_name)
+ {
+   cNetworkType *network = findNetwork(opt_network_name);
+   if (!network)
+     throw 1;
+ }
+ 
Index: trunk/gcc/testsuite/g++.dg/lto/20091026-1_a.h
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/g++.dg/lto/20091026-1_a.h	2009-10-26 14:48:35.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ class cObject {
+ public:
+     cObject *firstchildp;
+ };
+ class cHead : public cObject {
+ public:
+     cObject *find(const char *objname) const;
+ };
+ 



More information about the Gcc-patches mailing list