Message ID | 20180305204251.GS5867@tucnak |
---|---|
State | New |
Headers | show |
Series | Fix reg-stack error-recovery ICE (PR inline-asm/84683) | expand |
On Mon, Mar 5, 2018 at 9:42 PM, Jakub Jelinek <jakub@redhat.com> wrote: > Hi! > > If we discover some bad inline-asm during reg-stack processing and we > error on those, we replace that inline-asm with a (use (const_int 0)) > and therefore the various assumptions of reg-stack pass may not hold. > Seems we already have a couple of spots which are more permissive if > any_malformed_asm is true, this patch just adds another one. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2018-03-05 Jakub Jelinek <jakub@redhat.com> > > PR inline-asm/84683 > * reg-stack.c (move_for_stack_reg): If any_malformed_asm, avoid > assertion failure. > > * g++.dg/ext/pr84683.C: New test. LGTM. Uros. > --- gcc/reg-stack.c.jj 2018-01-03 10:19:55.000000000 +0100 > +++ gcc/reg-stack.c 2018-03-05 17:41:15.558415480 +0100 > @@ -1170,7 +1170,8 @@ move_for_stack_reg (rtx_insn *insn, stac > && XINT (SET_SRC (XVECEXP (pat, 0, 1)), 1) == UNSPEC_TAN) > emit_swap_insn (insn, regstack, dest); > else > - gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG); > + gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG > + || any_malformed_asm); > > gcc_assert (regstack->top < REG_STACK_SIZE); > > --- gcc/testsuite/g++.dg/ext/pr84683.C.jj 2018-03-05 17:45:32.901475529 +0100 > +++ gcc/testsuite/g++.dg/ext/pr84683.C 2018-03-05 17:44:52.527467872 +0100 > @@ -0,0 +1,13 @@ > +// PR inline-asm/84683 > +// { dg-do compile { target i?86-*-* x86_64-*-* } } > +// { dg-options "-O2" } > + > +void > +foo (float b, double c) > +{ > + for (int e = 0; e < 2; e++) > + { > + asm volatile ("" : "+f" (c)); // { dg-error "must specify a single register" } > + asm ("" : "+rm" (c = b)); > + } > +} > > Jakub
On 03/06/2018 01:03 AM, Uros Bizjak wrote: > On Mon, Mar 5, 2018 at 9:42 PM, Jakub Jelinek <jakub@redhat.com> wrote: >> Hi! >> >> If we discover some bad inline-asm during reg-stack processing and we >> error on those, we replace that inline-asm with a (use (const_int 0)) >> and therefore the various assumptions of reg-stack pass may not hold. >> Seems we already have a couple of spots which are more permissive if >> any_malformed_asm is true, this patch just adds another one. >> >> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? >> >> 2018-03-05 Jakub Jelinek <jakub@redhat.com> >> >> PR inline-asm/84683 >> * reg-stack.c (move_for_stack_reg): If any_malformed_asm, avoid >> assertion failure. >> >> * g++.dg/ext/pr84683.C: New test. > > LGTM. Likewise. jeff
--- gcc/reg-stack.c.jj 2018-01-03 10:19:55.000000000 +0100 +++ gcc/reg-stack.c 2018-03-05 17:41:15.558415480 +0100 @@ -1170,7 +1170,8 @@ move_for_stack_reg (rtx_insn *insn, stac && XINT (SET_SRC (XVECEXP (pat, 0, 1)), 1) == UNSPEC_TAN) emit_swap_insn (insn, regstack, dest); else - gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG); + gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG + || any_malformed_asm); gcc_assert (regstack->top < REG_STACK_SIZE); --- gcc/testsuite/g++.dg/ext/pr84683.C.jj 2018-03-05 17:45:32.901475529 +0100 +++ gcc/testsuite/g++.dg/ext/pr84683.C 2018-03-05 17:44:52.527467872 +0100 @@ -0,0 +1,13 @@ +// PR inline-asm/84683 +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-O2" } + +void +foo (float b, double c) +{ + for (int e = 0; e < 2; e++) + { + asm volatile ("" : "+f" (c)); // { dg-error "must specify a single register" } + asm ("" : "+rm" (c = b)); + } +}