OSDN Git Service

Fix last entry.
[pf3gnuchains/gcc-fork.git] / gcc / function.c
index a2956b3..05bbd64 100644 (file)
@@ -2591,7 +2591,21 @@ assign_parm_setup_block (struct assign_parm_data_all *all,
 #endif
              )
            {
-             rtx reg = gen_rtx_REG (mode, REGNO (entry_parm));
+             rtx reg;
+
+             /* We are really truncating a word_mode value containing
+                SIZE bytes into a value of mode MODE.  If such an
+                operation requires no actual instructions, we can refer
+                to the value directly in mode MODE, otherwise we must
+                start with the register in word_mode and explicitly
+                convert it.  */
+             if (TRULY_NOOP_TRUNCATION (size * BITS_PER_UNIT, BITS_PER_WORD))
+               reg = gen_rtx_REG (mode, REGNO (entry_parm));
+             else
+               {
+                 reg = gen_rtx_REG (word_mode, REGNO (entry_parm));
+                 reg = convert_to_mode (mode, copy_to_reg (reg), 1);
+               }
              emit_move_insn (change_address (mem, mode, 0), reg);
            }
 
@@ -4404,13 +4418,6 @@ expand_function_end (void)
          }
     }
 
-  /* Possibly warn about unused parameters.
-     When frontend does unit-at-a-time, the warning is already
-     issued at finalization time.  */
-  if (warn_unused_parameter
-      && !lang_hooks.callgraph.expand_function)
-    do_warn_unused_parameter (current_function_decl);
-
   /* End any sequences that failed to be closed due to syntax errors.  */
   while (in_sequence_p ())
     end_sequence ();
@@ -5656,7 +5663,7 @@ match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs)
       rtx input, output, insns;
       const char *constraint = ASM_OPERANDS_INPUT_CONSTRAINT (op, i);
       char *end;
-      int match;
+      int match, j;
 
       match = strtoul (constraint, &end, 10);
       if (end == constraint)
@@ -5665,18 +5672,59 @@ match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs)
       gcc_assert (match < noutputs);
       output = SET_DEST (p_sets[match]);
       input = RTVEC_ELT (inputs, i);
-      if (rtx_equal_p (output, input)
+      /* Only do the transformation for pseudos.  */
+      if (! REG_P (output)
+         || rtx_equal_p (output, input)
          || (GET_MODE (input) != VOIDmode
              && GET_MODE (input) != GET_MODE (output)))
        continue;
 
+      /* We can't do anything if the output is also used as input,
+        as we're going to overwrite it.  */
+      for (j = 0; j < ninputs; j++)
+        if (reg_overlap_mentioned_p (output, RTVEC_ELT (inputs, j)))
+         break;
+      if (j != ninputs)
+       continue;
+
       start_sequence ();
-      emit_move_insn (copy_rtx (output), input);
-      RTVEC_ELT (inputs, i) = copy_rtx (output);
+      emit_move_insn (output, input);
       insns = get_insns ();
       end_sequence ();
-
       emit_insn_before (insns, insn);
+
+      /* Now replace all mentions of the input with output.  We can't
+        just replace the occurence in inputs[i], as the register might
+        also be used in some other input (or even in an address of an
+        output), which would mean possibly increasing the number of
+        inputs by one (namely 'output' in addition), which might pose
+        a too complicated problem for reload to solve.  E.g. this situation:
+
+          asm ("" : "=r" (output), "=m" (input) : "0" (input))
+
+        Here 'input' is used in two occurrences as input (once for the
+        input operand, once for the address in the second output operand).
+        If we would replace only the occurence of the input operand (to
+        make the matching) we would be left with this:
+
+          output = input
+          asm ("" : "=r" (output), "=m" (input) : "0" (output))
+
+        Now we suddenly have two different input values (containing the same
+        value, but different pseudos) where we formerly had only one.
+        With more complicated asms this might lead to reload failures
+        which wouldn't have happen without this pass.  So, iterate over
+        all operands and replace all occurrences of the register used.  */
+      for (j = 0; j < noutputs; j++)
+       if (!rtx_equal_p (SET_DEST (p_sets[j]), input)
+           && reg_overlap_mentioned_p (input, SET_DEST (p_sets[j])))
+         SET_DEST (p_sets[j]) = replace_rtx (SET_DEST (p_sets[j]),
+                                             input, output);
+      for (j = 0; j < ninputs; j++)
+       if (reg_overlap_mentioned_p (input, RTVEC_ELT (inputs, j)))
+         RTVEC_ELT (inputs, j) = replace_rtx (RTVEC_ELT (inputs, j),
+                                              input, output);
+
       changed = true;
     }