]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* cgraphbuild.c (build_cgraph_edges): Do not finalize vars
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 May 2012 07:01:39 +0000 (07:01 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 9 May 2012 07:01:39 +0000 (07:01 +0000)
with VALUE_EXPR.
* cgraph.h (varpool_can_remove_if_no_refs): Vars with VALUE_EXPR
are removable.
* toplev.c (wrapup_global_declaration_2): Vars with VALUE_EXPR
need to wrapup.
(compile_file): Do not output variables.
* cgraphbuild.c (varpool_finalize_decl): When var is finalized late,
output it.
* langhooks.c: Include timevar.h
(write_global_declarations): Finalize compilation unit after wrapup;
set timevars correctly.
* passes.c (rest_of_decl_compilation): Decls with VALUE_EXPR needs
not to be added to varpool.
* varpool.c (varpool_assemble_decl): Sanity check that we are called
only on cases where it makes sense; skip constant pool and value expr
vars.

* lto.c (do_whole_program_analysis): Set timevars correctly.
(lto_main): Likewise.

* trans-common.c (create_common): Do not fake TREE_ASM_WRITTEN.
* trans-decl.c (gfc_finish_cray_pointee): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187314 138bc75d-0d04-0410-961f-82ee72b054a4

13 files changed:
gcc/ChangeLog
gcc/cgraph.h
gcc/cgraphbuild.c
gcc/cgraphunit.c
gcc/fortran/ChangeLog
gcc/fortran/trans-common.c
gcc/fortran/trans-decl.c
gcc/langhooks.c
gcc/lto/ChangeLog
gcc/lto/lto.c
gcc/passes.c
gcc/toplev.c
gcc/varpool.c

index 986f2c104360c63b2a9ec3067bb608b8fb47151a..4d154702361c9382d6a818254edffb3344b3fe4e 100644 (file)
@@ -1,3 +1,23 @@
+2012-05-08  Jan Hubicka  <jh@suse.cz>
+
+       * cgraphbuild.c (build_cgraph_edges): Do not finalize vars
+       with VALUE_EXPR.
+       * cgraph.h (varpool_can_remove_if_no_refs): Vars with VALUE_EXPR
+       are removable.
+       * toplev.c (wrapup_global_declaration_2): Vars with VALUE_EXPR
+       need to wrapup.
+       (compile_file): Do not output variables.
+       * cgraphbuild.c (varpool_finalize_decl): When var is finalized late,
+       output it.
+       * langhooks.c: Include timevar.h
+       (write_global_declarations): Finalize compilation unit after wrapup;
+       set timevars correctly.
+       * passes.c (rest_of_decl_compilation): Decls with VALUE_EXPR needs
+       not to be added to varpool.
+       * varpool.c (varpool_assemble_decl): Sanity check that we are called
+       only on cases where it makes sense; skip constant pool and value expr
+       vars.
+
 2012-05-08  David S. Miller  <davem@davemloft.net>
 
        * config/sparc/linux.h (LINK_SPEC): Don't pass "-Y" option.
index ad1b258d485c1d910398d8b745c361b2511d87d2..ca8650d4d8f719bff2b0185d4abfebf61eaaa63a 100644 (file)
@@ -1126,6 +1126,7 @@ varpool_can_remove_if_no_refs (struct varpool_node *node)
   return (!node->symbol.force_output && !node->symbol.used_from_other_partition
          && (DECL_COMDAT (node->symbol.decl)
          || !node->symbol.externally_visible
+         || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)
          || DECL_EXTERNAL (node->symbol.decl)));
 }
 
index 3abf869684eb9de18d81d3c1646814afb264f3f6..ea5351342c076c1c04ca35af6ffd0719cbafa418 100644 (file)
@@ -356,7 +356,8 @@ build_cgraph_edges (void)
   /* Look for initializers of constant variables and private statics.  */
   FOR_EACH_LOCAL_DECL (cfun, ix, decl)
     if (TREE_CODE (decl) == VAR_DECL
-       && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl)))
+       && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+       && !DECL_HAS_VALUE_EXPR_P (decl))
       varpool_finalize_decl (decl);
   record_eh_tables (node, cfun);
 
