OSDN Git Service

* expr.c (move_block_from_reg): Try using an integral mov operation first.
[pf3gnuchains/gcc-fork.git] / gcc / integrate.c
index 8529e4b..693304a 100644 (file)
@@ -1,5 +1,5 @@
 /* Procedure integration for GNU CC.
-   Copyright (C) 1988, 1991, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1988, 91, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
 This file is part of GNU CC.
@@ -16,7 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 #include <stdio.h>
@@ -24,6 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "config.h"
 #include "rtl.h"
 #include "tree.h"
+#include "regs.h"
 #include "flags.h"
 #include "insn-config.h"
 #include "insn-flags.h"
@@ -31,7 +33,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "output.h"
 #include "integrate.h"
 #include "real.h"
+#include "except.h"
 #include "function.h"
+#include "bytecode.h"
 
 #include "obstack.h"
 #define        obstack_chunk_alloc     xmalloc
@@ -53,25 +57,25 @@ extern tree poplevel ();
   (8 * (8 + list_length (DECL_ARGUMENTS (DECL))))
 #endif
 \f
-/* Save any constant pool constants in an insn.  */
-static void save_constants ();
-
-/* Note when parameter registers are the destination of a SET.  */
-static void note_modified_parmregs ();
-
-/* Copy an rtx for save_for_inline_copying.  */
-static rtx copy_for_inline ();
-
-/* Make copies of MEMs in DECL_RTLs.  */
-static void copy_decl_rtls ();
-
-static tree copy_decl_tree ();
-static tree copy_decl_list ();
-
-static void integrate_parm_decls ();
-static void integrate_decl_tree ();
-
-static void subst_constants ();
+static rtx initialize_for_inline PROTO((tree, int, int, int, int));
+static void finish_inline      PROTO((tree, rtx));
+static void adjust_copied_decl_tree PROTO((tree));
+static tree copy_decl_list     PROTO((tree));
+static tree copy_decl_tree     PROTO((tree));
+static void copy_decl_rtls     PROTO((tree));
+static void save_constants     PROTO((rtx *));
+static void note_modified_parmregs PROTO((rtx, rtx));
+static rtx copy_for_inline     PROTO((rtx));
+static void integrate_parm_decls PROTO((tree, struct inline_remap *, rtvec));
+static void integrate_decl_tree        PROTO((tree, int, struct inline_remap *));
+static void save_constants_in_decl_trees PROTO ((tree));
+static void subst_constants    PROTO((rtx *, rtx, struct inline_remap *));
+static void restore_constants  PROTO((rtx *));
+static void set_block_origin_self PROTO((tree));
+static void set_decl_origin_self PROTO((tree));
+static void set_block_abstract_flags PROTO((tree, int));
+
+void set_decl_abstract_flags   PROTO((tree, int));
 \f
 /* Zero if the current function (whose FUNCTION_DECL is FNDECL)
    is safe and reasonable to integrate into other functions.
@@ -87,14 +91,13 @@ function_cannot_inline_p (fndecl)
   int max_insns = INTEGRATE_THRESHOLD (fndecl);
   register int ninsns = 0;
   register tree parms;
+  rtx result;
 
   /* No inlines with varargs.  `grokdeclarator' gives a warning
      message about that if `inline' is specified.  This code
      it put in to catch the volunteers.  */
   if ((last && TREE_VALUE (last) != void_type_node)
-      || (DECL_ARGUMENTS (fndecl) && DECL_NAME (DECL_ARGUMENTS (fndecl))
-         && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
-                      "__builtin_va_alist")))
+      || current_function_varargs)
     return "varargs function cannot be inline";
 
   if (current_function_calls_alloca)
@@ -108,14 +111,6 @@ function_cannot_inline_p (fndecl)
     return "function too large to be inline";
 
 #if 0
-  /* Large stacks are OK now that inlined functions can share them.  */
-  /* Don't inline functions with large stack usage,
-     since they can make other recursive functions burn up stack.  */
-  if (!DECL_INLINE (fndecl) && get_frame_size () > 100)
-    return "function stack frame for inlining";
-#endif
-
-#if 0
   /* Don't inline functions which do not specify a function prototype and
      have BLKmode argument or take the address of a parameter.  */
   for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
@@ -132,23 +127,32 @@ function_cannot_inline_p (fndecl)
   if (current_function_returns_pcc_struct)
     return "inline functions not supported for this return value type";
 
+  /* We can't inline functions that return BLKmode structures in registers.  */
+  if (TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode
+      && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))))
+    return "inline functions not supported for this return value type";
+
   /* We can't inline functions that return structures of varying size.  */
   if (int_size_in_bytes (TREE_TYPE (TREE_TYPE (fndecl))) < 0)
     return "function with varying-size return value cannot be inline";
 
-  /* Cannot inline a function with a varying size argument.  */
+  /* Cannot inline a function with a varying size argument or one that
+     receives a transparent union.  */
   for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms))
-    if (int_size_in_bytes (TREE_TYPE (parms)) < 0)
-      return "function with varying-size parameter cannot be inline";
+    {
+      if (int_size_in_bytes (TREE_TYPE (parms)) < 0)
+       return "function with varying-size parameter cannot be inline";
+      else if (TYPE_TRANSPARENT_UNION (TREE_TYPE (parms)))
+       return "function with transparent unit parameter cannot be inline";
+    }
 
   if (!DECL_INLINE (fndecl) && get_max_uid () > max_insns)
     {
-      for (ninsns = 0, insn = get_first_nonparm_insn (); insn && ninsns < max_insns;
+      for (ninsns = 0, insn = get_first_nonparm_insn ();
+          insn && ninsns < max_insns;
           insn = NEXT_INSN (insn))
-       {
-         if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
-           ninsns++;
-       }
+       if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
+         ninsns++;
 
       if (ninsns >= max_insns)
        return "function too large to be inline";
@@ -164,6 +168,28 @@ function_cannot_inline_p (fndecl)
   if (forced_labels)
     return "function with label addresses used in initializers cannot inline";
 
+  /* We cannot inline a nested function that jumps to a nonlocal label.  */
+  if (current_function_has_nonlocal_goto)
+    return "function with nonlocal goto cannot be inline";
+
+  /* This is a hack, until the inliner is taught about eh regions at
+     the start of the function.  */
+  for (insn = get_insns ();
+       insn &&
+         ! (GET_CODE (insn) == NOTE
+           && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG);
+       insn = NEXT_INSN (insn))
+    {
+      if (insn && GET_CODE (insn) == NOTE
+         && NOTE_LINE_NUMBER (insn) == NOTE_INSN_EH_REGION_BEG)
+       return "function with complex parameters cannot be inline";
+    }
+
+  /* We can't inline functions that return a PARALLEL rtx.  */
+  result = DECL_RTL (DECL_RESULT (fndecl));
+  if (result && GET_CODE (result) == PARALLEL)
+    return "inline functions not supported for this return value type";
+
   return 0;
 }
 \f
@@ -240,7 +266,7 @@ initialize_for_inline (fndecl, min_labelno, max_labelno, max_reg, copy)
        + current_function_uses_pic_offset_table * FUNCTION_FLAGS_USES_PIC_OFFSET_TABLE);
 
   /* Clear out PARMDECL_MAP.  It was allocated in the caller's frame.  */
