public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/42462]  New: wrong-code with computed-goto
@ 2009-12-22 13:31 wouter dot vermaelen at scarlet dot be
  2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2009-12-22 13:31 UTC (permalink / raw)
  To: gcc-bugs

> cat Foo.cc
#define INLINE inline __attribute__((always_inline))

template<class> struct Foo {
        inline bool isFalse() { return false; }
        template <bool>        void f1() {}
        template <bool> INLINE void f2() { f1<false>(); }
        template <bool>        void f3() { f2<false>(); }
        template <bool> INLINE void f4() { f3<false>(); }
        void exec2();
        void execute();
        inline void unused();
};

template<class T> inline void Foo<T>::unused() {
        f4<true>();
}

template<class T> void Foo<T>::exec2() {
        static void* table[2] = { &&begin, &&end };
        goto *(table[0]);
begin:
        if (isFalse()) f1<false>();
end:
        return;
}

template<class T> void Foo<T>::execute() {
        while (true) { exec2(); }
}

template class Foo<int>;

int main() {
        Foo<int> c;
        c.execute();
}


> g++ -O2 Foo.cc


This program should get stuck in an infinite loop (I confirmed this with
g++-4.4 (Debian 4.4.2-3) 4.4.2). But when compiled with a recent SVN snapshot
it exits immediately.

I'm using revision trunk@155361 on linux x86_64.


-- 
           Summary: wrong-code with computed-goto
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wouter dot vermaelen at scarlet dot be


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
@ 2009-12-22 14:16 ` paolo dot carlini at oracle dot com
  2009-12-23 17:21 ` wouter dot vermaelen at scarlet dot be
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-22 14:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2009-12-22 14:16 -------
Long term, I would suggest staying away from these extensions, and try to write
portable code...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
  2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
@ 2009-12-23 17:21 ` wouter dot vermaelen at scarlet dot be
  2009-12-31 15:57 ` [Bug tree-optimization/42462] [4.5 Regression] " rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2009-12-23 17:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from wouter dot vermaelen at scarlet dot be  2009-12-23 17:21 -------
Seems this problem got introduced in revision 152492 (152491 still works,
152492 shows the problem).
   2009-10-06  Martin Jambor  <mjambor@suse.cz>
        PR bootstrap/41395
        * opts.c (decode_options): Run IPA-SRA at -O2.
(Though this patch is probably not the root cause).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
  2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
  2009-12-23 17:21 ` wouter dot vermaelen at scarlet dot be
@ 2009-12-31 15:57 ` rguenth at gcc dot gnu dot org
  2010-01-02 16:08 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-12-31 15:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-12-31 15:57 -------
-O1 -fipa-sra shows the problem as well.  We can see wrong (or rather missing)
cloning of static initializers:

;; Function void Foo< <template-parameter-1-1> >::exec2() [with
<template-parameter-1-1> = int] (_ZN3FooIiE5exec2Ev)

void Foo< <template-parameter-1-1> >::exec2() [with <template-parameter-1-1> =
int] (struct FooD.1756 * const thisD.1781)
{
  voidD.35 * gotovar.1D.1832;
  boolD.1631 D.1831;
  static voidD.35 * tableD.1795[2] = {&beginL.0, &endL.4};

<bb 2>:
  gotovar.1D.1832_1 = tableD.1795[0];
  goto gotovar.1D.1832_1;

beginL.0:

endL.4:
  return;

}


;; Function void Foo< <template-parameter-1-1> >::execute() [with
<template-parameter-1-1> = int] (_ZN3FooIiE7executeEv)

void Foo< <template-parameter-1-1> >::execute() [with <template-parameter-1-1>
= int] (struct FooD.1756 * const thisD.1783)
{
  static voidD.35 * tableD.1795[2] = {&beginL.0, &endL.4};
  voidD.35 * gotovar.1D.1845;
  static voidD.35 * tableD.1795[2] = {&beginL.0, &endL.4};

<bb 2>:
  gotovar.1D.1845_5 = tableD.1795[0];
  goto gotovar.1D.1845_5;

beginL.1:

endL.2:
  goto <bb 2>;

}

Hm.  Honza?  This looks like an issue with non-localized vars?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu dot
                   |                            |org, hubicka at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2009-12-31 15:57:11
               date|                            |
            Summary|wrong-code with computed-   |[4.5 Regression] wrong-code
                   |goto                        |with computed-goto
   Target Milestone|---                         |4.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (2 preceding siblings ...)
  2009-12-31 15:57 ` [Bug tree-optimization/42462] [4.5 Regression] " rguenth at gcc dot gnu dot org
@ 2010-01-02 16:08 ` rguenth at gcc dot gnu dot org
  2010-01-05 13:39 ` jamborm at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-02 16:08 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (3 preceding siblings ...)
  2010-01-02 16:08 ` rguenth at gcc dot gnu dot org