index 4c44d91af51d2fc6582e02ddb45a0a7d2c2752a6..781ca4bda5ffcb2f732aa81b262f66ed15ac6de1 100644 (file)
@@ -834,6 +834,10 @@ varpool_finalize_decl (tree decl)
     enqueue_node ((symtab_node)node);
   if (cgraph_state >= CGRAPH_STATE_IPA_SSA)
     varpool_analyze_node (node);
+  /* Some frontends produce various interface variables after compilation
+     finished.  */
+  if (cgraph_state == CGRAPH_STATE_FINISHED)
+    varpool_assemble_decl (node);
 }
 
 /* Discover all functions and variables that are trivially needed, analyze
index 5c580069dafa953faa1d52a1481227c1bf68c2f3..b26b5c72735309364393547a0413b4935ff044b3 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-08  Jan Hubicka  <jh@suse.cz>
+       
+       * trans-common.c (create_common): Do not fake TREE_ASM_WRITTEN.
+       * trans-decl.c (gfc_finish_cray_pointee): Likewise.
+
 2012-05-07  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/53255
index dcc2176a246ddcf4d61e8b4d9b84901efcc080c4..ce7114fb88dc8879c031dfaa12ca378576a934d6 100644 (file)
@@ -697,8 +697,6 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
        DECL_IGNORED_P (var_decl) = 1;
       if (s->sym->attr.target)
        TREE_ADDRESSABLE (var_decl) = 1;
-      /* This is a fake variable just for debugging purposes.  */
-      TREE_ASM_WRITTEN (var_decl) = 1;
       /* Fake variables are not visible from other translation units. */
       TREE_PUBLIC (var_decl) = 0;
 
index 9196f0a33098b52e33e536b64cbe7246f25b459c..b03d393aa8e77d3b9516b6cb47f6d149c9d0af4c 100644 (file)
@@ -457,8 +457,6 @@ gfc_finish_cray_pointee (tree decl, gfc_symbol *sym)
   SET_DECL_VALUE_EXPR (decl, value);
   DECL_HAS_VALUE_EXPR_P (decl) = 1;
   GFC_DECL_CRAY_POINTEE (decl) = 1;
-  /* This is a fake variable just for debugging purposes.  */
-  TREE_ASM_WRITTEN (decl) = 1;
 }
 
 
index cb5da8c36feb44ac3ec9bce5d1f8f58b0c838aaa..340cc99fa2925691bb77f397eba1306fe62cdb0b 100644 (file)
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "tree-diagnostic.h"
 #include "cgraph.h"
+#include "timevar.h"
 #include "output.h"
 
 /* Do nothing; in many cases the default hook.  */
@@ -298,10 +299,7 @@ write_global_declarations (void)
   tree globals, decl, *vec;
   int len, i;
 
-  /* This lang hook is dual-purposed, and also finalizes the
-     compilation unit.  */
-  finalize_compilation_unit ();
-
+  timevar_start (TV_PHASE_DEFERRED);
   /* Really define vars that have had only a tentative definition.
      Really output inline functions that must actually be callable
      and have not been output so far.  */
@@ -318,7 +316,17 @@ write_global_declarations (void)
 
   wrapup_global_declarations (vec, len);
   check_global_declarations (vec, len);
+  timevar_stop (TV_PHASE_DEFERRED);
+
+  timevar_start (TV_PHASE_CGRAPH);
+  /* This lang hook is dual-purposed, and also finalizes the
+     compilation unit.  */
+  finalize_compilation_unit ();
+  timevar_stop (TV_PHASE_CGRAPH);
+
+  timevar_start (TV_PHASE_CHECK_DBGINFO);
   emit_debug_global_declarations (vec, len);
+  timevar_stop (TV_PHASE_CHECK_DBGINFO);
 
   /* Clean up.  */
   free (vec);
index 8c1d9013edb8ad72fb9f26be4b1ba9f9e179999a..4be2f2b04c538082634e95c05bfd578ab11306f3 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-04  Jan Hubicka  <jh@suse.cz>
+
+       * lto.c (do_whole_program_analysis): Set timevars correctly.
+       (lto_main): Likewise.
+       
 2012-05-04  Richard Guenther  <rguenther@suse.de>
 
        * lang.opt (fwpa): Do not mark as Optimization.
