Hi,

today  I have  encountered  an unpleasant  problem  with the  function
get_ref_base_and_extent() when it claimed  a known and constant offset
for the expression  insn_4(D)->u.fld[arg.82_3].rt_rtvec.  (arg being a
default_def parameter of the function,  insn is an rtx).  Moreover, it
also  returned constant  size  and  max_size, all  three  equal to  64
(bits).

This  is certainly  wrong  (I  believe the  function  got confused  by
unions) but after looking at the function and what it did in debugger,
I grew unsure  what the expected behavior is.   The two alternatives I
consider  possibly  correct  are  returned  offset  equal  to  -1  or,
alternatively, offset  equal to the offset  of the array  (+ offset of
rt_rtvec which is  zero) and max_size equal either to  the size of the
array or -1 if it is unknown.

At  the moment, the  function never  returns offset  equal to  -1, the
comment above it does not  even mention such possibility and, from the
limited research  I did, its callers  do not expect and  check for it.
However, at  the same time,  the special handling of  non-constants in
array  indices  after  the  label  "done" does  not  trigger  in  this
particular case (here I suspect the  unions come to play because it is
the last part of the conjunction that evaluates to false).

Which (or what  else) is the correct semantics  of the function?  Both
make sense to me (I would  prefer the former but I suspect other users
rely on  the latter).   What would  be the correct  fix, when  a union
field is  itself a  record ending with  a variable-length  array?  How
much would I pessimize things if I just returned -1 max_size if both a
non-constant index and a union was encountered?

Or did I miss something else?

Thanks a lot in advance,

Martin

Reply via email to