re PR bootstrap/47187 (profiledbootstrap failure on i386)
authorJakub Jelinek <jakub@redhat.com>
Fri, 7 Jan 2011 18:39:11 +0000 (19:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 7 Jan 2011 18:39:11 +0000 (19:39 +0100)
PR bootstrap/47187
* value-prof.c (gimple_stringop_fixed_value): Handle
lhs of the call properly.

* gcc.dg/tree-prof/pr47187.c: New test.

From-SVN: r168581

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-prof/pr47187.c [new file with mode: 0644]
gcc/value-prof.c

index 238eef6c6758d95f402782d67f00c685e4335e06..13067437af110f9b4466628ebc67064ffc411e4c 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR bootstrap/47187
+       * value-prof.c (gimple_stringop_fixed_value): Handle
+       lhs of the call properly.
+
 2011-01-07  Jan Hubicka  <jh@suse.cz>
 
        PR lto/45375
index 8ffb04983c42db07c4a162c7e3e29591acc43306..af10b248ca582083e2baa16aa0fce50238ccf44d 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR bootstrap/47187
+       * gcc.dg/tree-prof/pr47187.c: New test.
+
 2011-01-07  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/41580
diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr47187.c b/gcc/testsuite/gcc.dg/tree-prof/pr47187.c
new file mode 100644 (file)
index 0000000..467ce25
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR bootstrap/47187 */
+/* { dg-options "-O2" } */
+
+char buf[64];
+char buf2[64];
+
+void *
+foo (char *p, long size)
+{
+  return __builtin_memcpy (buf, p, size);
+}
+
+int
+main (void)
+{
+  long i;
+  for (i = 0; i < 65536; i++)
+    if (foo ("abcdefghijkl", 12) != buf)
+      __builtin_abort ();
+  if (foo (buf2, 64) != buf)
+    __builtin_abort ();
+  return 0;
+}
index 414b94887fed9e984f87f53683c252bea3364dbe..0a36ed210c85e9d38b4b3cce2f2c9ab97a503f94 100644 (file)
@@ -1,5 +1,5 @@
 /* Transformations based on profile information for values.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -1401,6 +1401,21 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob,
   e_vj->probability = REG_BR_PROB_BASE;
   e_vj->count = all - count;
 
+  /* Insert PHI node for the call result if necessary.  */
+  if (gimple_call_lhs (vcall_stmt)
+      && TREE_CODE (gimple_call_lhs (vcall_stmt)) == SSA_NAME)
+    {
+      tree result = gimple_call_lhs (vcall_stmt);
+      gimple phi = create_phi_node (result, join_bb);
+      SSA_NAME_DEF_STMT (result) = phi;
+      gimple_call_set_lhs (vcall_stmt,
+                          make_ssa_name (SSA_NAME_VAR (result), vcall_stmt));
+      add_phi_arg (phi, gimple_call_lhs (vcall_stmt), e_vj, UNKNOWN_LOCATION);
+      gimple_call_set_lhs (icall_stmt,
+                          make_ssa_name (SSA_NAME_VAR (result), icall_stmt));
+      add_phi_arg (phi, gimple_call_lhs (icall_stmt), e_ij, UNKNOWN_LOCATION);
+    }
+
   /* Because these are all string op builtins, they're all nothrow.  */
   gcc_assert (!stmt_could_throw_p (vcall_stmt));
   gcc_assert (!stmt_could_throw_p (icall_stmt));