This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: get_ref_base_and_extent() semantics
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "GCC Mailing List" <gcc at gcc dot gnu dot org>
- Date: Fri, 12 Dec 2008 11:53:42 +0100
- Subject: Re: get_ref_base_and_extent() semantics
- References: <20081211232912.GA3493@alvy.suse.cz>
On Fri, Dec 12, 2008 at 12:29 AM, Martin Jambor <mjambor@suse.cz> wrote:
> 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?
The function is supposed to return -1 for max_size in case the access
accesses a variable array index of an array of unknown size.
insn_4(D)->u.fld[arg.82_3].rt_rtvec accesses struct rtvec_def -- in which
case the access _does_ have known size (an int plus one rtx pointer).
But maybe I am missing context here?
Richard.
> Thanks a lot in advance,
>
> Martin
>