Remove non-var-decls from blocks in free_lang_data

Message ID 20180614114124.GG28239@kam.mff.cuni.cz
State New
Headers show
Series
  • Remove non-var-decls from blocks in free_lang_data
Related show

Commit Message

Jan Hubicka June 14, 2018, 11:41 a.m.
Hi,
this patch removes TYPE_DECLs and CONST_DECLs from block trees for LTO.
With early debug we have no good use for it anymore.

ltobootstrapped/regtested x86-64-linux, OK?

Honza

	* tree.c (find_decls_types_r): Remove all non-VAR_DECLs from
	blocks.
	* g++.dg/lto/pr84805_0.C: Update template.
	* g++.dg/lto/pr84805_1.C: Update template.

Comments

Richard Biener June 14, 2018, 12:40 p.m. | #1
On Thu, 14 Jun 2018, Jan Hubicka wrote:

> Hi,

> this patch removes TYPE_DECLs and CONST_DECLs from block trees for LTO.

> With early debug we have no good use for it anymore.

> 

> ltobootstrapped/regtested x86-64-linux, OK?

> 

> Honza

> 

> 	* tree.c (find_decls_types_r): Remove all non-VAR_DECLs from

> 	blocks.

> 	* g++.dg/lto/pr84805_0.C: Update template.

> 	* g++.dg/lto/pr84805_1.C: Update template.

> Index: tree.c

> ===================================================================

> --- tree.c	(revision 261546)

> +++ tree.c	(working copy)

> @@ -5556,10 +5556,22 @@ find_decls_types_r (tree *tp, int *ws, v

>      }

>    else if (TREE_CODE (t) == BLOCK)

>      {

> -      tree tem;

> -      for (tem = BLOCK_VARS (t); tem; tem = TREE_CHAIN (tem))

> -	fld_worklist_push (tem, fld);

> -      for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem))

> +      for (tree *tem = &BLOCK_VARS (t); *tem; )

> +	{

> +	  if (TREE_CODE (*tem) != VAR_DECL

> +	      || TREE_STATIC (*tem))


I think you can use !auto_var_in_fn (*tem, cfun->decl) so you
also catch DECL_EXTERNALs considering

int foo()
{
  extern int j;
  return j;
}

OK with that change.

Richard.

> +	    {

> +	      gcc_assert (TREE_CODE (*tem) != RESULT_DECL

> +			  && TREE_CODE (*tem) != PARM_DECL);

> +	      *tem = TREE_CHAIN (*tem);

> +	    }

> +	  else 

> +	    {

> +	      fld_worklist_push (*tem, fld);

> +	      tem = &TREE_CHAIN (*tem);

> +	    }

> +	}

> +      for (tree tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem))

>  	fld_worklist_push (tem, fld);

>        fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld);

>      }

> Index: testsuite/g++.dg/lto/pr84805_0.C

> ===================================================================

> --- testsuite/g++.dg/lto/pr84805_0.C	(revision 261546)

> +++ testsuite/g++.dg/lto/pr84805_0.C	(working copy)

> @@ -23,7 +23,7 @@ template < typename _Tp, _Lock_policy, b

>             bool = is_void::value >

>  class __shared_ptr_access {};

>  template < typename _Tp, _Lock_policy _Lp >

