https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69044

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-01-07
                 CC|                            |jamborm at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Well, duplicate_thunk_for_node was written with normal C++ thunks,
that get expanded in expand_thunk, in mind.  The chkp thunks seem to
be quite different beasts.  I have to leave today so the following are
the changes I was experimenting with in the last hour or so.  They are
still not sufficient, the compiler still ICEs in unreachable
node_analysis because it happens to see a thunk with no callee
(callees are removed when materializing clones).


diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 8759ce4..a305e85 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -283,7 +283,9 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node
*node)
        && cs->caller->thunk.this_adjusting == thunk->thunk.this_adjusting
        && cs->caller->thunk.fixed_offset == thunk->thunk.fixed_offset
        && cs->caller->thunk.virtual_offset_p == thunk->thunk.virtual_offset_p
-       && cs->caller->thunk.virtual_value == thunk->thunk.virtual_value)
+       && cs->caller->thunk.virtual_value == thunk->thunk.virtual_value
+       && (cs->caller->thunk.add_pointer_bounds_args
+           == thunk->thunk.add_pointer_bounds_args))
       return cs->caller;

   tree new_decl;
@@ -318,13 +320,24 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node
*node)
   *link = NULL_TREE;

   gcc_checking_assert (!DECL_STRUCT_FUNCTION (new_decl));
-  gcc_checking_assert (!DECL_INITIAL (new_decl));
-  gcc_checking_assert (!DECL_RESULT (new_decl));
+  gcc_checking_assert (!DECL_INITIAL (new_decl)
+                      || thunk->thunk.add_pointer_bounds_args);
+  gcc_checking_assert (!DECL_RESULT (new_decl)
+                      || thunk->thunk.add_pointer_bounds_args);
   gcc_checking_assert (!DECL_RTL_SET_P (new_decl));

-  DECL_NAME (new_decl) = clone_function_name (thunk->decl,
"artificial_thunk");
-  SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
+  if (thunk->thunk.add_pointer_bounds_args)
+    {
+      std::string s = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl));
+      s += ".chkp";
+      tree new_name = get_identifier (s.c_str ());
+      IDENTIFIER_TRANSPARENT_ALIAS (new_name) = 1;
+      TREE_CHAIN (new_name) = DECL_ASSEMBLER_NAME (node->decl);
+    }
+  else
+    DECL_NAME (new_decl) = clone_function_name (thunk->decl,
"artificial_thunk");

+  SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
   new_thunk = cgraph_node::create (new_decl);
   set_new_clone_decl_and_node_flags (new_thunk);
   new_thunk->definition = true;
@@ -335,8 +348,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node
*node)
   new_thunk->clone.args_to_skip = node->clone.args_to_skip;
   new_thunk->clone.combined_args_to_skip = node->clone.combined_args_to_skip;

-  cgraph_edge *e = new_thunk->create_edge (node, NULL, 0,
-                                                 CGRAPH_FREQ_BASE);
+  cgraph_edge *e = new_thunk->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE);
   e->call_stmt_cannot_inline_p = true;
   symtab->call_edge_duplication_hooks (thunk->callees, e);
   symtab->call_cgraph_duplication_hooks (thunk, new_thunk);
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 7d7f4ac..d7d6dee 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -875,7 +875,8 @@ propagate (void)

          /* Create the complimentary sets.  */

-         if (bitmap_empty_p (node_g->statics_read))
+         if (!node_g->statics_read
+             || bitmap_empty_p (node_g->statics_read))
            opt->statics_not_read = all_module_statics;
          else
            {
@@ -887,7 +888,8 @@ propagate (void)
                                  node_g->statics_read);
            }

-         if (bitmap_empty_p (node_g->statics_written))
+         if (!node_g->statics_written
+             || bitmap_empty_p (node_g->statics_written))
            opt->statics_not_written = all_module_statics;
          else
            {

Reply via email to