index 32fc869e9835aa1a73423cfadf0699de6ab185c8..00f623f6a0d61b549d7f1420959a4fcd4546877e 100644 (file)
@@ -1958,6 +1958,7 @@ materialize_cgraph (void)
 static void
 do_whole_program_analysis (void)
 {
+  timevar_start (TV_PHASE_CGRAPH);
   /* Note that since we are in WPA mode, materialize_cgraph will not
      actually read in all the function bodies.  It only materializes
      the decls and cgraph nodes so that analysis can be performed.  */
@@ -2017,6 +2018,7 @@ do_whole_program_analysis (void)
       dump_memory_report (false);
     }
 
+  timevar_stop (TV_PHASE_CGRAPH);
   /* Show the LTO report before launching LTRANS.  */
   if (flag_lto_report)
     print_lto_report ();
@@ -2116,7 +2118,9 @@ lto_main (void)
 
          /* Let the middle end know that we have read and merged all of
             the input files.  */ 
+         timevar_start (TV_PHASE_CGRAPH);
          compile ();
+         timevar_stop (TV_PHASE_CGRAPH);
 
          /* FIXME lto, if the processes spawned by WPA fail, we miss
             the chance to print WPA's report, so WPA will call
index d6b9b9bc84f23a01632d1911028537c877e8db5e..c90c2231d7c354b89eb7c1a5975d3718100c9084 100644 (file)
@@ -186,6 +186,7 @@ rest_of_decl_compilation (tree decl,
       if ((at_end
           || !DECL_DEFER_OUTPUT (decl)
           || DECL_INITIAL (decl))
+         && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl))
          && !DECL_EXTERNAL (decl))
        {
          /* When reading LTO unit, we also read varpool, so do not
index a2845ab7f598344d3c6798313d8f01a3b2866dce..90b22466a9196379bb29a80cd6c5d13726326134 100644 (file)
@@ -364,7 +364,8 @@ wrapup_global_declaration_1 (tree decl)
 bool
 wrapup_global_declaration_2 (tree decl)
 {
-  if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
+  if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)
+      || (TREE_CODE (decl) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (decl)))
     return false;
 
   /* Don't write out static consts, unless we still need them.
@@ -576,7 +577,6 @@ compile_file (void)
      basically finished.  */
   if (in_lto_p || !flag_lto || flag_fat_lto_objects)
     {
-      varpool_output_variables ();
       finish_aliases_2 ();
 
       /* Likewise for mudflap static object registrations.  */
index 103b5b5f810b8e4587b82697ea2ee2df7e4b4e2c..5ab294bcd161c022d1b3fed6547c049fc9dd6931 100644 (file)
@@ -269,24 +269,42 @@ assemble_aliases (struct varpool_node *node)
 }
 
 /* Output one variable, if necessary.  Return whether we output it.  */
+
 bool
 varpool_assemble_decl (struct varpool_node *node)
 {
   tree decl = node->symbol.decl;
 
-  if (!TREE_ASM_WRITTEN (decl)
-      && !node->alias
-      && !node->symbol.in_other_partition
-      && !DECL_EXTERNAL (decl)
-      && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl)))
+  /* Aliases are outout when their target is produced or by
+     output_weakrefs.  */
+  if (node->alias)
+    return false;
+
+  /* Constant pool is output from RTL land when the reference
+     survive till this level.  */
+  if (DECL_IN_CONSTANT_POOL (decl))
+    return false;
+
+  /* Decls with VALUE_EXPR should not be in the varpool at all.  They
+     are not real variables, but just info for debugging and codegen.
+     Unfortunately at the moment emutls is not updating varpool correctly
+     after turning real vars into value_expr vars.  */
+  if (DECL_HAS_VALUE_EXPR_P (decl)
+      && !targetm.have_tls)
+    return false;
+
+  gcc_checking_assert (!TREE_ASM_WRITTEN (decl)
+                      && TREE_CODE (decl) == VAR_DECL
+                      && !DECL_HAS_VALUE_EXPR_P (decl));
+
+  if (!node->symbol.in_other_partition
+      && !DECL_EXTERNAL (decl))
     {
       assemble_variable (decl, 0, 1, 0);
-      if (TREE_ASM_WRITTEN (decl))
-       {
-         node->finalized = 1;
-         assemble_aliases (node);
-         return true;
-       }
+      gcc_assert (TREE_ASM_WRITTEN (decl));
+      node->finalized = 1;
+      assemble_aliases (node);
+      return true;
     }
 
   return false;