> -class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { // { dg-lto-warning "7: type 'struct __shared_ptr' violates the C\\+\\+ One Definition Rule" }

> +class __shared_ptr : __shared_ptr_access< _Tp, _Lp > {

>    using element_type = _Tp;

>    element_type *_M_ptr;

>    __shared_count< _Lp > _M_refcount;

> @@ -90,7 +90,7 @@ class ExtNameBuff;

>  class ExtSheetBuffer;

>  class ExcelToSc;

>  class XclImpColRowSettings;

> -struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" }

> +struct RootData { 

>    BiffTyp eDateiTyp;

>    ExtSheetBuffer *pExtSheetBuff;

>    SharedFormulaBuffer *pShrfmlaBuff;

> @@ -105,7 +105,7 @@ class ScExtDocOptions;

>  class XclFontPropSetHelper;

>  class XclChPropSetHelper;

>  class XclTracer;

> -struct XclRootData { // { dg-lto-warning "8: type 'struct XclRootData' violates the C\\+\\+ One Definition Rule" }

> +struct XclRootData {

>    typedef std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef;

>    typedef std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef;

>    typedef std::shared_ptr< EditEngine > EditEngineRef;

> @@ -141,12 +141,12 @@ struct XclRootData { // { dg-lto-warning

>    RootDataRef mxRD;

>    virtual ~XclRootData();

>  };

> -class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" }

> +class XclRoot {

>  public:

>    virtual ~XclRoot();

>    XclRootData &mrData;

>  };

> -class XclImpRoot : XclRoot {}; // { dg-lto-warning "7: type 'struct XclImpRoot' violates the C\\+\\+ One Definition Rule" }

> +class XclImpRoot : XclRoot {}; 

>  class XclImpColRowSettings : XclImpRoot {};

>  void lcl_ExportExcelBiff() {

>  XclRootData aExpData();

> Index: testsuite/g++.dg/lto/pr84805_1.C

> ===================================================================

> --- testsuite/g++.dg/lto/pr84805_1.C	(revision 261546)

> +++ testsuite/g++.dg/lto/pr84805_1.C	(working copy)

> @@ -1,9 +1,9 @@

> -class XclRoot {

> +class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" }

>  public:

>    virtual ~XclRoot();

>  };

>  class XclImpRoot : XclRoot {};

> -struct RootData {

> +struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" }

>    XclImpRoot pIR;

>  };

>  class ExcRoot {

> 

> 


-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

Patch

Index: tree.c
===================================================================
--- tree.c	(revision 261546)
+++ tree.c	(working copy)
@@ -5556,10 +5556,22 @@  find_decls_types_r (tree *tp, int *ws, v
     }
   else if (TREE_CODE (t) == BLOCK)
     {
-      tree tem;
-      for (tem = BLOCK_VARS (t); tem; tem = TREE_CHAIN (tem))
-	fld_worklist_push (tem, fld);
-      for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem))
+      for (tree *tem = &BLOCK_VARS (t); *tem; )
+	{
+	  if (TREE_CODE (*tem) != VAR_DECL
+	      || TREE_STATIC (*tem))
+	    {
+	      gcc_assert (TREE_CODE (*tem) != RESULT_DECL
+			  && TREE_CODE (*tem) != PARM_DECL);
+	      *tem = TREE_CHAIN (*tem);
+	    }
+	  else 
+	    {
+	      fld_worklist_push (*tem, fld);
+	      tem = &TREE_CHAIN (*tem);
+	    }
+	}
+      for (tree tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem))
 	fld_worklist_push (tem, fld);
       fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld);
     }
Index: testsuite/g++.dg/lto/pr84805_0.C
===================================================================
--- testsuite/g++.dg/lto/pr84805_0.C	(revision 261546)
+++ testsuite/g++.dg/lto/pr84805_0.C	(working copy)
@@ -23,7 +23,7 @@  template < typename _Tp, _Lock_policy, b
            bool = is_void::value >
 class __shared_ptr_access {};
 template < typename _Tp, _Lock_policy _Lp >
-class __shared_ptr : __shared_ptr_access< _Tp, _Lp > { // { dg-lto-warning "7: type 'struct __shared_ptr' violates the C\\+\\+ One Definition Rule" }
+class __shared_ptr : __shared_ptr_access< _Tp, _Lp > {
   using element_type = _Tp;
   element_type *_M_ptr;
   __shared_count< _Lp > _M_refcount;
@@ -90,7 +90,7 @@  class ExtNameBuff;
 class ExtSheetBuffer;
 class ExcelToSc;
 class XclImpColRowSettings;
-struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" }
+struct RootData { 
   BiffTyp eDateiTyp;
   ExtSheetBuffer *pExtSheetBuff;
   SharedFormulaBuffer *pShrfmlaBuff;
@@ -105,7 +105,7 @@  class ScExtDocOptions;
 class XclFontPropSetHelper;
 class XclChPropSetHelper;
 class XclTracer;
-struct XclRootData { // { dg-lto-warning "8: type 'struct XclRootData' violates the C\\+\\+ One Definition Rule" }
+struct XclRootData {
   typedef std::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef;
   typedef std::shared_ptr< ScHeaderEditEngine > ScHeaderEERef;
   typedef std::shared_ptr< EditEngine > EditEngineRef;
@@ -141,12 +141,12 @@  struct XclRootData { // { dg-lto-warning
   RootDataRef mxRD;
   virtual ~XclRootData();
 };
-class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" }
+class XclRoot {
 public:
   virtual ~XclRoot();
   XclRootData &mrData;
 };
-class XclImpRoot : XclRoot {}; // { dg-lto-warning "7: type 'struct XclImpRoot' violates the C\\+\\+ One Definition Rule" }
+class XclImpRoot : XclRoot {}; 
 class XclImpColRowSettings : XclImpRoot {};
 void lcl_ExportExcelBiff() {
 XclRootData aExpData();
Index: testsuite/g++.dg/lto/pr84805_1.C
===================================================================
--- testsuite/g++.dg/lto/pr84805_1.C	(revision 261546)
+++ testsuite/g++.dg/lto/pr84805_1.C	(working copy)
@@ -1,9 +1,9 @@ 
-class XclRoot {
+class XclRoot { // { dg-lto-warning "7: type 'struct XclRoot' violates the C\\+\\+ One Definition Rule" }
 public:
   virtual ~XclRoot();
 };
 class XclImpRoot : XclRoot {};
-struct RootData {
+struct RootData { // { dg-lto-warning "8: type 'struct RootData' violates the C\\+\\+ One Definition Rule" }
   XclImpRoot pIR;
 };
 class ExcRoot {