Hi Segher, On 12/11/16 2:00 PM, Segher Boessenkool wrote: > Maybe this should use DF_REF_IS_ARTIFICIAL? Or if that doesn't work, > DF_REF_INSN_INFO? > OK, currently regstrapping the following, which also fixes the problem with a non-bootstrap compiler. Is this ok for trunk if it succeeds?
Thanks, Bill [gcc] 2016-12-11 Bill Schmidt <wschm...@linux.vnet.ibm.com> PR target/78695 * config/rs6000/rs6000.c (find_alignment_op): Discard from consideration any artificial definition. [gcc/testsuite] 2016-12-11 Bill Schmidt <wschm...@linux.vnet.ibm.com> PR target/78695 * gcc.target/powerpc/swaps-stack-protector.c: New test. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 243506) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -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_CLASS (base_def_link->ref) == DF_REF_ARTIFICIAL) + break; + rtx_insn *and_insn = DF_REF_INSN (base_def_link->ref); and_operation = alignment_mask (and_insn); if (and_operation != 0) Index: gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c (working copy) @@ -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++; +}