Fix stack overflow with autofdo (PR83355)
authorAndi Kleen <ak@linux.intel.com>
Mon, 11 Dec 2017 16:13:53 +0000 (16:13 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Mon, 11 Dec 2017 16:13:53 +0000 (16:13 +0000)
g++.dg/bprob* is failing currently with autofdo.

Running in gdb shows that there is a very deep recursion in get_index_by_decl until it
overflows the stack.

gcc/:
2017-12-11  Andi Kleen  <ak@linux.intel.com>

PR gcov-profile/83355
* auto-profile.c (string_table::get_index_by_decl): Don't
recurse when abstract origin points to itself.

From-SVN: r255540

gcc/ChangeLog
gcc/auto-profile.c
gcc/lto-streamer-in.c

index a00bff3348251ad974e532e93868950f2707c1e4..75a4dc4c35a577f9b646d0f793d9a299765fd36a 100644 (file)
@@ -1,3 +1,9 @@
+2017-12-11  Andi Kleen  <ak@linux.intel.com>
+
+       PR gcov-profile/83355
+       * auto-profile.c (string_table::get_index_by_decl): Don't
+       recurse when abstract origin points to itself.
+
 2017-12-11  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/83320
index 5134a7953314d1103c88ec6154c2285f0ae312f9..403709bad6b867dc9044534727dfd94b59e6f71c 100644 (file)
@@ -477,7 +477,7 @@ string_table::get_index_by_decl (tree decl) const
   ret = get_index (lang_hooks.dwarf_name (decl, 0));
   if (ret != -1)
     return ret;
-  if (DECL_ABSTRACT_ORIGIN (decl))
+  if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl)
     return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));
 
   return -1;
index fd6bd06ffb2219c2f553a59b2800eb5c450426db..3db1d38d535de72c0935a023d1c1f59c55cd381e 100644 (file)
@@ -360,6 +360,8 @@ lto_input_tree_ref (struct lto_input_block *ib, struct data_in *data_in,
     case LTO_label_decl_ref:
     case LTO_translation_unit_decl_ref:
     case LTO_namelist_decl_ref:
+      if (!data_in->file_data->current_decl_state)
+             printf("tag %d\n", tag);
       ix_u = streamer_read_uhwi (ib);
       result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u);
       break;