re PR rtl-optimization/7507 (ICE (segfault) with -O2)
authorRichard Henderson <rth@redhat.com>
Tue, 21 Jan 2003 07:37:13 +0000 (23:37 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 21 Jan 2003 07:37:13 +0000 (23:37 -0800)
        PR opt/7507
        * stmt.c (expand_asm_operands): Validize memory operands.
* gcc.dg/20030120-1.c: New.

From-SVN: r61535

gcc/ChangeLog
gcc/stmt.c
gcc/testsuite/gcc.dg/20030120-1.c [new file with mode: 0644]

index 122cf2e037e5e447a60a478bfeba678923fbb1ea..78803b74e24e94cdb6d9dcfb210433d2ea8dc1ae 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-20  Richard Henderson  <rth@redhat.com>
+
+       PR opt/7507
+       * stmt.c (expand_asm_operands): Validize memory operands.
+
 2003-01-20  Richard Henderson  <rth@redhat.com>
 
        PR opt/8848
index 6f122c4d31b74271e309d440d3c7d0d319372bb8..b6503cfa9cabbefc67a439fba1a6308ea61dee79 100644 (file)
@@ -1610,6 +1610,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
       bool is_inout;
       bool allows_reg;
       bool allows_mem;
+      rtx op;
 
       if (!parse_output_constraint (&constraints[i], i, ninputs,
                                    noutputs, &allows_mem, &allows_reg,
@@ -1633,24 +1634,28 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
          || ! allows_reg
          || is_inout)
        {
-         output_rtx[i] = expand_expr (val, NULL_RTX, VOIDmode, EXPAND_WRITE);
+         op = expand_expr (val, NULL_RTX, VOIDmode, EXPAND_WRITE);
+         if (GET_CODE (op) == MEM)
+           op = validize_mem (op);
 
-         if (! allows_reg && GET_CODE (output_rtx[i]) != MEM)
+         if (! allows_reg && GET_CODE (op) != MEM)
            error ("output number %d not directly addressable", i);
-         if ((! allows_mem && GET_CODE (output_rtx[i]) == MEM)
-             || GET_CODE (output_rtx[i]) == CONCAT)
+         if ((! allows_mem && GET_CODE (op) == MEM)
+             || GET_CODE (op) == CONCAT)
            {
-             real_output_rtx[i] = protect_from_queue (output_rtx[i], 1);
-             output_rtx[i] = gen_reg_rtx (GET_MODE (output_rtx[i]));
+             real_output_rtx[i] = protect_from_queue (op, 1);
+             op = gen_reg_rtx (GET_MODE (op));
              if (is_inout)
-               emit_move_insn (output_rtx[i], real_output_rtx[i]);
+               emit_move_insn (op, real_output_rtx[i]);
            }
        }
       else
        {
-         output_rtx[i] = assign_temp (type, 0, 0, 1);
-         TREE_VALUE (tail) = make_tree (type, output_rtx[i]);
+         op = assign_temp (type, 0, 0, 1);
+         op = validize_mem (op);
+         TREE_VALUE (tail) = make_tree (type, op);
        }
+      output_rtx[i] = op;
 
       generating_concat_p = old_generating_concat_p;
 
@@ -1702,6 +1707,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
       /* Never pass a CONCAT to an ASM.  */
       if (GET_CODE (op) == CONCAT)
        op = force_reg (GET_MODE (op), op);
+      else if (GET_CODE (op) == MEM)
+       op = validize_mem (op);
 
       if (asm_operand_ok (op, constraint) <= 0)
        {
@@ -1711,7 +1718,10 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
            warning ("asm operand %d probably doesn't match constraints",
                     i + noutputs);
          else if (CONSTANT_P (op))
-           op = force_const_mem (TYPE_MODE (type), op);
+           {
+             op = force_const_mem (TYPE_MODE (type), op);
+             op = validize_mem (op);
+           }
          else if (GET_CODE (op) == REG
                   || GET_CODE (op) == SUBREG
                   || GET_CODE (op) == ADDRESSOF
@@ -1721,7 +1731,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
                                                     (TYPE_QUALS (type)
                                                      | TYPE_QUAL_CONST));
              rtx memloc = assign_temp (qual_type, 1, 1, 1);
-
+             memloc = validize_mem (memloc);
              emit_move_insn (memloc, op);
              op = memloc;
            }
diff --git a/gcc/testsuite/gcc.dg/20030120-1.c b/gcc/testsuite/gcc.dg/20030120-1.c
new file mode 100644 (file)
index 0000000..05689ad
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR 7154 */
+/* { dg-do compile } */
+/* { dg-options "-O -fpic" } */
+/* { dg-warning "not supported" "PIC unsupported" { target cris-*-elf* mmix-*-* } 0 } */
+
+const int x[1]={ 1 };
+void foo(int i, int *p)
+{
+  asm volatile("" : "+r"(i) : "m" (x[0]), "r"(p));
+}