-  bzero (parmdecl_map, max_parm_reg * sizeof (tree));
+  bzero ((char *) parmdecl_map, max_parm_reg * sizeof (tree));
   arg_vector = rtvec_alloc (list_length (DECL_ARGUMENTS (fndecl)));
 
   for (parms = DECL_ARGUMENTS (fndecl), i = 0;
@@ -271,6 +297,17 @@ initialize_for_inline (fndecl, min_labelno, max_labelno, max_reg, copy)
 
       if (GET_CODE (p) == REG)
        parmdecl_map[REGNO (p)] = parms;
+      else if (GET_CODE (p) == CONCAT)
+       {
+         rtx preal = gen_realpart (GET_MODE (XEXP (p, 0)), p);
+         rtx pimag = gen_imagpart (GET_MODE (preal), p);
+
+         if (GET_CODE (preal) == REG)
+           parmdecl_map[REGNO (preal)] = parms;
+         if (GET_CODE (pimag) == REG)
+           parmdecl_map[REGNO (pimag)] = parms;
+       }
+
       /* This flag is cleared later
         if the function ever modifies the value of the parm.  */
       TREE_READONLY (parms) = 1;
@@ -292,18 +329,22 @@ initialize_for_inline (fndecl, min_labelno, max_labelno, max_reg, copy)
      the size of the incoming stack area for parameters,
      the number of bytes popped on return,
      the stack slot list,
+     the labels that are forced to exist,
      some flags that are used to restore compiler globals,
      the value of current_function_outgoing_args_size,
      the original argument vector,
-     and the original DECL_INITIAL.  */
+     the original DECL_INITIAL,
+     and pointers to the table of psuedo regs, pointer flags, and alignment. */
 
   return gen_inline_header_rtx (NULL_RTX, NULL_RTX, min_labelno, max_labelno,
                                max_parm_reg, max_reg,
                                current_function_args_size,
                                current_function_pops_args,
-                               stack_slot_list, function_flags,
+                               stack_slot_list, forced_labels, function_flags,
                                current_function_outgoing_args_size,
-                               arg_vector, (rtx) DECL_INITIAL (fndecl));
+                               arg_vector, (rtx) DECL_INITIAL (fndecl),
+                               (rtvec) regno_reg_rtx, regno_pointer_flag,
+                               regno_pointer_align);
 }
 
 /* Subroutine for `save_for_inline{copying,nocopy}'.  Finishes up the
@@ -315,11 +356,10 @@ finish_inline (fndecl, head)
      tree fndecl;
      rtx head;
 {
-  NEXT_INSN (head) = get_first_nonparm_insn ();
+  FIRST_FUNCTION_INSN (head) = get_first_nonparm_insn ();
   FIRST_PARM_INSN (head) = get_insns ();
   DECL_SAVED_INSNS (fndecl) = head;
   DECL_FRAME_SIZE (fndecl) = get_frame_size ();
-  DECL_INLINE (fndecl) = 1;
 }
 
 /* Adjust the BLOCK_END_NOTE pointers in a given copied DECL tree so that
@@ -357,6 +397,11 @@ adjust_copied_decl_tree (block)
    compiled.  Our caller (rest_of_compilation) saves the original
    DECL_INITIAL and DECL_ARGUMENTS; here we copy them.  */
 
+/* ??? The nonlocal_label list should be adjusted also.  However, since
+   a function that contains a nested function never gets inlined currently,
+   the nonlocal_label list will always be empty, so we don't worry about
+   it for now.  */
+
 void
 save_for_inline_copying (fndecl)
      tree fndecl;
@@ -367,9 +412,10 @@ save_for_inline_copying (fndecl)
   int max_reg;
   int max_uid;
   rtx first_nonparm_insn;
+  char *new, *new1;
 
   /* Make and emit a return-label if we have not already done so. 
-     Do this before recording the bounds on label numbers. */
+     Do this before recording the bounds on label numbers.  */
 
   if (return_label == 0)
     {
@@ -406,6 +452,10 @@ save_for_inline_copying (fndecl)
              save_constants (&REG_NOTES (insn));
          }
 
+      /* Also scan all decls, and replace any constant pool references with the
+        actual constant.  */
+      save_constants_in_decl_trees (DECL_INITIAL (fndecl));
+
       /* Clear out the constant pool so that we can recreate it with the
         copied constants below.  */
       init_const_rtx_hash_table ();
@@ -445,16 +495,20 @@ save_for_inline_copying (fndecl)
      Make these new rtx's now, and install them in regno_reg_rtx, so they
      will be the official pseudo-reg rtx's for the rest of compilation.  */
 
-  reg_map = (rtx *) alloca ((max_reg + 1) * sizeof (rtx));
+  reg_map = (rtx *) savealloc (regno_pointer_flag_length * sizeof (rtx));
 
   len = sizeof (struct rtx_def) + (GET_RTX_LENGTH (REG) - 1) * sizeof (rtunion);
   for (i = max_reg - 1; i > LAST_VIRTUAL_REGISTER; i--)
     reg_map[i] = (rtx)obstack_copy (function_maybepermanent_obstack,
                                    regno_reg_rtx[i], len);
 
-  bcopy (reg_map + LAST_VIRTUAL_REGISTER + 1,
-        regno_reg_rtx + LAST_VIRTUAL_REGISTER + 1,
-        (max_reg - (LAST_VIRTUAL_REGISTER + 1)) * sizeof (rtx));
+  regno_reg_rtx = reg_map;
+
+  /* Put copies of all the virtual register rtx into the new regno_reg_rtx.  */
+  regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
+  regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
+  regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
+  regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
 
   /* Likewise each label rtx must have a unique rtx as its copy.  */
 
@@ -467,7 +521,7 @@ save_for_inline_copying (fndecl)
   /* Record the mapping of old insns to copied insns.  */
 
   insn_map = (rtx *) alloca (max_uid * sizeof (rtx));
-  bzero (insn_map, max_uid * sizeof (rtx));
+  bzero ((char *) insn_map, max_uid * sizeof (rtx));
 
   /* Get the insn which signals the end of parameter setup code.  */
   first_nonparm_insn = get_first_nonparm_insn ();
@@ -532,15 +586,30 @@ save_for_inline_copying (fndecl)
              NOTE_SOURCE_FILE (insn) = (char *) copy;
              NOTE_SOURCE_FILE (copy) = 0;
            }
+         if (NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_BEG
+             || NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_END)
+           {
+             /* We have to forward these both to match the new exception
+                region.  */
+             NOTE_BLOCK_NUMBER (copy)
+               = CODE_LABEL_NUMBER (label_map[NOTE_BLOCK_NUMBER (copy)]);
+             
+           }
+         RTX_INTEGRATED_P (copy) = RTX_INTEGRATED_P (insn);
          break;
 
        case INSN:
-       case CALL_INSN:
        case JUMP_INSN:
+       case CALL_INSN:
          copy = rtx_alloc (GET_CODE (insn));
+
+         if (GET_CODE (insn) == CALL_INSN)
+           CALL_INSN_FUNCTION_USAGE (copy) =
+                  copy_for_inline (CALL_INSN_FUNCTION_USAGE (insn));
+
          PATTERN (copy) = copy_for_inline (PATTERN (insn));
          INSN_CODE (copy) = -1;
-         LOG_LINKS (copy) = NULL;
+         LOG_LINKS (copy) = NULL_RTX;
          RTX_INTEGRATED_P (copy) = RTX_INTEGRATED_P (insn);
          break;
 
@@ -576,6 +645,15 @@ save_for_inline_copying (fndecl)
 
   finish_inline (fndecl, head);
 
+  /* Make new versions of the register tables.  */
+  new = (char *) savealloc (regno_pointer_flag_length);
+  bcopy (regno_pointer_flag, new, regno_pointer_flag_length);
+  new1 = (char *) savealloc (regno_pointer_flag_length);
+  bcopy (regno_pointer_align, new1, regno_pointer_flag_length);
+
+  regno_pointer_flag = new;
+  regno_pointer_align = new1;
+
   set_new_first_and_last_insn (first_insn, last_insn);
 }
 
@@ -636,7 +714,7 @@ copy_decl_tree (block)
   BLOCK_VARS (t) = vars;
   BLOCK_SUBBLOCKS (t) = nreverse (subblocks);
   /* If the BLOCK being cloned is already marked as having been instantiated
-     from something else, then leave that `origin' marking alone.  Elsewise,
+     from something else, then leave that `origin' marking alone.  Otherwise,
      mark the clone as having originated from the BLOCK we are cloning.  */
   if (BLOCK_ABSTRACT_ORIGIN (t) == NULL_TREE)
     BLOCK_ABSTRACT_ORIGIN (t) = block;
@@ -674,23 +752,18 @@ copy_decl_rtls (block)
    modified.  In the second case, FNDECL is used for the last time,
    so modifying the rtl is not a problem.
 
