This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GCC bug on PowerPC with gcc 2.95.2?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: GCC bug on PowerPC with gcc 2.95.2?
- From: Cort Dougan <cort at fsmlabs dot com>
- Date: Mon, 21 May 2001 16:26:56 -0600
gcc version 2.95.2 19991024 (release)
I've tried this hosted on a Linux/x86 system targeting a Linux/PPC system
and I've done a native build on a Linux/PPC host.
I've attached the program that demonstrates the problem. The command line
was:
ppc-linux-gcc --save-temps gccbug.c
In the inline asm I change r1 but I tell gcc in the 'modifies' constraint
that I've changed it. The output asm shows that it doesn't save/restore r1
during that code, though.
This seems like a bug but may be an undocumented feature of gcc. It shows
this behavior with 2.95.2 (19991024) but I haven't tried others.
I'm including the .c, .s and .i.
#include <stdio.h>
int main(void)
{
asm (
"/* inline asm cort junk */\n\t"
"mr 1,%0\n\t"
"/* end inline asm cort junk */\n\t"
: /* output */
: /* input */ "r" (0)
: /* modifies */ "r1" );
{
/* force a use of the stack - printf */
int i = 0;
printf("i %d\n", i);
}
return 0;
}
.file "gccbug.c"
gcc2_compiled.:
.section ".rodata"
.align 2
.LC0:
.string "i %d\n"
.section ".text"
.align 2
.globl main
.type main,@function
main:
stwu 1,-32(1)
mflr 0
stw 31,28(1)
stw 0,36(1)
mr 31,1
li 0,0
/* inline asm cort junk */
mr 1,0
/* end inline asm cort junk */
li 0,0
stw 0,8(31)
lis 9,.LC0@ha
la 3,.LC0@l(9)
lwz 4,8(31)
crxor 6,6,6
bl printf
li 3,0
b .L2
.L2:
lwz 11,0(1)
lwz 0,4(11)
mtlr 0
lwz 31,-4(11)
mr 1,11
blr
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) 2.95.2 19991024 (release)"
gccbug.i.bz2