This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Crossjumping of tablejumps


Josef Zlomek wrote:

> + /* Given a CONSTANT, return the corresponding constant pool reference.  */
> + 
> + rtx
> + get_constant_pool_symbol_ref (constant)
> +      rtx constant;
> + {
> +   struct pool_constant *pool;
> + 
> +   for (pool = cfun->varasm->x_first_pool; pool; pool = pool->next)
> +     if (rtx_referenced_p (constant, pool->constant))
> +       return XEXP (pool->desc->rtl, 0);
> + 
> +   return NULL;
> + }

Together with your rtx_referenced_p, it would appear that this routine
returns just about any constant pool entry that somewhere contains
CONSTANT.  E.g. consider the case where both .L1 and .L1+4 are in the
constant pool (which can reasonably happen on s390 in some cases);
this routine would randomly return one of those references.

(Also, due to the currently broken decode_rtx_const, it can happen
that the *same* constant appears twice in the literal pool.  This
would also lead to a confusing result of get_constant_pool_symbol_ref.)

While this will probably not happen in the specific case of jump table
labels, at the very least the comment for this function is misleading.

Would it not be better to replace this

> + 	  /* If the labels are in constant pool
> + 	     replace the SYMBOL_REF SYM1 by SYM2.  */
> + 	  sym1 = get_constant_pool_symbol_ref (label1);
> + 	  sym2 = get_constant_pool_symbol_ref (label2);
> + 	  if (sym1 && sym2)
> + 	    {
> + 	      for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
> + 		replace_rtx (insn, sym1, copy_rtx (sym2));
> + 	    }
> + 	  else if (sym1 || sym2)
> + 	    abort ();

by a loop that goes over all insns, checks each insn for references
to the literal pool, and checks for each such reference whether it
contains sym1; if so, replaces sym1 with sym2 in the constant, creates 
a new literal pool entry for the modified constant, and replaces the 
literal pool reference in the insn accordingly?

This should completly cover all cases, without any assumptions on
when and what symbols appear in the literal pool.

Basically, this could be something like an extended replace_rtx,
that extends the replacement operation to literals referenced by
the insn ...

Then, get_constant_pool_symbol_ref would not be necessary at all.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand at informatik dot uni-erlangen dot de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]