-   ??? Actually, we do not verify that FNDECL is not inline expanded
-   by other functions which must also be written down at the end
-   of compilation.  We could set flag_no_inline to nonzero when
-   the time comes to write down such functions.  */
+   We don't have to worry about FNDECL being inline expanded by
+   other functions which are written at the end of compilation
+   because flag_no_inline is turned on when we begin writing
+   functions at the end of compilation.  */
 
 void
 save_for_inline_nocopy (fndecl)
      tree fndecl;
 {
   rtx insn;
-  rtx head, copy;
-  tree parms;
-  int max_labelno, min_labelno, i, len;
-  int max_reg;
-  int max_uid;
+  rtx head;
   rtx first_nonparm_insn;
-  int function_flags;
 
   /* Set up PARMDECL_MAP which maps pseudo-reg number to its PARM_DECL.
      Later we set TREE_READONLY to 0 if the parm is modified inside the fn.
@@ -752,6 +825,10 @@ save_for_inline_nocopy (fndecl)
        }
     }
 
+  /* Also scan all decls, and replace any constant pool references with the
+     actual constant.  */
+  save_constants_in_decl_trees (DECL_INITIAL (fndecl));
+
   /* We have now allocated all that needs to be allocated permanently
      on the rtx obstack.  Set our high-water mark, so that we
      can free the rest of this when the time comes.  */
@@ -765,8 +842,8 @@ save_for_inline_nocopy (fndecl)
    pool.  Replace each with a CONST that has the mode of the original
    constant, contains the constant, and has RTX_INTEGRATED_P set.
    Similarly, constant pool addresses not enclosed in a MEM are replaced
-   with an ADDRESS rtx which also gives the constant, mode, and has
-   RTX_INTEGRATED_P set.  */
+   with an ADDRESS and CONST rtx which also gives the constant, its
+   mode, the mode of the address, and has RTX_INTEGRATED_P set.  */
 
 static void
 save_constants (px)
@@ -805,7 +882,9 @@ save_constants (px)
   else if (GET_CODE (x) == SYMBOL_REF
           && CONSTANT_POOL_ADDRESS_P (x))
     {
-      *px = gen_rtx (ADDRESS, get_pool_mode (x), get_pool_constant (x));
+      *px = gen_rtx (ADDRESS, GET_MODE (x),
+                    gen_rtx (CONST, get_pool_mode (x),
+                             get_pool_constant (x)));
       save_constants (&XEXP (*px, 0));
       RTX_INTEGRATED_P (*px) = 1;
     }
@@ -872,6 +951,7 @@ copy_for_inline (orig)
      rtx orig;
 {
   register rtx x = orig;
+  register rtx new;
   register int i;
   register enum rtx_code code;
   register char *format_ptr;
@@ -900,7 +980,7 @@ copy_for_inline (orig)
          REAL_VALUE_TYPE d;
 
          REAL_VALUE_FROM_CONST_DOUBLE (d, x);
-         return immed_real_const_1 (d, GET_MODE (x));
+         return CONST_DOUBLE_FROM_REAL_VALUE (d, GET_MODE (x));
        }
       else
        return immed_double_const (CONST_DOUBLE_LOW (x), CONST_DOUBLE_HIGH (x),
@@ -917,9 +997,8 @@ copy_for_inline (orig)
       /* Get constant pool entry, but access in different mode.  */
       if (RTX_INTEGRATED_P (x))
        {
-         rtx new
-           = force_const_mem (GET_MODE (SUBREG_REG (x)),
-                              copy_for_inline (XEXP (SUBREG_REG (x), 0)));
+         new = force_const_mem (GET_MODE (SUBREG_REG (x)),
+                                copy_for_inline (XEXP (SUBREG_REG (x), 0)));
 
          PUT_MODE (new, GET_MODE (x));
          return validize_mem (new);
@@ -932,8 +1011,16 @@ copy_for_inline (orig)
       if (! RTX_INTEGRATED_P (x))
        abort ();
 
-      return XEXP (force_const_mem (GET_MODE (x),
-                                   copy_for_inline (XEXP (x, 0))), 0);
+      new = force_const_mem (GET_MODE (XEXP (x, 0)),
+                            copy_for_inline (XEXP (XEXP (x, 0), 0)));
+      new = XEXP (new, 0);
+
+#ifdef POINTERS_EXTEND_UNSIGNED
+      if (GET_MODE (new) != GET_MODE (x))
+       new = convert_memory_address (GET_MODE (x), new);
+#endif
+
+      return new;
 
     case ASM_OPERANDS:
       /* If a single asm insn contains multiple output operands
@@ -942,6 +1029,7 @@ copy_for_inline (orig)
       if (orig_asm_operands_vector == XVEC (orig, 3))
        {
          x = rtx_alloc (ASM_OPERANDS);
+         x->volatil = orig->volatil;
          XSTR (x, 0) = XSTR (orig, 0);
          XSTR (x, 1) = XSTR (orig, 1);
          XINT (x, 2) = XINT (orig, 2);
@@ -1046,8 +1134,9 @@ copy_for_inline (orig)
   /* Replace this rtx with a copy of itself.  */
 
   x = rtx_alloc (code);
-  bcopy (orig, x, (sizeof (*x) - sizeof (x->fld)
-                  + sizeof (x->fld[0]) * GET_RTX_LENGTH (code)));
+  bcopy ((char *) orig, (char *) x,
+        (sizeof (*x) - sizeof (x->fld)
+         + sizeof (x->fld[0]) * GET_RTX_LENGTH (code)));
 
   /* Now scan the subexpressions recursively.
      We can store any replaced subexpressions directly into X
@@ -1075,7 +1164,7 @@ copy_for_inline (orig)
            {
              register int j;
 
-             XVEC (x, i) = gen_rtvec_v (XVECLEN (x, i), &XVECEXP (x, i, 0));
+             XVEC (x, i) = gen_rtvec_vv (XVECLEN (x, i), XVEC (x, i)->elem);
              for (j = 0; j < XVECLEN (x, i); j++)
                XVECEXP (x, i, j)
                  = copy_for_inline (XVECEXP (x, i, j));
@@ -1099,6 +1188,7 @@ copy_for_inline (orig)
    is used properly in the presence of recursion.  */
 
 rtx *global_const_equiv_map;
+int global_const_equiv_map_size;
 \f
 #define FIXED_BASE_PLUS_P(X) \
   (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == CONST_INT \
@@ -1120,7 +1210,8 @@ rtx *global_const_equiv_map;
    else an rtx for where the value is stored.  */
 
 rtx
-expand_inline_function (fndecl, parms, target, ignore, type, structure_value_addr)
+expand_inline_function (fndecl, parms, target, ignore, type,
+                       structure_value_addr)
      tree fndecl, parms;
      rtx target;
      int ignore;
@@ -1141,6 +1232,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   int nargs;
   rtx local_return_label = 0;
   rtx loc;
+  rtx stack_save = 0;
   rtx temp;
   struct inline_remap *map;
   rtx cc0_insn = 0;
@@ -1154,29 +1246,39 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
 
   nargs = list_length (DECL_ARGUMENTS (fndecl));
 
-  /* We expect PARMS to have the right length; don't crash if not.  */
-  if (list_length (parms) != nargs)
-    return (rtx) (HOST_WIDE_INT) -1;
-  /* Also check that the parms type match.  Since the appropriate
-     conversions or default promotions have already been applied,
-     the machine modes should match exactly.  */
-  for (formal = DECL_ARGUMENTS (fndecl),
-       actual = parms;
+  /* Check that the parms type match and that sufficient arguments were
+     passed.  Since the appropriate conversions or default promotions have
+     already been applied, the machine modes should match exactly.  */
+
+  for (formal = DECL_ARGUMENTS (fndecl), actual = parms;
        formal;
-       formal = TREE_CHAIN (formal),
-       actual = TREE_CHAIN (actual))
+       formal = TREE_CHAIN (formal), actual = TREE_CHAIN (actual))
     {
-      tree arg = TREE_VALUE (actual);
-      enum machine_mode mode = TYPE_MODE (DECL_ARG_TYPE (formal));
-      if (mode != TYPE_MODE (TREE_TYPE (arg)))
+      tree arg;
+      enum machine_mode mode;
+
+      if (actual == 0)
        return (rtx) (HOST_WIDE_INT) -1;
-      /* If they are block mode, the types should match exactly.
-         They don't match exactly if TREE_TYPE (FORMAL) == ERROR_MARK_NODE,
-        which could happen if the parameter has incomplete type.  */
-      if (mode == BLKmode && TREE_TYPE (arg) != TREE_TYPE (formal))
+
+      arg = TREE_VALUE (actual);
+      mode = TYPE_MODE (DECL_ARG_TYPE (formal));
+
+      if (mode != TYPE_MODE (TREE_TYPE (arg))
+         /* If they are block mode, the types should match exactly.
+            They don't match exactly if TREE_TYPE (FORMAL) == ERROR_MARK_NODE,
+            which could happen if the parameter has incomplete type.  */
+         || (mode == BLKmode
+             && (TYPE_MAIN_VARIANT (TREE_TYPE (arg))
+                 != TYPE_MAIN_VARIANT (TREE_TYPE (formal)))))
        return (rtx) (HOST_WIDE_INT) -1;
     }
 
+  /* Extra arguments are valid, but will be ignored below, so we must
+     evaluate them here for side-effects.  */
+  for (; actual; actual = TREE_CHAIN (actual))
+    expand_expr (TREE_VALUE (actual), const0_rtx,
+                TYPE_MODE (TREE_TYPE (TREE_VALUE (actual))), 0);
+
   /* Make a binding contour to keep inline cleanups called at
      outer function-scope level from looking like they are shadowing
      parameter declarations.  */
@@ -1185,14 +1287,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   /* Make a fresh binding contour that we can easily remove.  */
   pushlevel (0);
   expand_start_bindings (0);
-  if (GET_CODE (parm_insns) == NOTE
-      && NOTE_LINE_NUMBER (parm_insns) > 0)
-    {
-      rtx note = emit_note (NOTE_SOURCE_FILE (parm_insns),
-                           NOTE_LINE_NUMBER (parm_insns));
-      if (note)
-       RTX_INTEGRATED_P (note) = 1;
-    }
 
   /* Expand the function arguments.  Do this first so that any
      new registers get created before we allocate the maps.  */
@@ -1209,18 +1303,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
       tree arg = convert (TREE_TYPE (formal), TREE_VALUE (actual));
       /* Mode of the variable used within the function.  */
       enum machine_mode mode = TYPE_MODE (TREE_TYPE (formal));
-      /* Where parameter is located in the function.  */
-      rtx copy;
-
-      /* Make sure this formal has some correspondence in the users code
-       * before emitting any line notes for it.  */
-      if (DECL_SOURCE_LINE (formal))
-       {
-         rtx note = emit_note (DECL_SOURCE_FILE (formal),
-                               DECL_SOURCE_LINE (formal));
-         if (note)
-           RTX_INTEGRATED_P (note) = 1;
-       }
+      int invisiref = 0;
 
       arg_trees[i] = arg;
       loc = RTVEC_ELT (arg_vector, i);
@@ -1235,20 +1318,23 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          rtx stack_slot
            = assign_stack_temp (TYPE_MODE (TREE_TYPE (arg)),
                                 int_size_in_bytes (TREE_TYPE (arg)), 1);
+         MEM_IN_STRUCT_P (stack_slot) = AGGREGATE_TYPE_P (TREE_TYPE (arg));
 
          store_expr (arg, stack_slot, 0);
 
          arg_vals[i] = XEXP (stack_slot, 0);
+         invisiref = 1;
        }
       else if (GET_CODE (loc) != MEM)
        {
          if (GET_MODE (loc) != TYPE_MODE (TREE_TYPE (arg)))
            /* The mode if LOC and ARG can differ if LOC was a variable
               that had its mode promoted via PROMOTED_MODE.  */
-           arg_vals[i] = convert_to_mode (GET_MODE (loc),
-                                          expand_expr (arg, NULL_RTX, mode,
-                                                       EXPAND_SUM),
-                                          TREE_UNSIGNED (TREE_TYPE (formal)));
+           arg_vals[i] = convert_modes (GET_MODE (loc),
+                                        TYPE_MODE (TREE_TYPE (arg)),
+                                        expand_expr (arg, NULL_RTX, mode,
+                                                     EXPAND_SUM),
+                                        TREE_UNSIGNED (TREE_TYPE (formal)));
          else
            arg_vals[i] = expand_expr (arg, NULL_RTX, mode, EXPAND_SUM);
        }
@@ -1263,8 +1349,11 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
                 be two different pseudos, and `safe_from_p' will make all
                 sorts of smart assumptions about their not conflicting.
                 But if ARG_VALS[I] overlaps TARGET, these assumptions are
-                wrong, so put ARG_VALS[I] into a fresh register.  */
+                wrong, so put ARG_VALS[I] into a fresh register.
+                Don't worry about invisible references, since their stack
+                temps will never overlap the target.  */
              || (target != 0
+                 && ! invisiref
                  && (GET_CODE (arg_vals[i]) == REG
                      || GET_CODE (arg_vals[i]) == SUBREG
                      || GET_CODE (arg_vals[i]) == MEM)
@@ -1274,6 +1363,12 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
                 handle SUBREGs in addresses.  */
              || (GET_CODE (arg_vals[i]) == SUBREG)))
        arg_vals[i] = copy_to_mode_reg (GET_MODE (loc), arg_vals[i]);
+
+      if (arg_vals[i] != 0 && GET_CODE (arg_vals[i]) == REG
+         && TREE_CODE (TREE_TYPE (formal)) == POINTER_TYPE)
+       mark_reg_pointer (arg_vals[i],
+                         (TYPE_ALIGN (TREE_TYPE (TREE_TYPE (formal)))
+                          / BITS_PER_UNIT));
     }
        
   /* Allocate the structures we use to remap things.  */
@@ -1282,13 +1377,13 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   map->fndecl = fndecl;
 
   map->reg_map = (rtx *) alloca (max_regno * sizeof (rtx));
-  bzero (map->reg_map, max_regno * sizeof (rtx));
+  bzero ((char *) map->reg_map, max_regno * sizeof (rtx));
 
   map->label_map = (rtx *)alloca ((max_labelno - min_labelno) * sizeof (rtx));
   map->label_map -= min_labelno;
 
   map->insn_map = (rtx *) alloca (INSN_UID (header) * sizeof (rtx));
-  bzero (map->insn_map, INSN_UID (header) * sizeof (rtx));
+  bzero ((char *) map->insn_map, INSN_UID (header) * sizeof (rtx));
   map->min_insnno = 0;
   map->max_insnno = INSN_UID (header);
 
@@ -1311,17 +1406,22 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
 
   map->const_equiv_map
     = (rtx *)alloca (map->const_equiv_map_size * sizeof (rtx));
-  bzero (map->const_equiv_map, map->const_equiv_map_size * sizeof (rtx));
+  bzero ((char *) map->const_equiv_map,
+        map->const_equiv_map_size * sizeof (rtx));
 
   map->const_age_map
     = (unsigned *)alloca (map->const_equiv_map_size * sizeof (unsigned));
-  bzero (map->const_age_map, map->const_equiv_map_size * sizeof (unsigned));
+  bzero ((char *) map->const_age_map,
+        map->const_equiv_map_size * sizeof (unsigned));
   map->const_age = 0;
 
   /* Record the current insn in case we have to set up pointers to frame
      and argument memory blocks.  */
   map->insns_at_start = get_last_insn ();
 
+  map->regno_pointer_flag = INLINE_REGNO_POINTER_FLAG (header);
+  map->regno_pointer_align = INLINE_REGNO_POINTER_ALIGN (header);
+
   /* Update the outgoing argument size to allow for those in the inlined
      function.  */
   if (OUTGOING_ARGS_SIZE (header) > current_function_outgoing_args_size)
@@ -1336,6 +1436,15 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   if (FUNCTION_FLAGS (header) & FUNCTION_FLAGS_NEEDS_CONTEXT)
     static_chain_value = lookup_static_chain (fndecl);
 
+  if (GET_CODE (parm_insns) == NOTE
+      && NOTE_LINE_NUMBER (parm_insns) > 0)
+    {
+      rtx note = emit_note (NOTE_SOURCE_FILE (parm_insns),
+                           NOTE_LINE_NUMBER (parm_insns));
+      if (note)
+       RTX_INTEGRATED_P (note) = 1;
+    }
+
   /* Process each argument.  For each, set up things so that the function's
      reference to the argument will refer to the argument being passed.
      We only replace REG with REG here.  Any simplifications are done
@@ -1346,6 +1455,9 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
      register number fits in const_equiv_map.  Then we store all non-register
      parameters into their memory location.  */
 
+  /* Don't try to free temp stack slots here, because we may put one of the
+     parameters into a temp stack slot.  */
+
   for (i = 0; i < nargs; i++)
     {
       rtx copy = arg_vals[i];
@@ -1366,7 +1478,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          if (GET_CODE (copy) != REG)
            {
              temp = copy_addr_to_reg (copy);
-             if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
+             if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
+                 && REGNO (temp) < map->const_equiv_map_size)
                {
                  map->const_equiv_map[REGNO (temp)] = copy;
                  map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
@@ -1390,15 +1503,21 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
             constant equivalence.
 
             If LOC is REG_USERVAR_P, the usual case, COPY must also have
-            that flag set if it is a register.  */
+            that flag set if it is a register.
+
+            Also, don't allow hard registers here; they might not be valid
+            when substituted into insns.  */
 
          if ((GET_CODE (copy) != REG && GET_CODE (copy) != SUBREG)
              || (GET_CODE (copy) == REG && REG_USERVAR_P (loc)
-                 && ! REG_USERVAR_P (copy)))
+                 && ! REG_USERVAR_P (copy))
+             || (GET_CODE (copy) == REG
+                 && REGNO (copy) < FIRST_PSEUDO_REGISTER))
            {
              temp = copy_to_mode_reg (GET_MODE (loc), copy);
              REG_USERVAR_P (temp) = REG_USERVAR_P (loc);
-             if (CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
+             if ((CONSTANT_P (copy) || FIXED_BASE_PLUS_P (copy))
+                 && REGNO (temp) < map->const_equiv_map_size)
                {
                  map->const_equiv_map[REGNO (temp)] = copy;
                  map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
@@ -1407,11 +1526,61 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
            }
          map->reg_map[REGNO (loc)] = copy;
        }
+      else if (GET_CODE (loc) == CONCAT)
+       {
+         /* This is the good case where the parameter is in a
+            pair of separate pseudos.
+            If it is read-only and our argument is a constant, set up the
+            constant equivalence.
+
+            If LOC is REG_USERVAR_P, the usual case, COPY must also have
+            that flag set if it is a register.
+
+            Also, don't allow hard registers here; they might not be valid
+            when substituted into insns.  */
+         rtx locreal = gen_realpart (GET_MODE (XEXP (loc, 0)), loc);
+         rtx locimag = gen_imagpart (GET_MODE (XEXP (loc, 0)), loc);
+         rtx copyreal = gen_realpart (GET_MODE (locreal), copy);
+         rtx copyimag = gen_imagpart (GET_MODE (locimag), copy);
+
+         if ((GET_CODE (copyreal) != REG && GET_CODE (copyreal) != SUBREG)
+             || (GET_CODE (copyreal) == REG && REG_USERVAR_P (locreal)
+                 && ! REG_USERVAR_P (copyreal))
+             || (GET_CODE (copyreal) == REG
+                 && REGNO (copyreal) < FIRST_PSEUDO_REGISTER))
+           {
+             temp = copy_to_mode_reg (GET_MODE (locreal), copyreal);
+             REG_USERVAR_P (temp) = REG_USERVAR_P (locreal);
+             if ((CONSTANT_P (copyreal) || FIXED_BASE_PLUS_P (copyreal))
+                 && REGNO (temp) < map->const_equiv_map_size)
+               {
+                 map->const_equiv_map[REGNO (temp)] = copyreal;
+                 map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+               }
+             copyreal = temp;
+           }
+         map->reg_map[REGNO (locreal)] = copyreal;
+
+         if ((GET_CODE (copyimag) != REG && GET_CODE (copyimag) != SUBREG)
+             || (GET_CODE (copyimag) == REG && REG_USERVAR_P (locimag)
+                 && ! REG_USERVAR_P (copyimag))
+             || (GET_CODE (copyimag) == REG
+                 && REGNO (copyimag) < FIRST_PSEUDO_REGISTER))
+           {
+             temp = copy_to_mode_reg (GET_MODE (locimag), copyimag);
+             REG_USERVAR_P (temp) = REG_USERVAR_P (locimag);
+             if ((CONSTANT_P (copyimag) || FIXED_BASE_PLUS_P (copyimag))
+                 && REGNO (temp) < map->const_equiv_map_size)
+               {
+                 map->const_equiv_map[REGNO (temp)] = copyimag;
+                 map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+               }
+             copyimag = temp;
+           }
+         map->reg_map[REGNO (locimag)] = copyimag;
+       }
       else
        abort ();
-
-      /* Free any temporaries we made setting up this parameter.  */
-      free_temp_slots ();
     }
 
   /* Now do the parameters that will be placed in memory.  */
@@ -1419,8 +1588,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   for (formal = DECL_ARGUMENTS (fndecl), i = 0;
        formal; formal = TREE_CHAIN (formal), i++)
     {
-      rtx copy = arg_vals[i];
-
       loc = RTVEC_ELT (arg_vector, i);
 
       if (GET_CODE (loc) == MEM
@@ -1441,9 +1608,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
            temp = change_address (temp, VOIDmode, XEXP (temp, 0));
          store_expr (arg_trees[i], temp, 0);
-
-         /* Free any temporaries we made setting up this parameter.  */
-         free_temp_slots ();
        }
     }
 
@@ -1475,12 +1639,14 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
 
       if (GET_CODE (XEXP (loc, 0)) == REG)
        {
-         temp = force_reg (Pmode, structure_value_addr);
+         temp = force_reg (Pmode,
+                           force_operand (structure_value_addr, NULL_RTX));
          map->reg_map[REGNO (XEXP (loc, 0))] = temp;
-         if (CONSTANT_P (structure_value_addr)
-             || (GET_CODE (structure_value_addr) == PLUS
-                 && XEXP (structure_value_addr, 0) == virtual_stack_vars_rtx
-                 && GET_CODE (XEXP (structure_value_addr, 1)) == CONST_INT))
+         if ((CONSTANT_P (structure_value_addr)
+              || (GET_CODE (structure_value_addr) == PLUS
+                  && XEXP (structure_value_addr, 0) == virtual_stack_vars_rtx
+                  && GET_CODE (XEXP (structure_value_addr, 1)) == CONST_INT))
+             && REGNO (temp) < map->const_equiv_map_size)
            {
              map->const_equiv_map[REGNO (temp)] = structure_value_addr;
              map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
@@ -1523,7 +1689,21 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
         avoid machine mode mismatch when we substitute INLINE_TARGET.
         But TARGET is what we will return to the caller.  */
       if (arriving_mode != departing_mode)
-       reg_to_map = gen_rtx (SUBREG, arriving_mode, target, 0);
+       {
+         /* Avoid creating a paradoxical subreg wider than
+            BITS_PER_WORD, since that is illegal.  */
+         if (GET_MODE_BITSIZE (arriving_mode) > BITS_PER_WORD)
+           {
+             if (!TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (departing_mode),
+                                         GET_MODE_BITSIZE (arriving_mode)))
+               /* Maybe could be handled by using convert_move () ?  */
+               abort ();
+             reg_to_map = gen_reg_rtx (arriving_mode);
+             target = gen_lowpart (departing_mode, reg_to_map);
+           }
+         else
+           reg_to_map = gen_rtx (SUBREG, arriving_mode, target, 0);
+       }
       else
        reg_to_map = target;
 
@@ -1534,6 +1714,8 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
       else
        map->reg_map[REGNO (loc)] = reg_to_map;
     }
+  else
+    abort ();
 
   /* Make new label equivalences for the labels in the called function.  */
   for (i = min_labelno; i < max_labelno; i++)
@@ -1548,6 +1730,14 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   /* Save a copy of the location of const_equiv_map for mark_stores, called
      via note_stores.  */
   global_const_equiv_map = map->const_equiv_map;
+  global_const_equiv_map_size = map->const_equiv_map_size;
+
+  /* If the called function does an alloca, save and restore the
+     stack pointer around the call.  This saves stack space, but
+     also is required if this inline is being done between two
+     pushes.  */
+  if (FUNCTION_FLAGS (header) & FUNCTION_FLAGS_CALLS_ALLOCA)
+    emit_stack_save (SAVE_BLOCK, &stack_save, NULL_RTX);
 
   /* Now copy the insns one by one.  Do this in two passes, first the insns and
      then their REG_NOTES, just like save_for_inline.  */
@@ -1556,7 +1746,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
 
   for (insn = insns; insn; insn = NEXT_INSN (insn))
     {
-      rtx copy, pattern;
+      rtx copy, pattern, set;
 
       map->orig_asm_operands_vector = 0;
 
@@ -1564,6 +1754,7 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
        {
        case INSN:
          pattern = PATTERN (insn);
+         set = single_set (insn);
          copy = 0;
          if (GET_CODE (pattern) == USE
              && GET_CODE (XEXP (pattern, 0)) == REG
@@ -1575,33 +1766,52 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
 
          /* Ignore setting a function value that we don't want to use.  */
          if (map->inline_target == 0
-             && GET_CODE (pattern) == SET
-             && GET_CODE (SET_DEST (pattern)) == REG
-             && REG_FUNCTION_VALUE_P (SET_DEST (pattern)))
+             && set != 0
+             && GET_CODE (SET_DEST (set)) == REG
+             && REG_FUNCTION_VALUE_P (SET_DEST (set)))
            {
-             if (volatile_refs_p (SET_SRC (pattern)))
+             if (volatile_refs_p (SET_SRC (set)))
                {
+                 rtx new_set;
+
                  /* If we must not delete the source,
                     load it into a new temporary.  */
                  copy = emit_insn (copy_rtx_and_substitute (pattern, map));
-                 SET_DEST (PATTERN (copy)) 
-                   = gen_reg_rtx (GET_MODE (SET_DEST (PATTERN (copy))));
+
+                 new_set = single_set (copy);
+                 if (new_set == 0)
+                   abort ();
+
+                 SET_DEST (new_set)
+                   = gen_reg_rtx (GET_MODE (SET_DEST (new_set)));
                }
+             /* If the source and destination are the same and it
+                has a note on it, keep the insn.  */
+             else if (rtx_equal_p (SET_DEST (set), SET_SRC (set))
+                      && REG_NOTES (insn) != 0)
+               copy = emit_insn (copy_rtx_and_substitute (pattern, map));
              else
                break;
            }
+
+         /* If this is setting the static chain rtx, omit it.  */
+         else if (static_chain_value != 0
+                  && set != 0
+                  && GET_CODE (SET_DEST (set)) == REG
+                  && rtx_equal_p (SET_DEST (set),
+                                  static_chain_incoming_rtx))
+           break;
+
          /* If this is setting the static chain pseudo, set it from
             the value we want to give it instead.  */
          else if (static_chain_value != 0
-                  && GET_CODE (pattern) == SET
-                  && rtx_equal_p (SET_SRC (pattern),
+                  && set != 0
+                  && rtx_equal_p (SET_SRC (set),
                                   static_chain_incoming_rtx))
            {
-             rtx newdest = copy_rtx_and_substitute (SET_DEST (pattern), map);
-
-             copy = emit_insn (gen_rtx (SET, VOIDmode, newdest,
-                                        static_chain_value));
+             rtx newdest = copy_rtx_and_substitute (SET_DEST (set), map);
 
+             copy = emit_move_insn (newdest, static_chain_value);
              static_chain_value = 0;
            }
          else
@@ -1637,7 +1847,9 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          break;
 
        case JUMP_INSN:
-         if (GET_CODE (PATTERN (insn)) == RETURN)
+         if (GET_CODE (PATTERN (insn)) == RETURN
+             || (GET_CODE (PATTERN (insn)) == PARALLEL
+                 && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == RETURN))
            {
              if (local_return_label == 0)
                local_return_label = gen_label_rtx ();
@@ -1682,6 +1894,11 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          pattern = copy_rtx_and_substitute (PATTERN (insn), map);
          copy = emit_call_insn (pattern);
 
+         /* Because the USAGE information potentially contains objects other
+            than hard registers, we need to copy it.  */
+         CALL_INSN_FUNCTION_USAGE (copy) =
+            copy_rtx_and_substitute (CALL_INSN_FUNCTION_USAGE (insn), map);
+
 #ifdef HAVE_cc0
          if (cc0_insn)
            try_constants (cc0_insn, map);
@@ -1713,7 +1930,18 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
          if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END
              && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG
              && NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED)
-           copy = emit_note (NOTE_SOURCE_FILE (insn), NOTE_LINE_NUMBER (insn));
+           {
+             copy = emit_note (NOTE_SOURCE_FILE (insn), NOTE_LINE_NUMBER (insn));
+             if (copy && (NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_BEG
+                          || NOTE_LINE_NUMBER (copy) == NOTE_INSN_EH_REGION_END))
+               {
+                 rtx label = map->label_map[NOTE_BLOCK_NUMBER (copy)];
+
+                 /* We have to forward these both to match the new exception
+                    region.  */
+                 NOTE_BLOCK_NUMBER (copy) = CODE_LABEL_NUMBER (label);
+               }
+           }
          else
            copy = 0;
          break;
@@ -1749,6 +1977,10 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   if (local_return_label)
     emit_label (local_return_label);
 
+  /* Restore the stack pointer if we saved it above.  */
+  if (FUNCTION_FLAGS (header) & FUNCTION_FLAGS_CALLS_ALLOCA)
+    emit_stack_restore (SAVE_BLOCK, stack_save, NULL_RTX);
+
   /* Make copies of the decls of the symbols in the inline function, so that
      the copies of the variables get declared in the current function.  Set
      up things so that lookup_static_chain knows that to interpret registers
@@ -1767,6 +1999,16 @@ expand_inline_function (fndecl, parms, target, ignore, type, structure_value_add
   BLOCK_ABSTRACT_ORIGIN (block) = (DECL_ABSTRACT_ORIGIN (fndecl) == NULL
                                   ? fndecl : DECL_ABSTRACT_ORIGIN (fndecl));
   poplevel (0, 0, 0);
+
+  /* Must mark the line number note after inlined functions as a repeat, so
+     that the test coverage code can avoid counting the call twice.  This
+     just tells the code to ignore the immediately following line note, since
+     there already exists a copy of this note before the expanded inline call.
+     This line number note is still needed for debugging though, so we can't
+     delete it.  */
+  if (flag_test_coverage)
+    emit_note (0, NOTE_REPEATED_LINE_NUMBER);
+
   emit_line_note (input_filename, lineno);
 
   if (structure_value_addr)
@@ -1839,9 +2081,13 @@ integrate_decl_tree (let, level, map)
   
   for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
     {
-      tree d = build_decl (TREE_CODE (t), DECL_NAME (t), TREE_TYPE (t));
-      DECL_SOURCE_LINE (d) = DECL_SOURCE_LINE (t);
-      DECL_SOURCE_FILE (d) = DECL_SOURCE_FILE (t);
+      tree d;
+
+      push_obstacks_nochange ();
+      saveable_allocation ();
+      d = copy_node (t);
+      pop_obstacks ();
+
       if (DECL_RTL (t) != 0)
        {
          DECL_RTL (d) = copy_rtx_and_substitute (DECL_RTL (t), map);
@@ -1852,19 +2098,14 @@ integrate_decl_tree (let, level, map)
          subst_constants (&DECL_RTL (d), NULL_RTX, map);
          apply_change_group ();
        }
-      else if (DECL_RTL (t))
-       DECL_RTL (d) = copy_rtx (DECL_RTL (t));
-      DECL_EXTERNAL (d) = DECL_EXTERNAL (t);
-      TREE_STATIC (d) = TREE_STATIC (t);
-      TREE_PUBLIC (d) = TREE_PUBLIC (t);
-      TREE_CONSTANT (d) = TREE_CONSTANT (t);
-      TREE_ADDRESSABLE (d) = TREE_ADDRESSABLE (t);
-      TREE_READONLY (d) = TREE_READONLY (t);
-      TREE_SIDE_EFFECTS (d) = TREE_SIDE_EFFECTS (t);
       /* These args would always appear unused, if not for this.  */
       TREE_USED (d) = 1;
       /* Prevent warning for shadowing with these.  */
       DECL_ABSTRACT_ORIGIN (d) = t;
+
+      if (DECL_LANG_SPECIFIC (d))
+       copy_lang_decl (d);
+
       pushdecl (d);
     }
 
@@ -1881,6 +2122,23 @@ integrate_decl_tree (let, level, map)
        }
     }
 }
+
+/* Given a BLOCK node LET, search for all DECL_RTL fields, and pass them
+   through save_constants.  */
+
+static void
+save_constants_in_decl_trees (let)
+     tree let;
+{
+  tree t;
+
+  for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
+    if (DECL_RTL (t) != 0)
+      save_constants (&DECL_RTL (t));
+
+  for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
+    save_constants_in_decl_trees (t);
+}
 \f
 /* Create a new copy of an rtx.
    Recursively copies the operands of the rtx,
@@ -1938,23 +2196,36 @@ copy_rtx_and_substitute (orig, map)
            {
              rtx loc, seq;
              int size = DECL_FRAME_SIZE (map->fndecl);
-             int rounded;
 
+#ifdef FRAME_GROWS_DOWNWARD
+             /* In this case, virtual_stack_vars_rtx points to one byte
+                higher than the top of the frame area.  So make sure we
+                allocate a big enough chunk to keep the frame pointer
+                aligned like a real one.  */
+             size = CEIL_ROUND (size, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
+#endif
              start_sequence ();
              loc = assign_stack_temp (BLKmode, size, 1);
              loc = XEXP (loc, 0);
 #ifdef FRAME_GROWS_DOWNWARD
              /* In this case, virtual_stack_vars_rtx points to one byte
                 higher than the top of the frame area.  So compute the offset
-                to one byte higher than our substitute frame.
-                Keep the fake frame pointer aligned like a real one.  */
-             rounded = CEIL_ROUND (size, BIGGEST_ALIGNMENT / BITS_PER_UNIT);
-             loc = plus_constant (loc, rounded);
+                to one byte higher than our substitute frame.  */
+             loc = plus_constant (loc, size);
 #endif
              map->reg_map[regno] = temp
                = force_reg (Pmode, force_operand (loc, NULL_RTX));
-             map->const_equiv_map[REGNO (temp)] = loc;
-             map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+
+#ifdef STACK_BOUNDARY
+             mark_reg_pointer (map->reg_map[regno],
+                               STACK_BOUNDARY / BITS_PER_UNIT);
+#endif
+
+             if (REGNO (temp) < map->const_equiv_map_size)
+               {
+                 map->const_equiv_map[REGNO (temp)] = loc;
+                 map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+               }
 
              seq = gen_sequence ();
              end_sequence ();
@@ -1964,7 +2235,7 @@ copy_rtx_and_substitute (orig, map)
          else if (regno == VIRTUAL_INCOMING_ARGS_REGNUM)
            {
              /* Do the same for a block to contain any arguments referenced
-                in memory. */
+                in memory.  */
              rtx loc, seq;
              int size = FUNCTION_ARGS_SIZE (DECL_SAVED_INSNS (map->fndecl));
 
@@ -1973,14 +2244,23 @@ copy_rtx_and_substitute (orig, map)
              loc = XEXP (loc, 0);
              /* When arguments grow downward, the virtual incoming 
                 args pointer points to the top of the argument block,
-                so the remapped location better do the same. */
+                so the remapped location better do the same.  */
 #ifdef ARGS_GROW_DOWNWARD
              loc = plus_constant (loc, size);
 #endif
              map->reg_map[regno] = temp
                = force_reg (Pmode, force_operand (loc, NULL_RTX));
-             map->const_equiv_map[REGNO (temp)] = loc;
-             map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+
+#ifdef STACK_BOUNDARY
+             mark_reg_pointer (map->reg_map[regno],
+                               STACK_BOUNDARY / BITS_PER_UNIT);
+#endif
+
+             if (REGNO (temp) < map->const_equiv_map_size)
+               {
+                 map->const_equiv_map[REGNO (temp)] = loc;
+                 map->const_age_map[REGNO (temp)] = CONST_AGE_PARM;
+               }
 
              seq = gen_sequence ();
              end_sequence ();
@@ -2010,6 +2290,10 @@ copy_rtx_and_substitute (orig, map)
          REG_LOOP_TEST_P (map->reg_map[regno]) = REG_LOOP_TEST_P (orig);
          RTX_UNCHANGING_P (map->reg_map[regno]) = RTX_UNCHANGING_P (orig);
          /* A reg with REG_FUNCTION_VALUE_P true will never reach here.  */
+
+         if (map->regno_pointer_flag[regno])
+           mark_reg_pointer (map->reg_map[regno],
+                             map->regno_pointer_align[regno]);
        }
       return map->reg_map[regno];
 
@@ -2019,6 +2303,8 @@ copy_rtx_and_substitute (orig, map)
       if (GET_CODE (copy) == SUBREG)
        return gen_rtx (SUBREG, GET_MODE (orig), SUBREG_REG (copy),
                        SUBREG_WORD (orig) + SUBREG_WORD (copy));
+      else if (GET_CODE (copy) == CONCAT)
+       return (subreg_realpart_p (orig) ? XEXP (copy, 0) : XEXP (copy, 1));
       else
        return gen_rtx (SUBREG, GET_MODE (orig), copy,
                        SUBREG_WORD (orig));
@@ -2052,6 +2338,14 @@ copy_rtx_and_substitute (orig, map)
        = (LABEL_REF_NONLOCAL_P (orig)
           && ! (CODE_LABEL_NUMBER (XEXP (copy, 0)) >= get_first_label_num ()
                 && CODE_LABEL_NUMBER (XEXP (copy, 0)) < max_label_num ()));
+
+      /* If we have made a nonlocal label local, it means that this
+        inlined call will be referring to our nonlocal goto handler.
+        So make sure we create one for this block; we normally would
+        not since this is not otherwise considered a "call".  */
+      if (LABEL_REF_NONLOCAL_P (orig) && ! LABEL_REF_NONLOCAL_P (copy))
+       function_call_count++;
+
       return copy;
 
     case PC:
@@ -2067,7 +2361,7 @@ copy_rtx_and_substitute (orig, map)
        {
          rtx constant = get_pool_constant (orig);
          if (GET_CODE (constant) == LABEL_REF)
-           return XEXP (force_const_mem (Pmode, 
+           return XEXP (force_const_mem (GET_MODE (orig),
                                          copy_rtx_and_substitute (constant,
                                                                   map)),
                         0);
@@ -2084,7 +2378,7 @@ copy_rtx_and_substitute (orig, map)
          REAL_VALUE_TYPE d;
 
          REAL_VALUE_FROM_CONST_DOUBLE (d, orig);
-         return immed_real_const_1 (d, GET_MODE (orig));
+         return CONST_DOUBLE_FROM_REAL_VALUE (d, GET_MODE (orig));
        }
       else
        return immed_double_const (CONST_DOUBLE_LOW (orig),
@@ -2114,16 +2408,18 @@ copy_rtx_and_substitute (orig, map)
       if (! RTX_INTEGRATED_P (orig))
        abort ();
 
-      temp = force_const_mem (GET_MODE (orig),
-                             copy_rtx_and_substitute (XEXP (orig, 0), map));
+      temp
+       = force_const_mem (GET_MODE (XEXP (orig, 0)),
+                          copy_rtx_and_substitute (XEXP (XEXP (orig, 0), 0),
+                                                   map));
 
 #if 0
       /* Legitimizing the address here is incorrect.
 
         The only ADDRESS rtx's that can reach here are ones created by
-        save_constants.  Hence the operand of the ADDRESS is always legal
+        save_constants.  Hence the operand of the ADDRESS is always valid
         in this position of the instruction, since the original rtx without
-        the ADDRESS was legal.
+        the ADDRESS was valid.
 
         The reason we don't legitimize the address here is that on the
         Sparc, the caller may have a (high ...) surrounding this ADDRESS.
@@ -2134,13 +2430,20 @@ copy_rtx_and_substitute (orig, map)
         will not have valid reg_map entries.  This can cause try_constants()
         to fail because assumes that all registers in the rtx have valid
         reg_map entries, and it may end up replacing one of these new
-        registers with junk. */
+        registers with junk.  */
 
       if (! memory_address_p (GET_MODE (temp), XEXP (temp, 0)))
        temp = change_address (temp, GET_MODE (temp), XEXP (temp, 0));
 #endif
 
-      return XEXP (temp, 0);
+      temp = XEXP (temp, 0);
+
+#ifdef POINTERS_EXTEND_UNSIGNED
+      if (GET_MODE (temp) != GET_MODE (orig))
+       temp = convert_memory_address (GET_MODE (orig), temp);
+#endif
+
+      return temp;
 
     case ASM_OPERANDS:
       /* If a single asm insn contains multiple output operands
@@ -2149,6 +2452,7 @@ copy_rtx_and_substitute (orig, map)
       if (map->orig_asm_operands_vector == XVEC (orig, 3))
        {
          copy = rtx_alloc (ASM_OPERANDS);
+         copy->volatil = orig->volatil;
          XSTR (copy, 0) = XSTR (orig, 0);
          XSTR (copy, 1) = XSTR (orig, 1);
          XINT (copy, 2) = XINT (orig, 2);
@@ -2301,11 +2605,12 @@ try_constants (insn, map)
        {
          int regno = REGNO (map->equiv_sets[i].dest);
 
-         if (map->const_equiv_map[regno] == 0
-             /* Following clause is a hack to make case work where GNU C++
-                reassigns a variable to make cse work right.  */
-             || ! rtx_equal_p (map->const_equiv_map[regno],
-                               map->equiv_sets[i].equiv))
+         if (regno < map->const_equiv_map_size
+             && (map->const_equiv_map[regno] == 0
+                 /* Following clause is a hack to make case work where GNU C++
+                    reassigns a variable to make cse work right.  */
+                 || ! rtx_equal_p (map->const_equiv_map[regno],
+                                   map->equiv_sets[i].equiv)))
            {
              map->const_equiv_map[regno] = map->equiv_sets[i].equiv;
              map->const_age_map[regno] = map->const_age;
@@ -2444,8 +2749,6 @@ subst_constants (loc, insn, map)
        src = SET_SRC (x);
 
        while (GET_CODE (*dest_loc) == ZERO_EXTRACT
-              /* By convention, we always use ZERO_EXTRACT in the dest.  */
-/*            || GET_CODE (*dest_loc) == SIGN_EXTRACT */
               || GET_CODE (*dest_loc) == SUBREG
               || GET_CODE (*dest_loc) == STRICT_LOW_PART)
          {
@@ -2477,10 +2780,13 @@ subst_constants (loc, insn, map)
        /* If storing a recognizable value save it for later recording.  */
        if ((map->num_sets < MAX_RECOG_OPERANDS)
            && (CONSTANT_P (src)
+               || (GET_CODE (src) == REG
+                   && (REGNO (src) == VIRTUAL_INCOMING_ARGS_REGNUM
+                       || REGNO (src) == VIRTUAL_STACK_VARS_REGNUM))
                || (GET_CODE (src) == PLUS
                    && GET_CODE (XEXP (src, 0)) == REG
-                   && REGNO (XEXP (src, 0)) >= FIRST_VIRTUAL_REGISTER
-                   && REGNO (XEXP (src, 0)) <= LAST_VIRTUAL_REGISTER
+                   && (REGNO (XEXP (src, 0)) == VIRTUAL_INCOMING_ARGS_REGNUM
+                       || REGNO (XEXP (src, 0)) == VIRTUAL_STACK_VARS_REGNUM)
                    && CONSTANT_P (XEXP (src, 1)))
                || GET_CODE (src) == COMPARE
 #ifdef HAVE_cc0
@@ -2567,7 +2873,8 @@ subst_constants (loc, insn, map)
 #ifdef FLOAT_STORE_FLAG_VALUE
        if (new != 0 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
          new = ((new == const0_rtx) ? CONST0_RTX (GET_MODE (x))
-                : immed_real_const_1 (FLOAT_STORE_FLAG_VALUE, GET_MODE (x)));
+                : CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE,
+                                                GET_MODE (x)));
 #endif
        break;
       }
@@ -2618,7 +2925,8 @@ mark_stores (dest, x)
       int i;
 
       for (i = regno; i <= last_reg; i++)
-       global_const_equiv_map[i] = 0;
+       if (i < global_const_equiv_map_size)
+         global_const_equiv_map[i] = 0;
     }
 }
 \f
@@ -2649,7 +2957,7 @@ restore_constants (px)
          REAL_VALUE_TYPE d;
 
          REAL_VALUE_FROM_CONST_DOUBLE (d, x);
-         *px = immed_real_const_1 (d, GET_MODE (x));
+         *px = CONST_DOUBLE_FROM_REAL_VALUE (d, GET_MODE (x));
        }
       else
        *px = immed_double_const (CONST_DOUBLE_LOW (x), CONST_DOUBLE_HIGH (x),
@@ -2673,8 +2981,16 @@ restore_constants (px)
     }
   else if (RTX_INTEGRATED_P (x) && GET_CODE (x) == ADDRESS)
     {
-      restore_constants (&XEXP (x, 0));
-      *px = XEXP (force_const_mem (GET_MODE (x), XEXP (x, 0)), 0);
+      rtx new = XEXP (force_const_mem (GET_MODE (XEXP (x, 0)),
+                                      XEXP (XEXP (x, 0), 0)),
+                     0);
+
+#ifdef POINTERS_EXTEND_UNSIGNED
+      if (GET_MODE (new) != GET_MODE (x))
+       new = convert_memory_address (GET_MODE (x), new);
+#endif
+
+      *px = new;
     }
   else
     {
@@ -2706,8 +3022,6 @@ restore_constants (px)
    still NULL, set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN
    values to point to themselves.  */
 
-static void set_decl_origin_self ();
-
 static void
 set_block_origin_self (stmt)
      register tree stmt;
@@ -2760,7 +3074,8 @@ set_decl_origin_self (decl)
 
          for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
            DECL_ABSTRACT_ORIGIN (arg) = arg;
-         if (DECL_INITIAL (decl) != NULL_TREE)
+         if (DECL_INITIAL (decl) != NULL_TREE
+             && DECL_INITIAL (decl) != error_mark_node)
            set_block_origin_self (DECL_INITIAL (decl));
        }
     }
@@ -2771,32 +3086,25 @@ set_decl_origin_self (decl)
    the given block, and for all local decls and all local sub-blocks
    (recursively) which are contained therein.  */
 
-void set_decl_abstract_flags ();
-
 static void
 set_block_abstract_flags (stmt, setting)
      register tree stmt;
      register int setting;
 {
-  BLOCK_ABSTRACT (stmt) = setting;
-
-  {
-    register tree local_decl;
+  register tree local_decl;
+  register tree subblock;
 
-    for (local_decl = BLOCK_VARS (stmt);
-        local_decl != NULL_TREE;
-        local_decl = TREE_CHAIN (local_decl))
-      set_decl_abstract_flags (local_decl, setting);
-  }
+  BLOCK_ABSTRACT (stmt) = setting;
 
-  {
-    register tree subblock;
+  for (local_decl = BLOCK_VARS (stmt);
+       local_decl != NULL_TREE;
+       local_decl = TREE_CHAIN (local_decl))
+    set_decl_abstract_flags (local_decl, setting);
 
-    for (subblock = BLOCK_SUBBLOCKS (stmt);
-        subblock != NULL_TREE;
-        subblock = BLOCK_CHAIN (subblock))
-      set_block_abstract_flags (subblock, setting);
-  }
+  for (subblock = BLOCK_SUBBLOCKS (stmt);
+       subblock != NULL_TREE;
+       subblock = BLOCK_CHAIN (subblock))
+    set_block_abstract_flags (subblock, setting);
 }
 
 /* Given a pointer to some ..._DECL node, and a boolean value to set the
@@ -2817,7 +3125,8 @@ set_decl_abstract_flags (decl, setting)
 
       for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
        DECL_ABSTRACT (arg) = setting;
-      if (DECL_INITIAL (decl) != NULL_TREE)
+      if (DECL_INITIAL (decl) != NULL_TREE
+         && DECL_INITIAL (decl) != error_mark_node)
        set_block_abstract_flags (DECL_INITIAL (decl), setting);
     }
 }
@@ -2830,9 +3139,21 @@ void
 output_inline_function (fndecl)
      tree fndecl;
 {
-  rtx head = DECL_SAVED_INSNS (fndecl);
+  rtx head;
   rtx last;
+  int save_flag_no_inline = flag_no_inline;
 
+  if (output_bytecode)
+    {
+      warning ("`inline' ignored for bytecode output");
+      return;
+    }
+
+  /* Things we allocate from here on are part of this function, not
+     permanent.  */
+  temporary_allocation ();
+
+  head = DECL_SAVED_INSNS (fndecl);
   current_function_decl = fndecl;
 
   /* This call is only used to initialize global variables.  */
@@ -2845,9 +3166,15 @@ output_inline_function (fndecl)
   /* Set stack frame size.  */
   assign_stack_local (BLKmode, DECL_FRAME_SIZE (fndecl), 0);
 
-  restore_reg_data (FIRST_PARM_INSN (head));
-
+  /* The first is a bit of a lie (the array may be larger), but doesn't
+     matter too much and it isn't worth saving the actual bound.  */
+  reg_rtx_no = regno_pointer_flag_length = MAX_REGNUM (head);
+  regno_reg_rtx = (rtx *) INLINE_REGNO_REG_RTX (head);
+  regno_pointer_flag = INLINE_REGNO_POINTER_FLAG (head);
+  regno_pointer_align = INLINE_REGNO_POINTER_ALIGN (head);
+  
   stack_slot_list = STACK_SLOT_LIST (head);
+  forced_labels = FORCED_LABELS (head);
 
   if (FUNCTION_FLAGS (head) & FUNCTION_FLAGS_CALLS_ALLOCA)
     current_function_calls_alloca = 1;
@@ -2882,10 +3209,9 @@ output_inline_function (fndecl)
   current_function_outgoing_args_size = OUTGOING_ARGS_SIZE (head);
   current_function_pops_args = POPS_ARGS (head);
 
-  /* There is no need to output a return label again.  */
-  return_label = 0;
-
-  expand_function_end (DECL_SOURCE_FILE (fndecl), DECL_SOURCE_LINE (fndecl));
+  /* This is the only thing the expand_function_end call that uses to be here
+     actually does and that call can cause problems.  */
+  immediate_size_expand--;
 
   /* Find last insn and rebuild the constant pool.  */
   for (last = FIRST_PARM_INSN (head);
@@ -2912,8 +3238,18 @@ output_inline_function (fndecl)
 
   set_decl_origin_self (fndecl);
 
+  /* We're not deferring this any longer.  */
+  DECL_DEFER_OUTPUT (fndecl) = 0;
+
+  /* Integrating function calls isn't safe anymore, so turn on
+     flag_no_inline.  */
+  flag_no_inline = 1;
+
   /* Compile this function all the way down to assembly code.  */
   rest_of_compilation (fndecl);
 
+  /* Reset flag_no_inline to its original value.  */
+  flag_no_inline = save_flag_no_inline;
+
   current_function_decl = 0;
 }