public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu
@ 2014-05-14  1:30 su at cs dot ucdavis.edu
  2014-05-14  8:53 ` [Bug c/61184] [4.10 Regression] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-05-14  1:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

            Bug ID: 61184
           Summary: wrong code (that hangs) by LTO on x86_64-linux-gnu
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following code when using LTO on
x86_64-linux-gnu in both 32-bit and 64-bit modes.  The generated code hangs. 

This is a regression from 4.9.x. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140513 (experimental) [trunk revision 210350] (GCC) 
$ 
$ gcc-trunk -flto -O0 -c foo.c 
$ gcc-trunk -flto -O0 -c main.c
$ gcc-trunk -flto -Os foo.o main.o
$ a.out
^C
$ 
$ gcc-4.9.0 -flto -O0 -c foo.c
$ gcc-4.9.0 -flto -O0 -c main.c
$ gcc-4.9.0 -flto -Os foo.o main.o
$ a.out
$ 
$ cat foo.c
short a; 

void
foo (void)
{
  for (a = 0; a >= 0; a++)
    ;
}
$ cat main.c
extern void foo (void); 

int
main ()
{
  foo ();
  return 0;
}
$


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2014-05-14  8:53 ` rguenth at gcc dot gnu.org
  2014-05-19 10:16 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-14  8:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2014-05-14
          Component|lto                         |c
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
            Summary|wrong code (that hangs) by  |[4.10 Regression] wrong
                   |LTO on x86_64-linux-gnu     |code (that hangs) by LTO on
                   |                            |x86_64-linux-gnu
   Target Milestone|---                         |4.10.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  VRP2 transforms this wrongly.  Can be reproduced without LTO
and just with -Os -fno-strict-overflow.

It boils down to gimplification optimizing the auto-inc in short as if
overflow would wrap.  But -fno-strict-overflow does _not_ say overflow
wraps.  It just says we don't treat as many things as overflowing
(yeah, quite useless).

Thus we may not do:

    case PREINCREMENT_EXPR:
    case PREDECREMENT_EXPR:
    case POSTINCREMENT_EXPR:
    case POSTDECREMENT_EXPR:
      {
        tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 0));
        if (INTEGRAL_TYPE_P (type) && c_promoting_integer_type_p (type))
          {
            if (TYPE_OVERFLOW_UNDEFINED (type)
                || ((flag_sanitize & SANITIZE_SI_OVERFLOW)
                    && !TYPE_OVERFLOW_WRAPS (type)))
              type = unsigned_type_for (type);
            return gimplify_self_mod_expr (expr_p, pre_p, post_p, 1, type);
          }
        break;
      }

but have to use !TYPE_OVERFLOW_WRAPS (type) - sanitization should have
shown this.

So it's not really a 4.10 regression only, but latent (and thus not really a
regression).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-05-14  8:53 ` [Bug c/61184] [4.10 Regression] " rguenth at gcc dot gnu.org
@ 2014-05-19 10:16 ` rguenth at gcc dot gnu.org
  2014-05-19 12:32 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-19 10:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ok, it's rather an old bug in vrp_operand_equal_p which does

  if (is_overflow_infinity (val1))
    return is_overflow_infinity (val2);

which isn't correct for how it is called from update_value_range
(old value first, new value last and in this particular case
+INF and +INF(OVF) which are happily classified as equal).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-05-14  8:53 ` [Bug c/61184] [4.10 Regression] " rguenth at gcc dot gnu.org
  2014-05-19 10:16 ` rguenth at gcc dot gnu.org
@ 2014-05-19 12:32 ` rguenth at gcc dot gnu.org
  2014-05-19 12:47 ` [Bug tree-optimization/61184] " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-19 12:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon May 19 12:32:15 2014
New Revision: 210611

URL: http://gcc.gnu.org/viewcvs?rev=210611&root=gcc&view=rev
Log:
2014-05-19  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/61184
    * tree-vrp.c (is_negative_overflow_infinity): Use
    TREE_OVERFLOW_P and do that check first.
    (is_positive_overflow_infinity): Likewise.
    (is_overflow_infinity): Likewise.
    (vrp_operand_equal_p): Properly treat operands with
    differing overflow as not equal.

    * c-c++-common/torture/pr61184.c: New testcase.

Added:
    trunk/gcc/testsuite/c-c++-common/torture/pr61184.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2014-05-19 12:32 ` rguenth at gcc dot gnu.org
@ 2014-05-19 12:47 ` rguenth at gcc dot gnu.org
  2014-05-21  9:17 ` schwab@linux-m68k.org
  2014-05-23  8:14 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-19 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
          Component|c                           |tree-optimization
         Resolution|---                         |FIXED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2014-05-19 12:47 ` [Bug tree-optimization/61184] " rguenth at gcc dot gnu.org
@ 2014-05-21  9:17 ` schwab@linux-m68k.org
  2014-05-23  8:14 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2014-05-21  9:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184

--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
This breaks gcc.dg/Wstrict-overflow-18.c.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/61184] [4.10 Regression] wrong code (that hangs) by LTO on x86_64-linux-gnu
  2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2014-05-21  9:17 ` schwab@linux-m68k.org
@ 2014-05-23  8:14 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-23  8:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61184
Bug 61184 depends on bug 61266, which changed state.

Bug 61266 Summary: [4.10 regression] FAIL: gcc.dg/Wstrict-overflow-18.c  (test for bogus messages, line 20)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61266

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-23  8:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14  1:30 [Bug lto/61184] New: wrong code (that hangs) by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-05-14  8:53 ` [Bug c/61184] [4.10 Regression] " rguenth at gcc dot gnu.org
2014-05-19 10:16 ` rguenth at gcc dot gnu.org
2014-05-19 12:32 ` rguenth at gcc dot gnu.org
2014-05-19 12:47 ` [Bug tree-optimization/61184] " rguenth at gcc dot gnu.org
2014-05-21  9:17 ` schwab@linux-m68k.org
2014-05-23  8:14 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).