Bug 29248 - Stack pointer is modified in functions that don't use the stack
Summary: Stack pointer is modified in functions that don't use the stack
Status: RESOLVED DUPLICATE of bug 28966
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2006-09-27 03:19 UTC by Aaron Graham
Modified: 2006-12-18 18:36 UTC (History)
4 users (show)

See Also:
Host: i686-redhat-linux
Target: powerpc-wrs-vxworks
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-27 05:14:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Graham 2006-09-27 03:19:32 UTC
Consider the following two functions:

int foo() { return 1; }
void bar() {}

Disassembly when compiled with gcc 2.95.2: (-Os)
  00000000 <foo(void)>:
     0:   38 60 00 01     li      r3,1
     4:   4e 80 00 20     blr
  00000008 <bar(void)>:
     8:   4e 80 00 20     blr

Disassembly when compiled with gcc 4.1.1: (-Os)
  00000000 <foo()>:
     0:   94 21 ff f0     stwu    r1,-16(r1)
     4:   38 60 00 01     li      r3,1
     8:   38 21 00 10     addi    r1,r1,16
     c:   4e 80 00 20     blr
  00000010 <bar()>:
    10:   94 21 ff f0     stwu    r1,-16(r1)
    14:   38 21 00 10     addi    r1,r1,16
    18:   4e 80 00 20     blr
Comment 1 Andrew Pinski 2006-09-27 03:26:47 UTC
How did you configure 4.1.1?
I bet this is really a dup of bug 28966.
Comment 2 Andrew Pinski 2006-09-27 03:59:24 UTC
This works for me on the mainline:
[pinskia@celery gcc]$ ./cc1 -m32 -Os t.c -o - -quiet
        .file   "t.c"
        .section        ".text"
        .align 2
        .globl foo
        .type   foo, @function
foo:
        li 3,1
        blr
        .size   foo,.-foo
        .align 2
        .globl bar
        .type   bar, @function
bar:
        blr
        .size   bar,.-bar
        .ident  "GCC: (GNU) 4.2.0 20060909 (experimental)"
        .section        .note.GNU-stack,"",@progbits




Are you sure you did not add -maltivec somewhere or --with-cpu=970 ?
Comment 3 Aaron Graham 2006-09-27 04:28:04 UTC
Ack!  Sorry--I had indicated the wrong target on that one.  The target is vxworks, not linux.  My 4.1.1 powerpc-linux compiler *does* get this optimization right.  So something in the vxworks-specific code is causing this:

/opt/vxppc/libexec/gcc/powerpc-wrs-vxworks/4.1.1> ./cc1 -m32 -Os ~/foo.c -o - -quiet
        .file   "foo.c"
        .section        ".text"
        .align 2
        .globl foo
        .type   foo, @function
foo:
        stwu 1,-16(1)
        li 3,1
        addi 1,1,16
        blr
        .size   foo, .-foo
        .align 2
        .globl bar
        .type   bar, @function
bar:
        stwu 1,-16(1)
        addi 1,1,16
        blr
        .size   bar, .-bar
        .ident  "GCC: (GNU) 4.1.1"

In my opinion, this is a very low priority problem, despite that this is one of my primary development environments.  Sorry for wasting your time with the wrong target.
Comment 4 Andrew Pinski 2006-09-27 04:42:00 UTC
Can you give the output of gcc -v for powerpc-wrs-vxworks?  I bet vxworks enables altivec by default which means it is a dup still.
Comment 5 Andrew Pinski 2006-09-27 05:14:43 UTC
#define STACK_BOUNDARY (16*BITS_PER_UNIT)

This is a target issue.
Comment 6 Nathan Sidwell 2006-12-18 18:36:38 UTC
this is really a duplicate of 28966.  Like vxworks has an unconditional 128 bit stack alignment, unlike other targets where it is only 128bit when altivec comes into play.

*** This bug has been marked as a duplicate of 28966 ***
Comment 7 Pat Haugen 2007-10-31 19:48:47 UTC
Subject: Bug 29248

Author: pthaugen
Date: Wed Oct 31 19:48:19 2007
New Revision: 129806

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129806
Log:
2007-10-01  Pat Haugen  <pthaugen@us.ibm.com>

	Backport the following patches:

	2007-09-04  Daniel Jacobowitz  <dan@codesourcery.com>

	* config/rs6000/rs6000.c (rs6000_stack_info): Allocate space for the
	GOT pointer only if there is a constant pool.  Use the allocated space
	for SPE also.

	2006-12-21  Nathan Sidwell  <nathan@codesourcery.com>

	PR target/28966
	PR target/29248
	* reload1.c (reload): Realign stack after it changes size.


Modified:
    branches/ibm/gcc-4_1-branch/gcc/ChangeLog
    branches/ibm/gcc-4_1-branch/gcc/config/rs6000/rs6000.c
    branches/ibm/gcc-4_1-branch/gcc/reload1.c