re PR middle-end/8866 (Bug in switch statement code generation -- missing label)

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
This commit is contained in:
Richard Henderson 2003-04-22 16:17:46 -07:00 committed by Richard Henderson
parent c1238896d3
commit 4da2eb6b90
6 changed files with 34 additions and 5 deletions

View 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

View 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)

View 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}.

View 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));

View File

@ -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))

View 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. */