From 66f4014d4bf82b7f92c99d18513cc6dc947b9ece Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 23 Oct 2017 15:49:19 +0000 Subject: [PATCH] i386: Skip DF_REF_INSN if DF_REF_INSN_INFO is false We should check DF_REF_INSN_INFO before accessing DF_REF_INSN. 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. From-SVN: r254013 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 7 +++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr82673.c | 12 ++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr82673.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be739723a35..ab759abefd3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-23 H.J. Lu + + PR target/82673 + * config/i386/i386.c (ix86_finalize_stack_frame_flags): Skip + DF_REF_INSN if DF_REF_INSN_INFO is false. + 2017-10-23 Jan Hubicka * i386.c (dimode_scalar_chain::compute_convert_gain): Use diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b182cc6c0ee..3fafcfe9613 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -12692,10 +12692,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/ChangeLog b/gcc/testsuite/ChangeLog index 3aadb9e8a89..f4c09481911 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-23 H.J. Lu + + PR target/82673 + * gcc.target/i386/pr82673.c: New test. + 2017-10-23 Jakub Jelinek * lib/scanasm.exp (dg-function-on-line): Accept optional column info. diff --git a/gcc/testsuite/gcc.target/i386/pr82673.c b/gcc/testsuite/gcc.target/i386/pr82673.c new file mode 100644 index 00000000000..50eb5a3bcfc --- /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" } */ + +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.30.2