From 3113e92dc3dc525af2b1b1d159ea5fed1828bd3b Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Sun, 11 Dec 2016 23:37:17 +0000 Subject: [PATCH] re PR target/78695 (ICE (segfault) on powerpc64le-linux-gnu) [gcc] 2016-12-11 Bill Schmidt PR target/78695 * config/rs6000/rs6000.c (find_alignment_op): Discard from consideration any artificial definition. [gcc/testsuite] 2016-12-11 Bill Schmidt PR target/78695 * gcc.target/powerpc/swaps-stack-protector.c: New test. From-SVN: r243534 --- gcc/ChangeLog | 6 ++++++ gcc/config/rs6000/rs6000.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ .../gcc.target/powerpc/swaps-stack-protector.c | 16 ++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9a48b0c02e..b6a058bf449 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-11 Bill Schmidt + + PR target/78695 + * config/rs6000/rs6000.c (find_alignment_op): Discard from + consideration any artificial definition. + 2016-12-11 Iain Sandoe * configure.ac (CROSS directory tests): Remove the assumption that diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 55e9548f766..6aa84369755 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -41433,6 +41433,12 @@ find_alignment_op (rtx_insn *insn, rtx base_reg) if (!base_def_link || base_def_link->next) break; + /* With stack-protector code enabled, and possibly in other + circumstances, there may not be an associated insn for + the def. */ + if (DF_REF_IS_ARTIFICIAL (base_def_link->ref)) + break; + rtx_insn *and_insn = DF_REF_INSN (base_def_link->ref); and_operation = alignment_mask (and_insn); if (and_operation != 0) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa9aae76e13..cde6eefc8ee 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-11 Bill Schmidt + + PR target/78695 + * gcc.target/powerpc/swaps-stack-protector.c: New test. + 2016-12-11 Uros Bizjak PR target/70799 diff --git a/gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c b/gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c new file mode 100644 index 00000000000..8093a26cc56 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fstack-protector -O3" } */ + +/* PR78695: This code used to ICE in rs6000.c:find_alignment_op because + the stack protector address definition isn't associated with an insn. */ + +void *a(); +long b() { + char c[1]; + char *d = a(), *e = c; + long f = e ? b(e) : 0; + if (f > 54) + f = 1; + while (f--) + *d++ = *e++; +} -- 2.30.2