A gcc build from yesterday (4.6.0 20110113) fails when building a ppc64 Linux kernel. A cut down testcase: struct thread_info { int preempt_count; }; static inline struct thread_info *current_thread_info(void) { register struct thread_info *sp asm("r1"); return sp; } void testcase(void) { current_thread_info()->preempt_count += 1; } compiled with -O2: # gcc -O2 -S testcase.s has the add optimised away: .L.testcase: blr
Confirmed. points-to analysis computes sp as pointing to nothing.
The fundamental problem is present on all branches, we are lucky in 4.4 and earlier though.
Author: rguenth Date: Fri Jan 14 12:15:43 2011 New Revision: 168779 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168779 Log: 2011-01-14 Richard Guenther <rguenther@suse.de> PR tree-optimization/47286 * tree-ssa-structalias.c (new_var_info): Register variables are global. * gcc.dg/tree-ssa/pr47286.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr47286.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-structalias.c
Author: rguenth Date: Mon Jan 17 11:31:10 2011 New Revision: 168894 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168894 Log: 2011-01-17 Richard Guenther <rguenther@suse.de> Backport from mainline PR tree-optimization/47286 * tree-ssa-structalias.c (new_var_info): Register variables are global. * gcc.dg/tree-ssa/pr47286.c: New testcase. PR tree-optimization/44592 * tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Copy from trunk. * gfortran.dg/pr44592.f90: New testcase. Added: branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/tree-ssa/pr47286.c branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/pr44592.f90 Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/testsuite/ChangeLog branches/gcc-4_5-branch/gcc/tree-ssa-ccp.c branches/gcc-4_5-branch/gcc/tree-ssa-structalias.c
Fixed.