[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-04 Thread rguenth at gcc dot gnu dot org


--- Comment #29 from rguenth at gcc dot gnu dot org  2010-05-04 11:16 
---
Indeed.  Many thanks for these testcases!  I have a fix in testing.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-04 Thread rguenth at gcc dot gnu dot org


--- Comment #30 from rguenth at gcc dot gnu dot org  2010-05-04 13:12 
---
Subject: Bug 43879

Author: rguenth
Date: Tue May  4 13:12:02 2010
New Revision: 159026

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=159026
Log:
2010-05-04  Richard Guenther  rguent...@suse.de

PR tree-optimization/43879
* tree-ssa-structalias.c (alias_get_name): Use
DECL_ASSEMBLER_NAME if available.
(create_function_info_for): Return the varinfo node.
(ipa_pta_execute): Associate same-body aliases and extra names
with their origin nodes varinfo.  Dump DECL_ASSEMBLER_NAME.

* g++.dg/torture/pr43879-1_0.C: New testcase.
* g++.dg/torture/pr43879-1_1.C: Likewise.

Added:
trunk/gcc/testsuite/g++.dg/torture/pr43879-1_0.C
trunk/gcc/testsuite/g++.dg/torture/pr43879-1_1.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-structalias.c


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-04 Thread rguenth at gcc dot gnu dot org


--- Comment #31 from rguenth at gcc dot gnu dot org  2010-05-04 14:02 
---
Fixed!


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED
   Target Milestone|--- |4.6.0


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-03 Thread zsojka at seznam dot cz


--- Comment #25 from zsojka at seznam dot cz  2010-05-03 14:56 ---
Created an attachment (id=20546)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20546action=view)
next testcase, second part will follow


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-03 Thread zsojka at seznam dot cz


--- Comment #26 from zsojka at seznam dot cz  2010-05-03 15:02 ---
Created an attachment (id=20547)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20547action=view)
next testcase

Reduced from libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc

I am happy those testcases helped with gcc development, and I hope this one
will too.

Command line:
$ g++ -O[123] -fipa-pta pr43879-4_1.C pr43879-4_2.C  ./a.out
Aborted

For some reason, b1.i is expected to be zero:
(diff from asm output for a bit different testcase)
101c98
   cmp QWORD PTR [rsp+48], rbx # b2.i, b1$i
---
   cmp QWORD PTR [rsp+48], 0   # b2.i,


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-03 Thread steven at gcc dot gnu dot org


--- Comment #27 from steven at gcc dot gnu dot org  2010-05-03 16:56 ---
Zdenek, has anyone told you how amazing your contribution is here? Wow!


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-03 Thread zsojka at seznam dot cz


--- Comment #28 from zsojka at seznam dot cz  2010-05-03 23:45 ---
Thank you, Steven and Richard! It's nice to see the testcases are useful and
appreciated.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-02 Thread zsojka at seznam dot cz


--- Comment #21 from zsojka at seznam dot cz  2010-05-02 13:45 ---
Created an attachment (id=20534)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20534action=view)
reduced testcase, from lto-section-out.c

Miscompiled function is lto-section-out.c:lto_output_fn_decl_index()
lto_output_fn_decl_index:
mov rax, rdi# decl_state, decl_state
lea rcx, [rsp-12]   # tmp62,
mov rdi, rsi# obs, obs
lea rsi, [rax+48]   # tmp63,
jmp lto_output_decl_index   #

tmp62 is index, but it is allocated under the stack pointer. Later, when
lto_output_decl_index() executes *this_index = index;, it overwrites
registers stored on stack:
lto_output_decl_index:
... # r15 is saved:
mov QWORD PTR [rsp-8], r15  #,
... # saved r15 is overwritten:
mov DWORD PTR [r15], ebx# *this_index_24(D), index
... # wrong r15 is reloaded:
mov r15, QWORD PTR [rsp+80] #,

The testcase works only on x86_64, with command line:
$ gcc -O[2s] -fipa-pta pr43879-3.c
$ gcc -O1 -fipa-pta -foptimize-sibling-calls pr43879-3.c
$ ./a.out
Aborted


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-02 Thread zsojka at seznam dot cz


