re PR middle-end/8866 (Bug in switch statement code generation -- missing label)
authorRichard Henderson <rth@redhat.com>
Tue, 22 Apr 2003 23:17:46 +0000 (16:17 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 22 Apr 2003 23:17:46 +0000 (16:17 -0700)
        PR 8866
        * rtl.h (MEM_NOTRAP_P): New.
        (MEM_COPY_ATTRIBUTES): Copy it.
        * rtlanal.c (may_trap_p): Check it.
        * expr.c (do_tablejump): Set it.
        * doc/rtl.texi (Flags): Document it.

        * cfgrtl.c (try_redirect_by_replacing_jump): Revert last three changes.

From-SVN: r65967

gcc/ChangeLog
gcc/cfgrtl.c
gcc/doc/rtl.texi
gcc/expr.c
gcc/rtl.h
gcc/rtlanal.c

index c5cbb7485e72ab556d59f01a8b8f28283aae9ec0..842a542d6c8913adcf4e3384cb874b1335f32387 100644 (file)
@@ -1,3 +1,14 @@
+2003-04-22  Richard Henderson  <rth@redhat.com>
+
+        PR 8866
+        * rtl.h (MEM_NOTRAP_P): New.
+        (MEM_COPY_ATTRIBUTES): Copy it.
+        * rtlanal.c (may_trap_p): Check it.
+        * expr.c (do_tablejump): Set it.
+       * doc/rtl.texi (Flags): Document it.
+
+        * cfgrtl.c (try_redirect_by_replacing_jump): Revert last three changes.
+
 2003-04-22  Olivier Hainque  <hainque@act-europe.fr>
 
        * config/alpha/alpha.c (alpha_expand_prologue [OPEN_VMS_ABI]): Don't
index 654d3e304bd154c1e03046506b392033188887c3..0ba32c5782ea3c86b66926aebee289e68d41c129 100644 (file)
@@ -740,12 +740,14 @@ try_redirect_by_replacing_jump (e, target)
        fprintf (rtl_dump_file, "Replacing insn %i by jump %i\n",
                 INSN_UID (insn), INSN_UID (src->end));
 
-      /* Remove the original jump.  If INSN is a tablejump, the jump
-        table will be removed later, if it is no longer needed.  */
+
       delete_insn_chain (kill_from, insn);
 
+      /* Recognize a tablejump that we are converting to a
+        simple jump and remove its associated CODE_LABEL
+        and ADDR_VEC or ADDR_DIFF_VEC.  */
       if (tablejump_p (insn, &label, &table))
-       create_basic_block (label, table, src);
+       delete_insn_chain (label, table);
 
       barrier = next_nonnote_insn (src->end);
       if (!barrier || GET_CODE (barrier) != BARRIER)
index 8368b49f39c642e20e5a371c2316ea33680d467a..8a97a5d2e0b52bf41290706890d47dd6d2500e68 100644 (file)
@@ -630,6 +630,13 @@ In @code{mem}, @code{asm_operands}, and @code{asm_input} expressions,
 nonzero for volatile memory references.
 Stored in the @code{volatil} field and printed as @samp{/v}.
 
+@findex MEM_NOTRAP_P
+@cindex @code{mem} and @samp{/c}
+@cindex @code{call}, in @code{mem}
+@item MEM_NOTRAP_P (@var{x})
+In @code{mem}, nonzero for memory references that will not trap.
+Stored in the @code{call} field and printed as @samp{/c}.
+
 @findex REG_FUNCTION_VALUE_P
 @cindex @code{reg} and @samp{/i}
 @cindex @code{integrated}, in @code{reg}
@@ -847,7 +854,7 @@ These are the fields to which the above macros refer:
 @findex call
 @cindex @samp{/c} in RTL dump
 @item call
-This flag is currently unused.
+In a @code{mem}, 1 means that the memory reference will not trap.
 
 In an RTL dump, this flag is represented as @samp{/c}.
 
index f87f9c900ff3a0aefbac4f963a6101cf7e0d32f1..9176c30a8b1f488f25d5ba22057deb9a29352315 100644 (file)
@@ -10272,6 +10272,7 @@ do_tablejump (index, mode, range, table_label, default_label)
   temp = gen_reg_rtx (CASE_VECTOR_MODE);
   vector = gen_rtx_MEM (CASE_VECTOR_MODE, index);
   RTX_UNCHANGING_P (vector) = 1;
+  MEM_NOTRAP_P (vector) = 1;
   convert_move (temp, vector, 0);
 
   emit_jump_insn (gen_tablejump (temp, table_label));
index acd724353ce5a545619997991770af74468107d7..517dd281045a2a6b9d63f7c65b3b5100a3627fc9 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -150,7 +150,8 @@ struct rtx_def GTY((chain_next ("RTX_NEXT (&%h)"),
      1 in a SET that is for a return.
      In a CODE_LABEL, part of the two-bit alternate entry field.  */
   unsigned int jump : 1;
-  /* In a CODE_LABEL, part of the two-bit alternate entry field.  */
+  /* In a CODE_LABEL, part of the two-bit alternate entry field.
+     1 in a MEM if it cannot trap.  */
   unsigned int call : 1;
   /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere.
      1 in a SUBREG if it references an unsigned object whose mode has been
@@ -1109,6 +1110,10 @@ do {                                                                     \
 #define MEM_SCALAR_P(RTX)                                              \
   (RTL_FLAG_CHECK1("MEM_SCALAR_P", (RTX), MEM)->frame_related)
 
+/* 1 if RTX is a mem that cannot trap.  */
+#define MEM_NOTRAP_P(RTX) \
+  (RTL_FLAG_CHECK1("MEM_NOTRAP_P", (RTX), MEM)->call)
+
 /* If VAL is nonzero, set MEM_IN_STRUCT_P and clear MEM_SCALAR_P in
    RTX.  Otherwise, vice versa.  Use this macro only when you are
    *sure* that you know that the MEM is in a structure, or is a
@@ -1178,6 +1183,7 @@ do {                                              \
   (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS),                        \
    MEM_IN_STRUCT_P (LHS) = MEM_IN_STRUCT_P (RHS),              \
    MEM_SCALAR_P (LHS) = MEM_SCALAR_P (RHS),                    \
+   MEM_NOTRAP_P (LHS) = MEM_NOTRAP_P (RHS),                    \
    RTX_UNCHANGING_P (LHS) = RTX_UNCHANGING_P (RHS),            \
    MEM_KEEP_ALIAS_SET_P (LHS) = MEM_KEEP_ALIAS_SET_P (RHS),    \
    MEM_ATTRS (LHS) = MEM_ATTRS (RHS))
index b0c76cc851d6f1ae7c3e8f02478d9dbfaf27de3a..1972375313dd6ce6d933a9f0158bce6674f01861 100644 (file)
@@ -2462,6 +2462,8 @@ may_trap_p (x)
 
       /* Memory ref can trap unless it's a static var or a stack slot.  */
     case MEM:
+      if (MEM_NOTRAP_P (x))
+       return 0;
       return rtx_addr_can_trap_p (XEXP (x, 0));
 
       /* Division by a non-constant might trap.  */