Patchwork Fix PR53433, LTO and constant folding confused about error_mark_node

login
register
mail settings
Submitter Richard Guenther
Date July 4, 2012, 12:39 p.m.
Message ID <alpine.LNX.2.00.1207041437150.17233@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/168978/
State New
Headers show

Comments

Richard Guenther - July 4, 2012, 12:39 p.m.
In initializer constant folding we use error_mark_node as a magic
return value which indicates a not present but kown zero initializer.
LTO on the other hand uses error_mark_node to mark something as
having a non-empty initializer but not present in the current ltrans
unit.  Those uses conflict - thus avoid leaking the latter into the
former.

Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu (it
is confirmed that it fixes the LTO profiledbootstrap case).

I'll apply this to all affected branches once tested.

Thanks,
Richard.

2012-07-04  Richard Guenther  <rguenther@suse.de>

	PR middle-end/53433
	* gimple-fold.c (get_base_constructor): Do not return an
	error_mark_node DECL_INITIAL.

Patch

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 189251)
+++ gcc/gimple-fold.c	(working copy)
@@ -2713,6 +2713,10 @@  get_base_constructor (tree base, HOST_WI
       if (!DECL_INITIAL (base)
 	  && (TREE_STATIC (base) || DECL_EXTERNAL (base)))
         return error_mark_node;
+      /* Do not return an error_mark_node DECL_INITIAL.  LTO uses this
+         as special marker (_not_ zero ...) for its own purposes.  */
+      if (DECL_INITIAL (base) == error_mark_node)
+	return NULL_TREE;
       return DECL_INITIAL (base);
 
     case ARRAY_REF: