Bug 47286 - Invalid code when using register ... asm
Summary: Invalid code when using register ... asm
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.5.3
Assignee: Richard Biener
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-01-13 23:48 UTC by Anton Blanchard
Modified: 2011-01-17 11:33 UTC (History)
0 users

See Also:
Host:
Target: powerpc64-unknown-linux-gnu
Build:
Known to work: 4.5.3, 4.6.0
Known to fail: 4.5.2
Last reconfirmed: 2011-01-14 10:34:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Blanchard 2011-01-13 23:48:20 UTC
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
Comment 1 Richard Biener 2011-01-14 10:34:35 UTC
Confirmed.  points-to analysis computes sp as pointing to nothing.
Comment 2 Richard Biener 2011-01-14 10:59:46 UTC
The fundamental problem is present on all branches, we are lucky in 4.4 and
earlier though.
Comment 3 Richard Biener 2011-01-14 12:15:48 UTC
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
Comment 4 Richard Biener 2011-01-17 11:31:15 UTC
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
Comment 5 Richard Biener 2011-01-17 11:33:48 UTC
Fixed.