@ 2010-01-05 13:39 ` jamborm at gcc dot gnu dot org
  2010-01-05 16:03 ` jamborm at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jamborm at gcc dot gnu dot org @ 2010-01-05 13:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jamborm at gcc dot gnu dot org  2010-01-05 13:39 -------
This weird side-effect of IPA-SRA is caused by a bug in
compute_inline_parameters which should pass node->decl instead of
current_function_decl to its helper functions.  I am about to test the
following patch which fixes this problem:

Index: mine/gcc/ipa-inline.c
===================================================================
--- mine.orig/gcc/ipa-inline.c
+++ mine/gcc/ipa-inline.c
@@ -1859,10 +1859,10 @@ compute_inline_parameters (struct cgraph
   node->global.stack_frame_offset = 0;

   /* Can this function be inlined at all?  */
-  node->local.inlinable = tree_inlinable_function_p (current_function_decl);
+  node->local.inlinable = tree_inlinable_function_p (node->decl);
   if (node->local.inlinable && !node->local.disregard_inline_limits)
     node->local.disregard_inline_limits
-      = DECL_DISREGARD_INLINE_LIMITS (current_function_decl);
+      = DECL_DISREGARD_INLINE_LIMITS (node->decl);
   estimate_function_body_sizes (node);
   /* Inlining characteristics are maintained by the cgraph_mark_inline.  */
   node->global.time = inline_summary (node)->self_time;


-- 

jamborm at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jamborm at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-12-31 15:57:11         |2010-01-05 13:39:11
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (4 preceding siblings ...)
  2010-01-05 13:39 ` jamborm at gcc dot gnu dot org
@ 2010-01-05 16:03 ` jamborm at gcc dot gnu dot org
  2010-01-05 19:43 ` jamborm at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jamborm at gcc dot gnu dot org @ 2010-01-05 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jamborm at gcc dot gnu dot org  2010-01-05 16:03 -------
Patch posted to the mailing list:
http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00215.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (5 preceding siblings ...)
  2010-01-05 16:03 ` jamborm at gcc dot gnu dot org
@ 2010-01-05 19:43 ` jamborm at gcc dot gnu dot org
  2010-01-05 19:44 ` jamborm at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jamborm at gcc dot gnu dot org @ 2010-01-05 19:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jamborm at gcc dot gnu dot org  2010-01-05 19:42 -------
Subject: Bug 42462

Author: jamborm
Date: Tue Jan  5 19:42:32 2010
New Revision: 155658

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155658
Log:
2010-01-05  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/42462
        * ipa-inline.c (compute_inline_parameters): Pass node->decl instead of
        current_function_decl to helper functions and macros.

        * gcc/testsuite/g++.dg/torture/pr42462.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/torture/pr42462.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-inline.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (6 preceding siblings ...)
  2010-01-05 19:43 ` jamborm at gcc dot gnu dot org
@ 2010-01-05 19:44 ` jamborm at gcc dot gnu dot org
  2010-01-07 22:24 ` hjl at gcc dot gnu dot org
  2010-02-08 14:11 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jamborm at gcc dot gnu dot org @ 2010-01-05 19:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jamborm at gcc dot gnu dot org  2010-01-05 19:44 -------
Fixed.


-- 

jamborm at gcc dot gnu dot org changed:

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


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (7 preceding siblings ...)
  2010-01-05 19:44 ` jamborm at gcc dot gnu dot org
@ 2010-01-07 22:24 ` hjl at gcc dot gnu dot org
  2010-02-08 14:11 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: hjl at gcc dot gnu dot org @ 2010-01-07 22:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hjl at gcc dot gnu dot org  2010-01-07 22:23 -------
Subject: Bug 42462

Author: hjl
Date: Thu Jan  7 22:22:32 2010
New Revision: 155713

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155713
Log:
Backport tests from mainline

2010-01-07  H.J. Lu  <hongjiu.lu@intel.com>

        Backport from mainline:
        2010-01-06  Richard Guenther  <rguenther@suse.de>

        * gcc.c-torture/compile/pr42632.c: New testcase.

        2010-01-05  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/42462
        * g++.dg/torture/pr42462.C: New test.

        2010-01-05  Jakub Jelinek  <jakub@redhat.com>

        PR tree-optimization/42508
        * g++.dg/opt/pr42508.C: New test.

        2010-01-04  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/42398
        * gcc.c-torture/compile/pr42398.c: New test.

        2010-01-04  Jason Merrill  <jason@redhat.com>

        PR c++/42555
        * g++.dg/ext/attrib35.C: New.

        2010-01-01  Richard Guenther  <rguenther@suse.de>

        PR c/42570
        * gcc.c-torture/execute/pr42570.c: New testcase.

        2010-01-01  Richard Guenther  <rguenther@suse.de>

        PR middle-end/42559
        * gcc.c-torture/compile/pr42559.c: New testcase.

        2009-12-30  Joseph Myers  <joseph@codesourcery.com>

        PR c/42439
        * gcc.dg/bitfld-19.c: New test.

        2009-12-28  Jason Merrill  <jason@redhat.com>

        PR c++/42447
        * g++.dg/template/array21.C: New.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/attrib35.C
      - copied unchanged from r155711,
trunk/gcc/testsuite/g++.dg/ext/attrib35.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/pr42508.C
      - copied unchanged from r155711, trunk/gcc/testsuite/g++.dg/opt/pr42508.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/array21.C
      - copied unchanged from r155710,
trunk/gcc/testsuite/g++.dg/template/array21.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42462.C
      - copied unchanged from r155711,
trunk/gcc/testsuite/g++.dg/torture/pr42462.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42398.c
      - copied unchanged from r155711,
trunk/gcc/testsuite/gcc.c-torture/compile/pr42398.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42559.c
      - copied unchanged from r155712,
trunk/gcc/testsuite/gcc.c-torture/compile/pr42559.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42632.c
      - copied unchanged from r155710,
trunk/gcc/testsuite/gcc.c-torture/compile/pr42632.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42570.c
      - copied unchanged from r155712,
trunk/gcc/testsuite/gcc.c-torture/execute/pr42570.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/bitfld-19.c
      - copied unchanged from r155710, trunk/gcc/testsuite/gcc.dg/bitfld-19.c
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

* [Bug tree-optimization/42462] [4.5 Regression] wrong-code with computed-goto
  2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
                   ` (8 preceding siblings ...)
  2010-01-07 22:24 ` hjl at gcc dot gnu dot org
@ 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-02-08 14:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2010-02-08 14:10 -------
Subject: Bug 42462

Author: rguenth
Date: Mon Feb  8 14:10:15 2010
New Revision: 156601

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156601
Log:
2010-02-08  Richard Guenther  <rguenther@suse.de>

        PR middle-end/42995
        * tree-inline.c (estimate_move_cost): Assert we are not called
        with a void type.
        (estimate_num_insns): Do not count the terminating void_type_node
        of a function argument type list.

        Backport from mainline:
        2010-01-06  Richard Guenther  <rguenther@suse.de>

        * ipa-inline.c (cgraph_decide_inlining_incrementally): Do
        not inline regular functions into always-inline functions.

        2010-01-05  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/42462
        * ipa-inline.c (compute_inline_parameters): Pass node->decl instead of
        current_function_decl to helper functions and macros.

        * gcc.dg/tree-ssa/inline-4.c: New testcase.
        * gcc.dg/Wunreachable-2.c: Remove.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/inline-4.c
Removed:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/Wunreachable-2.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/ipa-inline.c
    branches/gcc-4_4-branch/gcc/tree-inline.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42462


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

end of thread, other threads:[~2010-02-08 14:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 13:31 [Bug tree-optimization/42462] New: wrong-code with computed-goto wouter dot vermaelen at scarlet dot be
2009-12-22 14:16 ` [Bug tree-optimization/42462] " paolo dot carlini at oracle dot com
2009-12-23 17:21 ` wouter dot vermaelen at scarlet dot be
2009-12-31 15:57 ` [Bug tree-optimization/42462] [4.5 Regression] " rguenth at gcc dot gnu dot org
2010-01-02 16:08 ` rguenth at gcc dot gnu dot org
2010-01-05 13:39 ` jamborm at gcc dot gnu dot org
2010-01-05 16:03 ` jamborm at gcc dot gnu dot org
2010-01-05 19:43 ` jamborm at gcc dot gnu dot org
2010-01-05 19:44 ` jamborm at gcc dot gnu dot org
2010-01-07 22:24 ` hjl at gcc dot gnu dot org
2010-02-08 14:11 ` rguenth at gcc dot gnu dot 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).