emit-rtl.c (set_mem_attributes_minus_bitpos): Look through component-like references...
authorRichard Henderson <rth@redhat.com>
Thu, 1 Sep 2005 01:41:30 +0000 (18:41 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 1 Sep 2005 01:41:30 +0000 (18:41 -0700)
        * emit-rtl.c (set_mem_attributes_minus_bitpos): Look through
        component-like references for setting MEM_NOTRAP_P.

        * config/i386/i386.c (ix86_setup_incoming_varargs): Set MEM_NOTRAP_P.
        * config/alpha/alpha.c (alpha_setup_incoming_varargs): Likewise.

From-SVN: r103714

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/i386/i386.c
gcc/emit-rtl.c

index f887654193b2e70f824a3e5a303729467a6fe601..7cdd2926f6ee4263d4115e75a011709eb4b95a28 100644 (file)
@@ -1,3 +1,11 @@
+2005-08-31  Richard Henderson  <rth@redhat.com>
+
+       * emit-rtl.c (set_mem_attributes_minus_bitpos): Look through
+       component-like references for setting MEM_NOTRAP_P.
+
+       * config/i386/i386.c (ix86_setup_incoming_varargs): Set MEM_NOTRAP_P.
+       * config/alpha/alpha.c (alpha_setup_incoming_varargs): Likewise.
+
 2005-08-31  Richard Henderson  <rth@redhat.com>
 
        * expr.c (expand_expr_real_1) <VIEW_CONVERT_EXPR>: Force subregs
index f15964fd7f62c9a920d4c76fc08085146e84f307..808116a158d03ee54c8a957cb9e469b517d8b0b2 100644 (file)
@@ -6090,6 +6090,7 @@ alpha_setup_incoming_varargs (CUMULATIVE_ARGS *pcum, enum machine_mode mode,
          tmp = gen_rtx_MEM (BLKmode,
                             plus_constant (virtual_incoming_args_rtx,
                                            (cum + 6) * UNITS_PER_WORD));
+         MEM_NOTRAP_P (tmp) = 1;
          set_mem_alias_set (tmp, set);
          move_block_from_reg (16 + cum, tmp, count);
        }
@@ -6099,6 +6100,7 @@ alpha_setup_incoming_varargs (CUMULATIVE_ARGS *pcum, enum machine_mode mode,
          tmp = gen_rtx_MEM (BLKmode,
                             plus_constant (virtual_incoming_args_rtx,
                                            cum * UNITS_PER_WORD));
+         MEM_NOTRAP_P (tmp) = 1;
          set_mem_alias_set (tmp, set);
          move_block_from_reg (16 + cum + TARGET_FPREGS*32, tmp, count);
        }
index e3fd6e7a75d75ea1e6b27cfde0216813bf187c27..5f12d1a5f7e0e9e7a0ce7b3c39276d2b40176cb4 100644 (file)
@@ -3682,6 +3682,7 @@ ix86_setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode,
     {
       mem = gen_rtx_MEM (Pmode,
                         plus_constant (save_area, i * UNITS_PER_WORD));
+      MEM_NOTRAP_P (mem) = 1;
       set_mem_alias_set (mem, set);
       emit_move_insn (mem, gen_rtx_REG (Pmode,
                                        x86_64_int_parameter_registers[i]));
@@ -3724,6 +3725,7 @@ ix86_setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode,
                              plus_constant (save_area,
                                             8 * REGPARM_MAX + 127)));
       mem = gen_rtx_MEM (BLKmode, plus_constant (tmp_reg, -127));
+      MEM_NOTRAP_P (mem) = 1;
       set_mem_alias_set (mem, set);
       set_mem_align (mem, BITS_PER_WORD);
 
index 18c71b14890cce7defd15855cc2baad31a1f5785..d9e253e3ce2eccbca8d5dc16e605d93697743fcf 100644 (file)
@@ -1469,7 +1469,6 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
   MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type);
   MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
   MEM_POINTER (ref) = POINTER_TYPE_P (type);
-  MEM_NOTRAP_P (ref) = TREE_THIS_NOTRAP (t);
 
   /* If we are making an object of this type, or if this is a DECL, we know
      that it is a scalar if the type is not an aggregate.  */
@@ -1500,16 +1499,7 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
      the expression.  */
   if (! TYPE_P (t))
     {
-      tree base = get_base_address (t);
-      if (base && DECL_P (base)
-         && TREE_READONLY (base)
-         && (TREE_STATIC (base) || DECL_EXTERNAL (base)))
-       {
-         tree base_type = TREE_TYPE (base);
-         gcc_assert (!(base_type && TYPE_NEEDS_CONSTRUCTING (base_type))
-                     || DECL_ARTIFICIAL (base));
-         MEM_READONLY_P (ref) = 1;
-       }
+      tree base;
 
       if (TREE_THIS_VOLATILE (t))
        MEM_VOLATILE_P (ref) = 1;
@@ -1522,6 +1512,36 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
             || TREE_CODE (t) == SAVE_EXPR)
        t = TREE_OPERAND (t, 0);
 
+      /* We may look through structure-like accesses for the purposes of
+        examining TREE_THIS_NOTRAP, but not array-like accesses.  */
+      base = t;
+      while (TREE_CODE (base) == COMPONENT_REF
+            || TREE_CODE (base) == REALPART_EXPR
+            || TREE_CODE (base) == IMAGPART_EXPR
+            || TREE_CODE (base) == BIT_FIELD_REF)
+       base = TREE_OPERAND (base, 0);
+
+      if (DECL_P (base))
+       {
+         if (CODE_CONTAINS_STRUCT (TREE_CODE (base), TS_DECL_WITH_VIS))
+           MEM_NOTRAP_P (ref) = !DECL_WEAK (base);
+         else
+           MEM_NOTRAP_P (ref) = 1;
+       }
+      else
+       MEM_NOTRAP_P (ref) = TREE_THIS_NOTRAP (base);
+
+      base = get_base_address (base);
+      if (base && DECL_P (base)
+         && TREE_READONLY (base)
+         && (TREE_STATIC (base) || DECL_EXTERNAL (base)))
+       {
+         tree base_type = TREE_TYPE (base);
+         gcc_assert (!(base_type && TYPE_NEEDS_CONSTRUCTING (base_type))
+                     || DECL_ARTIFICIAL (base));
+         MEM_READONLY_P (ref) = 1;
+       }
+
       /* If this expression uses it's parent's alias set, mark it such
         that we won't change it.  */
       if (component_uses_parent_alias_set (t))