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: [vta,trunk?] inlining gen_rtvec_v into gen_rtvec warns


On Tue, Aug 12, 2008 at 5:22 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
> Richard Guenther wrote:
>>
>> 2008/8/12 Alexandre Oliva <aoliva@redhat.com>:
>>>
>>> Bootstrapping with -O3 on x86/64? causes gen_rtvec_v() to be inlined
>>> into gen_rtvec().  This in turns causes the test for n == 0, already
>>> performed in the caller, to be warned about, since it's always false.
>>> I don't think it is appropriate to warn in this case, but this patches
>>> permits bootstrap with -O3 to succeed.
>>>
>>> I'm installing it on the branch.  Should I install it on the trunk as
>>> well?
>>
>> Why not fix gen_rtvec instead to not allocate the temporary array
>> on the stack?
>
> You mean inlining gen_rtvec_v into gen_rtvec like this (totally untested)?

Yes.

> I could not resist the urge of replacing code dating to...
>
>   471        rms /* gen_rtvec (n, [rt1, ..., rtn])
>
> r471 | rms | 1992-03-14 06:04:21 +0100 (Sat, 14 Mar 1992) | 2 lines

;)

Patch is ok for trunk if it passes bootstrap & regtest.

Thanks,
Richard.

> Paolo
>
>
> Index: emit-rtl.c
> ===================================================================
> --- emit-rtl.c  (revision 134435)
> +++ emit-rtl.c  (working copy)
> @@ -793,35 +793,29 @@ gen_lowpart_SUBREG (enum machine_mode mo
>                         subreg_lowpart_offset (mode, inmode));
>  }
>
>
> -/* gen_rtvec (n, [rt1, ..., rtn])
> -**
> -**         This routine creates an rtvec and stores within it the
> -**     pointers to rtx's which are its arguments.
> -*/
> +/* Create an rtvec and stores within it the RTXen passed in the arguments.
>  */
>
> -/*VARARGS1*/
>  rtvec
>  gen_rtvec (int n, ...)
>  {
> -  int i, save_n;
> -  rtx *vector;
> +  int i;
> +  rtvec rt_val;
>   va_list p;
>
>   va_start (p, n);
>
> +  /* Don't allocate an empty rtvec...  */
>   if (n == 0)
> -    return NULL_RTVEC;         /* Don't allocate an empty rtvec...     */
> +    return NULL_RTVEC;
>
> -  vector = alloca (n * sizeof (rtx));
> +  rt_val = rtvec_alloc (n);
>
>   for (i = 0; i < n; i++)
> -    vector[i] = va_arg (p, rtx);
> +    rt_val->elem[i] = va_arg (p, rtx);
>
> -  /* The definition of VA_* in K&R C causes `n' to go out of scope.  */
> -  save_n = n;
>   va_end (p);
>
> -  return gen_rtvec_v (save_n, vector);
> +  return rt_val;
>  }
>
>  rtvec
> @@ -830,10 +824,11 @@ gen_rtvec_v (int n, rtx *argp)
>   int i;
>   rtvec rt_val;
>
> +  /* Don't allocate an empty rtvec...  */
>   if (n == 0)
> -    return NULL_RTVEC;         /* Don't allocate an empty rtvec...     */
> +    return NULL_RTVEC;
>
> -  rt_val = rtvec_alloc (n);    /* Allocate an rtvec...                 */
> +  rt_val = rtvec_alloc (n);
>
>   for (i = 0; i < n; i++)
>     rt_val->elem[i] = *argp++;
>
>


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