This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11753] New: %o7 register being used immediately in the delay slot before a call with -O2
- From: "warren_baird at cimmetry dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jul 2003 18:51:39 -0000
- Subject: [Bug optimization/11753] New: %o7 register being used immediately in the delay slot before a call with -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11753
Summary: %o7 register being used immediately in the delay slot
before a call with -O2
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: warren_baird at cimmetry dot com
CC: gcc-bugs at gcc dot gnu dot org
gcc -v output:
Reading specs from /usr/local/gcc-3.2.2/lib/gcc-lib/sparc-sun-solaris2.8/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --prefix=/usr/local/gcc-3.2.2
--with-gnu-as --with-gnu-ld --with-gnu-nm
--with-as=/usr/local/binutils-2.13.2.1/bin/as
--with-ld=/usr/local/binutils-2.13.2.1/bin/ld
--with-nm=/usr/local/binutils-2.13.2.1/bin/nm
Thread model: posix
gcc version 3.2.2
if you compile the attached .i file with -O2 optimization:
gcc -c -O2 -S bug_o7.i
And you look around line 414 of the bug_o7.s file you should see code
like this:
mov 1, %i0
call free, 0
add %o7, (.LL1-.-4), %o7
The problem here is that on a sparc system register %o7 is used to
pass the return address to a function, and since we're modifying it in
the delay slot, %o7 is modified just before the call to free, and when
free tries to return it jumps back to a different piece of code and
crashes almost immediately.
If I compile with -O1 it doesn't generate this construct. Also, if I
try to remove almost any code from the function it doesn't generate
this construct. It looks to me like it is only under fairly rare
circumstances that the optimizer produces this particular error.