--- Comment #22 from zsojka at seznam dot cz  2010-05-02 13:47 ---
Of course the overwritten register is r14:
mov QWORD PTR [rsp-16], r14 #,
mov DWORD PTR [r15], ebx# *this_index_24(D), index
mov r14, QWORD PTR [rsp+72] #,


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-02 Thread rguenth at gcc dot gnu dot org


--- Comment #23 from rguenth at gcc dot gnu dot org  2010-05-02 18:11 
---
Subject: Bug 43879

Author: rguenth
Date: Sun May  2 18:10:53 2010
New Revision: 158977

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=158977
Log:
2010-05-02  Richard Guenther  rguent...@suse.de

PR tree-optimization/43879
* tree-tailcall.c (find_tail_calls): Clobbers also prevent
tail calls.

* gcc.dg/torture/pr43879-3.c: New testcase.

Added:
trunk/gcc/testsuite/gcc.dg/torture/pr43879-3.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-tailcall.c


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-05-02 Thread rguenth at gcc dot gnu dot org


--- Comment #24 from rguenth at gcc dot gnu dot org  2010-05-02 18:12 
---
Thanks for the testcase!  The issue is now fixed and bootstrap with IPA-PTA
enabled succeeds and the testresults are the same as without (with -fipa-pta
enabled).

There are still the same libstdc++ miscompiles and the known missed
optimizations.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #11 from rguenth at gcc dot gnu dot org  2010-04-30 08:23 
---
Subject: Bug 43879

Author: rguenth
Date: Fri Apr 30 08:22:15 2010
New Revision: 158924

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=158924
Log:
2010-04-30  Richard Guenther  rguent...@suse.de

PR tree-optimization/43879
* tree-ssa-structalias.c (get_constraint_for_1): Properly
handle non-zero initializers.

* gcc.dg/torture/pr43879_1.c: New testcase.

Added:
trunk/gcc/testsuite/gcc.dg/torture/pr43879_1.c
trunk/gcc/testsuite/gcc.dg/torture/pr43879_2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-structalias.c


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #12 from rguenth at gcc dot gnu dot org  2010-04-30 09:00 
---
With the last patch we are down to

=== libstdc++ tests ===


Running target unix/-fipa-pta/
FAIL: 23_containers/bitset/operations/1.cc execution test
FAIL: 23_containers/bitset/to_ullong/1.cc execution test

plus some gfortran procedure pointer tests (might be invalid or require
-fwhole-file to work) and 

FAIL: gcc.c-torture/execute/frame-address.c execution,  -O2

which is an invalid testcase with -fipa-pta (it gets optimized too far,
the stack frame is elided).


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #13 from rguenth at gcc dot gnu dot org  2010-04-30 10:06 
---
I can now successfully bootstrap with -O2 -fipa-pta but lto1 seems to be
miscompiled (all LTO tests ICE).


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #14 from rguenth at gcc dot gnu dot org  2010-04-30 13:57 
---
Indeed all proc_ptr_* execution FAILs are fixed with -fwhole-program.  The
frontend does not properly unify decls for example in proc_ptr_comp_12.f90
for

  testObj%test = returnMat

vs.

  function returnMat( a, b ) result( mat )

without -fwhole-file.  But all IPA optimizations rely on that, so it's
critical that -fwhole-file is enabled.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread dominiq at lps dot ens dot fr


--- Comment #15 from dominiq at lps dot ens dot fr  2010-04-30 14:51 ---
 ... without -fwhole-file.  But all IPA optimizations rely on that, so it's
 critical that -fwhole-file is enabled.

-fwhole-file works only at the file level, i.e., if proc_ptr_comp_12.f90 is
split as:

[macbook] f90/bug% cat aa.f90
! { dg-do run }
!
! PR 40646: [F03] array-valued procedure pointer components
!
! Original test case by Charlie Sharpsteen ch...@sharpsteen.net
! Modified by Janus Weil ja...@gcc.gnu.org

module bugTestMod
  implicit none
  type:: boundTest
procedure(returnMat), pointer, nopass:: test
  end type boundTest
contains
  function returnMat( a, b ) result( mat )
integer:: a, b
double precision, dimension(a,b):: mat 
mat = 1d0
  end function returnMat
end module bugTestMod

[macbook] f90/bug% cat bb.f90
program bugTest
  use bugTestMod
  implicit none
  type( boundTest ):: testObj
  double precision, dimension(2,2):: testCatch
  testObj%test = returnMat
  testCatch = testObj%test(2,2)
  print *,testCatch
  if (sum(testCatch)/=4) call abort()
  print *,testObj%test(3,3)
  if (sum(testObj%test(3,3))/=9) call abort()
