OSDN Git Service

2010-06-26 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 16:47:55 +0000 (16:47 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 16:47:55 +0000 (16:47 +0000)
* tree-sra.c (convert_callers): New parameter, change fndecls of
recursive calls.
(modify_function): Pass the old decl to convert_callers.

* testsuite/gcc.dg/ipa/ipa-sra-6.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ipa-sra-6.c [new file with mode: 0644]
gcc/tree-sra.c

index ffec6e4..f723b69 100644 (file)
@@ -1,5 +1,11 @@
 2010-06-28  Martin Jambor  <mjambor@suse.cz>
 
+       * tree-sra.c (convert_callers): New parameter, change fndecls of
+       recursive calls.
+       (modify_function): Pass the old decl to convert_callers.
+
+2010-06-28  Martin Jambor  <mjambor@suse.cz>
+
        * ipa-cp.c (ipcp_init_cloned_node): Replace calls to
        ipa_check_create_node_params and ipa_initialize_node_params with
        checking asserts they are not necessary.
index d61073a..ffec3e5 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-28  Martin Jambor  <mjambor@suse.cz>
+
+       * testsuite/gcc.dg/ipa/ipa-sra-6.c: New test.
+
 2010-06-28  Jan Hubicka  <jh@suse.cz>
 
        PR tree-optimization/44687
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-6.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-6.c
new file mode 100644 (file)
index 0000000..c9a766d
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fipa-sra -fdump-tree-eipa_sra-slim"  } */
+
+struct bovid
+{
+  float a;
+  int b;
+  struct bovid *next;
+};
+
+static int
+__attribute__((noinline))
+foo (struct bovid *cow, int i)
+{
+  i++;
+  if (cow->next)
+    foo (cow->next, i);
+  return i;
+}
+
+int main (int argc, char *argv[])
+{
+  struct bovid cow;
+
+  cow.a = 7.4;
+  cow.b = 6;
+  cow.next = (struct bovid *) 0;
+
+  return foo (&cow, 0);
+}
+
+/* { dg-final { scan-tree-dump-times "foo " 1 "eipa_sra"  } } */
index 47d0e50..84d950f 100644 (file)
@@ -4167,7 +4167,8 @@ all_callers_have_enough_arguments_p (struct cgraph_node *node)
 /* Convert all callers of NODE to pass parameters as given in ADJUSTMENTS.  */
 
 static void
-convert_callers (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
+convert_callers (struct cgraph_node *node, tree old_decl,
+                ipa_parm_adjustment_vec adjustments)
 {
   tree old_cur_fndecl = current_function_decl;
   struct cgraph_edge *cs;
@@ -4214,10 +4215,11 @@ convert_callers (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
          if (gimple_code (stmt) != GIMPLE_CALL)
            continue;
          call_fndecl = gimple_call_fndecl (stmt);
-         if (call_fndecl && cgraph_get_node (call_fndecl) == node)
+         if (call_fndecl == old_decl)
            {
              if (dump_file)
                fprintf (dump_file, "Adjusting recursive call");
+             gimple_call_set_fndecl (stmt, node->decl);
              ipa_modify_call_arguments (NULL, stmt, adjustments);
            }
        }
@@ -4256,7 +4258,7 @@ modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
   ipa_modify_formal_parameters (current_function_decl, adjustments, "ISRA");
   ipa_sra_modify_function_body (adjustments);
   sra_ipa_reset_debug_stmts (adjustments);
-  convert_callers (new_node, adjustments);
+  convert_callers (new_node, node->decl, adjustments);
   cgraph_make_node_local (new_node);
   return;
 }