This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR42401
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 19 Dec 2009 12:39:59 +0100 (CET)
- Subject: [PATCH] Fix PR42401
We fail to mark local statics as indexable. This breaks as soon
as we clone a function with local statics like in this case from IPA-CP.
Bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC 2006 tested,
applied to trunk.
Richard.
2009-12-19 Richard Guenther <rguenther@suse.de>
PR lto/42401
* lto-streamer-out.c (tree_is_indexable): Local statics
are indexable.
(lto_output_tree_ref): Adjust assert.
* g++.dg/lto/20091219_0.C: New testcase.
Index: gcc/lto-streamer-out.c
===================================================================
*** gcc/lto-streamer-out.c (revision 155359)
--- gcc/lto-streamer-out.c (working copy)
*************** tree_is_indexable (tree t)
*** 638,644 ****
{
if (TREE_CODE (t) == PARM_DECL)
return false;
! else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t))
return false;
else
return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
--- 638,645 ----
{
if (TREE_CODE (t) == PARM_DECL)
return false;
! else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t)
! && !TREE_STATIC (t))
return false;
else
return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
*************** lto_output_tree_ref (struct output_block
*** 694,700 ****
case VAR_DECL:
case DEBUG_EXPR_DECL:
! gcc_assert (decl_function_context (expr) == NULL);
output_record_start (ob, LTO_global_decl_ref);
lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
break;
--- 695,702 ----
case VAR_DECL:
case DEBUG_EXPR_DECL:
! gcc_assert (decl_function_context (expr) == NULL
! || TREE_STATIC (expr));
output_record_start (ob, LTO_global_decl_ref);
lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
break;
Index: gcc/testsuite/g++.dg/lto/20091219_0.C
===================================================================
*** gcc/testsuite/g++.dg/lto/20091219_0.C (revision 0)
--- gcc/testsuite/g++.dg/lto/20091219_0.C (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ // { dg-lto-do run }
+ // { dg-lto-options {{-O3 -flto}} }
+
+ #include <string>
+ #include <map>
+
+ int main ()
+ {
+ typedef std::map<int, std::string> Map;
+ static Map m;
+
+ Map::const_iterator it = m.find(0);
+ if (it != m.end())
+ std::string s = it->second;
+
+ return 0;
+ }