Bug 42508 - [4.5 Regression] wrong code with "-O1 -fipa-sra"
[4.5 Regression] wrong code with "-O1 -fipa-sra"
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: tree-optimization
4.5.0
: P1 major
: 4.5.0
Assigned To: Jakub Jelinek
: wrong-code
Depends on:
Blocks: 42290
  Show dependency treegraph
 
Reported: 2009-12-26 11:18 UTC by Zdenek Sojka
Modified: 2010-01-05 08:58 UTC (History)
5 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-01-04 14:13:18


Attachments
testcase (272 bytes, text/plain)
2009-12-26 11:20 UTC, Zdenek Sojka
Details
gcc45-pr42508.patch (2.82 KB, patch)
2010-01-04 14:15 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2009-12-26 11:18:32 UTC
+++ This bug was initially created as a clone of Bug #42290 +++

Command line:
g++ -O1 -fipa-sra testcase.cpp && ./a.out
(-Wall shows valid (but misleading?) warnings as described in bug 42290)

Tested versions:
r155434 - broken
r154886 - broken
r154830 - OK
r153685 - OK

Output:
g++ -O1 -fipa-sra testcase.cpp && ./a.out
2
-1419800576

Expected output:
g++ -O1 -fipa-sra testcase.cpp && ./a.out
2
1
Comment 1 Zdenek Sojka 2009-12-26 11:20:33 UTC
Created attachment 19394 [details]
testcase

Command line:
g++ -O1 -fipa-sra pr42508.cpp && ./a.out
Comment 2 H.J. Lu 2009-12-26 21:04:27 UTC
It is caused by revision 154880:

http://gcc.gnu.org/ml/gcc-cvs/2009-12/msg00024.html
Comment 3 Richard Biener 2010-01-02 16:13:54 UTC
Confirmed.  Doesn't happen on i?86-linux or with -m32.
Comment 4 Jakub Jelinek 2010-01-04 14:15:43 UTC
Created attachment 19460 [details]
gcc45-pr42508.patch

Fix, so far not bootstrapped/regtested.  The cgraphunit.c hunk is only somewhat related, is not necessary to fix this, I've just noticed that the function was still modifying GIMPLE_CALL decl unnecessarily (and confusingly), when e->callee is an inline clone of some cgraph node with same_body aliases and GIMPLE_CALL calls the same_body alias.
Comment 5 Jakub Jelinek 2010-01-05 08:41:09 UTC
Subject: Bug 42508

Author: jakub
Date: Tue Jan  5 08:40:50 2010
New Revision: 155640

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155640
Log:
	PR tree-optimization/42508
	* tree-sra.c (convert_callers): Check for recursive call
	by comparing cgraph nodes instead of decls.
	(modify_function): Call ipa_modify_formal_parameters also
	on all same_body aliases.

	* g++.dg/opt/pr42508.C: New test.

	* cgraphunit.c (cgraph_materialize_all_clones): Compare
	cgraph nodes when checking for same_body aliases.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr42508.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraphunit.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c

Comment 6 Jakub Jelinek 2010-01-05 08:58:31 UTC
Fixed.
Comment 7 hjl@gcc.gnu.org 2010-01-07 22:23:12 UTC
Subject: Bug 42508

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