integrate.h (struct inline_remap): Add leaf_reg_map table.
authorMark Mitchell <mark@codesourcery.com>
Thu, 3 May 2001 16:14:34 +0000 (16:14 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 3 May 2001 16:14:34 +0000 (16:14 +0000)
* integrate.h (struct inline_remap): Add leaf_reg_map table.
* integrate.c (expand_inline_function): Use xcalloc to allocate
memory.
(copy_rtx_and_substitute): Use the leaf_reg_map for leaf
registers.

From-SVN: r41791

gcc/ChangeLog
gcc/integrate.c
gcc/integrate.h
gcc/testsuite/gcc.c-torture/compile/20010503-1.c [new file with mode: 0644]

index fecca4fc1e7fc09577229f21e10000ed158897af..4aaf478c1eb1f4deebca0057c550828c39abf00e 100644 (file)
@@ -1,3 +1,11 @@
+2001-05-03  Mark Mitchell  <mark@codesourcery.com>
+
+       * integrate.h (struct inline_remap): Add leaf_reg_map table.
+       * integrate.c (expand_inline_function): Use xcalloc to allocate
+       memory.
+       (copy_rtx_and_substitute): Use the leaf_reg_map for leaf
+       registers.
+
 2001-05-03  Mark Mitchell  <mark@codesourcery.com>
 
        * c-dump.c (dequeue_and_dump): Don't look at DECL_ASSEMBLER_NAME
index ba198b4c404c6ae3fa10bbb943720098addf1537..a4300303825379a3875f8135a256f680541fec20 100644 (file)
@@ -758,7 +758,7 @@ expand_inline_function (fndecl, parms, target, ignore, type,
 
   /* Allocate the structures we use to remap things.  */
 
-  map = (struct inline_remap *) xmalloc (sizeof (struct inline_remap));
+  map = (struct inline_remap *) xcalloc (1, sizeof (struct inline_remap));
   map->fndecl = fndecl;
 
   VARRAY_TREE_INIT (map->block_map, 10, "block_map");
@@ -1753,15 +1753,7 @@ copy_rtx_and_substitute (orig, map, for_lhs)
        {
          /* Some hard registers are also mapped,
             but others are not translated.  */
-         if (map->reg_map[regno] != 0
-             /* We shouldn't usually have reg_map set for return
-                register, but it may happen if we have leaf-register
-                remapping and the return register is used in one of
-                the calling sequences of a call_placeholer.  In this
-                case, we'll end up with a reg_map set for this
-                register, but we don't want to use for registers
-                marked as return values.  */
-             && ! REG_FUNCTION_VALUE_P (orig))
+         if (map->reg_map[regno] != 0)
            return map->reg_map[regno];
 
          /* If this is the virtual frame pointer, make space in current
@@ -1879,9 +1871,9 @@ copy_rtx_and_substitute (orig, map, for_lhs)
          if (map->integrating && regno < FIRST_PSEUDO_REGISTER
              && LEAF_REGISTERS[regno] && LEAF_REG_REMAP (regno) != regno)
            {
-             temp = gen_rtx_REG (mode, regno);
-             map->reg_map[regno] = temp;
-             return temp;
+             if (!map->leaf_reg_map[regno][mode])
+               map->leaf_reg_map[regno][mode] = gen_rtx_REG (mode, regno);
+             return map->leaf_reg_map[regno][mode]; 
            }
 #endif
          else
index 14606a6c1b64512a728a4b76ad76059c079d180e..52c300424fa0b3aa3ce1ecb1fd5b332fd2ba243c 100644 (file)
@@ -1,5 +1,5 @@
 /* Function integration definitions for GNU C-Compiler
-   Copyright (C) 1990, 1995, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1990, 1995, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -47,6 +47,10 @@ struct inline_remap
   /* Mapping from old registers to new registers.
      It is allocated and deallocated in `expand_inline_function' */
   rtx *reg_map;
+#if defined (LEAF_REGISTERS) && defined (LEAF_REG_REMAP)
+  /* Mapping from old leaf registers to new leaf registers.  */
+  rtx leaf_reg_map[FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES];
+#endif
   /* Mapping from old code-labels to new code-labels.
      The first element of this map is label_map[min_labelno].  */
   rtx *label_map;
diff --git a/gcc/testsuite/gcc.c-torture/compile/20010503-1.c b/gcc/testsuite/gcc.c-torture/compile/20010503-1.c
new file mode 100644 (file)
index 0000000..75005f4
--- /dev/null
@@ -0,0 +1,17 @@
+void f1 (double);
+void f2 (int);
+
+void
+foo (int type, double xx)
+{
+  if (type)
+    f1 (xx);
+  else
+    f2 (type);
+}
+
+void
+bar (int type)
+{
+  foo (type, 1.0);
+}