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: [PATCH] i386: Skip DF_REF_INSN if DF_REF_INSN_INFO is false


On Mon, Oct 23, 2017 at 1:45 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> We should check DF_REF_INSN_INFO before accessing DF_REF_INSN.
>
> OK for trunk?
>
> H.J.
> ---
> gcc/
>
>         PR target/82673
>         * config/i386/i386.c (ix86_finalize_stack_frame_flags): Skip
>         DF_REF_INSN if DF_REF_INSN_INFO is false.
>
> gcc/testsuite/
>
>         PR target/82673
>         * gcc.target/i386/pr82673.c: New test.

I'm not that versed in the dataflow details, the patch LGTM.

One nit below.

Thanks,
Uros

> ---
>  gcc/config/i386/i386.c                  |  7 +++++--
>  gcc/testsuite/gcc.target/i386/pr82673.c | 12 ++++++++++++
>  2 files changed, 17 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr82673.c
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index b86504378ae..25c898866e2 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -12694,10 +12694,13 @@ ix86_finalize_stack_frame_flags (void)
>               for (ref = DF_REG_USE_CHAIN (HARD_FRAME_POINTER_REGNUM);
>                    ref; ref = next)
>                 {
> -                 rtx_insn *insn = DF_REF_INSN (ref);
> +                 next = DF_REF_NEXT_REG (ref);
> +                 if (!DF_REF_INSN_INFO (ref))
> +                   continue;
> +
>                   /* Make sure the next ref is for a different instruction,
>                      so that we're not affected by the rescan.  */
> -                 next = DF_REF_NEXT_REG (ref);
> +                 rtx_insn *insn = DF_REF_INSN (ref);
>                   while (next && DF_REF_INSN (next) == insn)
>                     next = DF_REF_NEXT_REG (next);
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr82673.c b/gcc/testsuite/gcc.target/i386/pr82673.c
> new file mode 100644
> index 00000000000..cff4b34535b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr82673.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O0 -fno-omit-frame-pointer -fvar-tracking-assignments-toggle" } */

Use -fvar-tracking-assignments here.

> +
> +register long *B asm ("ebp");
> +
> +long y = 20;
> +
> +void
> +bar (void) /* { dg-error "frame pointer required, but reserved" } */
> +{
> +  B = &y;
> +} /* { dg-error "bp cannot be used in asm here" } */
> --
> 2.13.6
>


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