end program bugTest

! { dg-final { cleanup-modules bugTestMod } }

one gets

[macbook] f90/bug% gfc -O2 -fipa-pta bb.f90 aa.f90 -fwhole-file -flto
[macbook] f90/bug% a.out
   1.1.1.  
 1. 
   1.1.1.  
 1.1.1.   
1.1.1. 
Segmentation fault


-- 

dominiq at lps dot ens dot fr changed:

   What|Removed |Added

 CC||pault at gcc dot gnu dot org


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #16 from rguenth at gcc dot gnu dot org  2010-04-30 15:17 
---
(In reply to comment #15)
  ... without -fwhole-file.  But all IPA optimizations rely on that, so it's
  critical that -fwhole-file is enabled.
 
 -fwhole-file works only at the file level, i.e., if proc_ptr_comp_12.f90 is
 split as:
 
 [macbook] f90/bug% cat aa.f90
 ! { dg-do run }
 !
 ! PR 40646: [F03] array-valued procedure pointer components
 !
 ! Original test case by Charlie Sharpsteen ch...@sharpsteen.net
 ! Modified by Janus Weil ja...@gcc.gnu.org
 
 module bugTestMod
   implicit none
   type:: boundTest
 procedure(returnMat), pointer, nopass:: test
   end type boundTest
 contains
   function returnMat( a, b ) result( mat )
 integer:: a, b
 double precision, dimension(a,b):: mat 
 mat = 1d0
   end function returnMat
 end module bugTestMod
 
 [macbook] f90/bug% cat bb.f90
 program bugTest
   use bugTestMod

As far as I understand this use statement causes GFortran to read in the
bytecode from the .mod file and combine the files again to a single
translation unit.  So this split is in fact not a split.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread jv244 at cam dot ac dot uk


--- Comment #17 from jv244 at cam dot ac dot uk  2010-04-30 15:26 ---
in this case the Fortran bits depend on PR40011


-- 

jv244 at cam dot ac dot uk changed:

   What|Removed |Added

  BugsThisDependsOn||40011


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread dominiq at lps dot ens dot fr


--- Comment #18 from dominiq at lps dot ens dot fr  2010-04-30 15:53 ---
 As far as I understand this use statement causes GFortran to read in the
 bytecode from the .mod file and combine the files again to a single
 translation unit.  So this split is in fact not a split.

From my very limited understanding of the content of *.mod files, there is
nothing such as a bytecode in them, but only the information needed for the
USE statements:

[macbook] f90/bug% cat aa.mod
GFORTRAN module version '5' created from pr36761.f90 on Tue Apr 20 08:55:48
2010
MD5:8452a2eab439f2a00c76ddd985f3af67 -- If you edit this, you'll get what you
deserve.

(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())

()

()

()

()

()

(2 'aa' 'aa' 'aa' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
3 'md' 'aa' 'md' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 ALLOCATABLE DIMENSION) (REAL 8 0 0 REAL ()) 0 0 () (2 0
DEFERRED () () () ()) 0 () () () 0 0)
)

('aa' 0 2 'md' 0 3)

