[Bug target/49211] New: MMIX: Code generation broken, when using global variables
nils@script-solution.de
gcc-bugzilla@gcc.gnu.org
Sat May 28 14:56:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49211
Summary: MMIX: Code generation broken, when using global
variables
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: nils@script-solution.de
Host: Ubuntu on x86_64
Target: MMIX
Build: gcc-4.6.0 with binutils-2.21
Created attachment 24386
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24386
Contains the object-file and the executable
I hope it is no missunderstanding, but as it seems, the code generation is
wrong when using global variables (I'm wondering because it is such a basic
thing).
For example, take the following C file:
----
struct foo {
int x,y;
};
static struct foo f;
static int x;
static void func1(int *i) {
}
static void func2(struct foo *pf) {
}
int main(void) {
int a;
f.x = 0;
f.y = 1;
x = 2;
func1(&x);
func1(&a);
func2(&f);
return 0;
}
----
I'm using the following commands to build the executable:
$ mmix-elf-escape-gcc -o test.o -c test.c
$ mmix-elf-escape-gcc -nostdlib -o test test.o
The disassembly for the main-function is:
----
0000000000000040 <main>:
40: 27fefe10 subu $254,$254,16
44: affdfe08 stou $253,$254,8
48: 23fdfe10 addu $253,$254,16
4c: fe000004 get $0,rJ
50: e3010000 setl $1,0x0
54: ab01fe00 sttu $1,$254,0
58: e3010001 setl $1,0x1
5c: ab01fe04 sttu $1,$254,4
60: e3010002 setl $1,0x2
64: ab01fe08 sttu $1,$254,8
68: 2303fe08 addu $3,$254,8
6c: f302ffe5 pushj $2,0 <_start.>
70: f6040000 put rJ,$0
74: 2701fd0c subu $1,$253,12
78: c1030100 set $3,$1
7c: f302ffe1 pushj $2,0 <_start.>
80: f6040000 put rJ,$0
84: 2303fe00 addu $3,$254,0
88: f302ffe6 pushj $2,20 <func2>
8c: f6040000 put rJ,$0
90: e3000000 setl $0,0x0
94: 8dfdfe08 ldo $253,$254,8
98: 23fefe10 addu $254,$254,16
9c: f8010000 pop 1,0
----
That means, the code expects, that f is located at $254, offset 0. But $254 is
the frame-pointer according to
http://www.bitrange.com/mmix/mmixfest-2001/mmixabi.html. The example shows a
few other usages, that are wrong for the same reason. Note that it is correct
for the local variable.
For the case that it helps, I've attached the object file and the executable.
I hope that the fix is easy. It would be really nice to know shortly how to
resolve that, because before that, I think one can't do anything useful with
gcc for MMIX :/
More information about the Gcc-bugs
mailing list