From: Eric Botcazou Date: Mon, 6 Jan 2014 11:39:41 +0000 (+0000) Subject: re PR debug/59350 (ICE: in vt_expand_var_loc_chain, at var-tracking.c:8212) X-Git-Tag: releases/gcc-4.9.0~1827 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b5cd2a02573975f60ea28f5f24ee564e750c87b9;p=thirdparty%2Fgcc.git re PR debug/59350 (ICE: in vt_expand_var_loc_chain, at var-tracking.c:8212) PR debug/59350 PR debug/59510 * var-tracking.c (add_stores): Preserve the value of the source even if we don't record the store. From-SVN: r206356 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33548a07100b..a810fa22c22b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-01-06 Eric Botcazou + + PR debug/59350 + PR debug/59510 + * var-tracking.c (add_stores): Preserve the value of the source even if + we don't record the store. + 2014-01-06 Terry Guo * config.gcc (arm*-*-*): Check --with-arch against arm-arches.def. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c46c8df0d010..e2b84c5278fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-01-06 Eric Botcazou + + * gcc.dg/pr59350.c: Tweak. + * gcc.dg/pr59350-2.c: New test. + * g++.dg/pr59510.C: Likewise. + 2014-01-06 Janus Weil PR fortran/59023 diff --git a/gcc/testsuite/g++.dg/pr59510.C b/gcc/testsuite/g++.dg/pr59510.C new file mode 100644 index 000000000000..dcdf860dcf73 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr59510.C @@ -0,0 +1,82 @@ +// PR debug/59510 +// { dg-do compile } +// { dg-options "-O2 -g --param=large-stack-frame-growth=1" } + +template +struct _Iter_base +{ + typedef _Iterator iterator_type; +}; +template +struct basic_ostream; +template +struct basic_ostringstream; +template +struct ostreambuf_iterator; +typedef basic_ostringstream ostringstream; +template struct _Miter_base : _Iter_base <_Iterator> +{ +}; +template +typename _Miter_base <_Iterator>::iterator_type __miter_base (_Iterator); +template +ostreambuf_iterator <_CharT> +__copy_move_a2 (ostreambuf_iterator <_CharT>); +template +_OI copy (_II __first, _II __last, _OI __result) +{ + __copy_move_a2 (__first, __miter_base (__last), __result); +} +struct ios_base { + struct _Words { + int *_M_pword; + long _M_iword; + }; + _Words _M_local_word[8]; +}; +template +struct basic_streambuf +{ + typedef _CharT char_type; + int sputn (char_type *, int); +}; +template +struct ostreambuf_iterator +{ + typedef basic_streambuf <_CharT> streambuf_type; + typedef basic_ostream <_CharT> ostream_type; + streambuf_type *_M_sbuf; + bool _M_failed; + ostreambuf_iterator (ostream_type __s) : _M_sbuf (__s.rdbuf ()), _M_failed () {} + void _M_put (_CharT * __ws, int __len) + { + if (_M_failed && _M_sbuf->sputn (__ws, __len) != __len) _M_failed = true; + } +}; +template +void __copy_move_a2 (_CharT * __first,_CharT * __last,ostreambuf_iterator <_CharT> __result) +{ + int __num = __last - __first; + __result._M_put (__first, __num); +} +template +struct basic_ios : ios_base +{ + basic_streambuf <_CharT> *rdbuf (); +}; +template +struct basic_ostream : public basic_ios <_CharT> +{ +}; +template +struct basic_ostringstream : public basic_ostream <_CharT> +{ +}; +void +test01 () { + char data1[] = "foo"; + char *beg1 = data1; + ostringstream oss1; + ostreambuf_iterator out1 (oss1); + out1 = copy (beg1, beg1, out1); +} diff --git a/gcc/testsuite/gcc.dg/pr59350-2.c b/gcc/testsuite/gcc.dg/pr59350-2.c new file mode 100644 index 000000000000..2fea85fcf719 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59350-2.c @@ -0,0 +1,29 @@ +/* PR debug/59350 */ + +/* { dg-do compile } */ +/* { dg-options "-O -g " } */ + +typedef struct +{ + void *v; + int len; + int sign; +} ZVALUE; + +extern int pred (ZVALUE); + +static unsigned long +small_factor (ZVALUE z) +{ + if (z.len > 0) + return 0; + + return pred (z) ? -1 : 0; +} + +unsigned long +zfactor (ZVALUE z) +{ + z.sign = 0; + return small_factor (z); +} diff --git a/gcc/testsuite/gcc.dg/pr59350.c b/gcc/testsuite/gcc.dg/pr59350.c index be186873ac58..fa632454ae1e 100644 --- a/gcc/testsuite/gcc.dg/pr59350.c +++ b/gcc/testsuite/gcc.dg/pr59350.c @@ -1,4 +1,4 @@ -/* PR rtl-optimization/59350 */ +/* PR debug/59350 */ /* Testcase by Ryan Mansfield */ /* { dg-do compile } */ diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index ee16aed35646..cfa785079f64 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -5930,6 +5930,13 @@ add_stores (rtx loc, const_rtx expr, void *cuip) if (type != MO_VAL_SET) goto log_and_return; + v = find_use_val (oloc, mode, cui); + + if (!v) + goto log_and_return; + + resolve = preserve = !cselib_preserved_value_p (v); + /* We cannot track values for multiple-part variables, so we track only locations for tracked parameters passed either by invisible reference or directly in multiple locations. */ @@ -5943,14 +5950,15 @@ add_stores (rtx loc, const_rtx expr, void *cuip) && XEXP (DECL_INCOMING_RTL (REG_EXPR (loc)), 0) != arg_pointer_rtx) || (GET_CODE (DECL_INCOMING_RTL (REG_EXPR (loc))) == PARALLEL && XVECLEN (DECL_INCOMING_RTL (REG_EXPR (loc)), 0) > 1))) - goto log_and_return; - - v = find_use_val (oloc, mode, cui); - - if (!v) - goto log_and_return; - - resolve = preserve = !cselib_preserved_value_p (v); + { + /* Although we don't use the value here, it could be used later by the + mere virtue of its existence as the operand of the reverse operation + that gave rise to it (typically extension/truncation). Make sure it + is preserved as required by vt_expand_var_loc_chain. */ + if (preserve) + preserve_value (v); + goto log_and_return; + } if (loc == stack_pointer_rtx && hard_frame_pointer_adjustment != -1