I don't know what information you need for -fipa-pta, but it is likely not
there.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #19 from rguenth at gcc dot gnu dot org  2010-04-30 17:12 
---
(In reply to comment #18)
  As far as I understand this use statement causes GFortran to read in the
  bytecode from the .mod file and combine the files again to a single
  translation unit.  So this split is in fact not a split.
 
 From my very limited understanding of the content of *.mod files, there is
 nothing such as a bytecode in them, but only the information needed for the
 USE statements:

You are right.  The .mod files only seem to contain declaration information.
So splitting the file should make the testcase work ...

 I don't know what information you need for -fipa-pta, but it is likely not
 there.

... I need callgraph information not misrepresented.  Indeed it's a bug
in IPA-PTA that makes the separate case fail.  I have a patch.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-30 Thread rguenth at gcc dot gnu dot org


--- Comment #20 from rguenth at gcc dot gnu dot org  2010-04-30 18:53 
---
Subject: Bug 43879

Author: rguenth
Date: Fri Apr 30 18:52:44 2010
New Revision: 158945

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=158945
Log:
2010-04-30  Richard Guenther  rguent...@suse.de

PR tree-optimization/43879
* tree-ssa-structalias.c (type_could_have_pointers): Functions
can have pointers.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-ssa-structalias.c


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-29 Thread rguenth at gcc dot gnu dot org


--- Comment #9 from rguenth at gcc dot gnu dot org  2010-04-29 15:29 ---
Wow, thanks for the testcase!


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-29 Thread rguenth at gcc dot gnu dot org


--- Comment #10 from rguenth at gcc dot gnu dot org  2010-04-29 15:37 
---
And the bug is:

struct TBL tbl = { foo };

but:

Generating constraints for global initializers

...
tbl = NONLOCAL
tbl = NULL

ouch.  I have a patch.


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-28 Thread rguenth at gcc dot gnu dot org


--- Comment #5 from rguenth at gcc dot gnu dot org  2010-04-28 11:51 ---
Subject: Bug 43879

Author: rguenth
Date: Wed Apr 28 11:51:31 2010
New Revision: 158825

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=158825
Log:
2010-04-28  Richard Guenther  rguent...@suse.de

PR tree-optimization/43879
PR tree-optimization/43909
* tree-ssa-structalias.c (struct variable_info): Add
only_restrict_pointers flag.
(new_var_info): Initialize it.  Increment stats.total_vars here.
(create_function_info_for): Do not increment stats.total_vars
here.
(get_function_part_constraint): Fix build with C++.
(insert_into_field_list): Remove.
(push_fields_onto_fieldstack): Properly merge fields.
(create_variable_info_for): Split and simplify.
(create_variable_info_for_1): New piece.
(intra_create_variable_infos): Properly make restrict constraints
from parameters.

* gcc.dg/ipa/ipa-pta-14.c: Adjust.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c
trunk/gcc/tree-ssa-structalias.c


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-28 Thread rguenth at gcc dot gnu dot org


--- Comment #6 from rguenth at gcc dot gnu dot org  2010-04-28 12:53 ---
Real miscompiles prevailing:

=== libstdc++ tests ===


Running target unix/-fipa-pta/
FAIL: 20_util/shared_ptr/thread/default_weaktoshared.cc execution test
FAIL: 23_containers/bitset/cons/1.cc execution test
FAIL: 23_containers/bitset/operations/1.cc execution test
FAIL: 23_containers/bitset/to_ullong/1.cc execution test
WARNING: program timed out.
WARNING: program timed out.
FAIL: tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc
executio
n test


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-28 Thread zsojka at seznam dot cz


--- Comment #7 from zsojka at seznam dot cz  2010-04-28 15:09 ---
Created an attachment (id=20507)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20507action=view)
first part of reduced testcase

second part to follow


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-28 Thread zsojka at seznam dot cz


--- Comment #8 from zsojka at seznam dot cz  2010-04-28 15:12 ---
Created an attachment (id=20508)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20508action=view)
second part of reduced testcase

These testcases demonstrate what happens in cfgrtl.c, why is
cfg_layout_merge_blocks miscompiled:
((a)-il.rtl-end_)-code is expected not to change during call to
try_redirect_by_replacing_jump()

Command line to demonstrate:
$ gcc -O[123s] -fipa-pta pr43879.c pr43879-2.c  ./a.out
Aborted


-- 


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-24 Thread rguenth at gcc dot gnu dot org


--- Comment #3 from rguenth at gcc dot gnu dot org  2010-04-24 18:55 ---
Well, -fipa-pta is no longer a no-op and I wouldn't call the existing (known)
bugs a regression.  I have some pending patches to fix issues.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
   |dot org |org
 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2010-04-24 18:55:15
   date||
Summary|[4.6 Regression] -fipa-pta  |-fipa-pta causes various
   |causes various  |miscompilations
   |miscompilations |


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



[Bug tree-optimization/43879] -fipa-pta causes various miscompilations

2010-04-24 Thread rguenth at gcc dot gnu dot org


--- Comment #4 from rguenth at gcc dot gnu dot org  2010-04-24 20:04 ---
(In reply to comment #2)
 Bootstrap fails too with -fipa-pta, (at least) cfgrtl.o is miscompiled.

Yep, I know.  If you can isolate the miscompile that would be great
(I am concentrating on completing IPA PTA as time permits).


-- 


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