public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nils@script-solution.de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49211] New: MMIX: Code generation broken, when using global variables Date: Sat, 28 May 2011 14:56:00 -0000 [thread overview] Message-ID: <bug-49211-4@http.gcc.gnu.org/bugzilla/> (raw) 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 :/
next reply other threads:[~2011-05-28 14:53 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-05-28 14:56 nils@script-solution.de [this message] 2011-05-28 14:57 ` [Bug target/49211] " nils@script-solution.de 2011-05-30 14:25 ` hp at gcc dot gnu.org 2011-05-30 14:30 ` hp at gcc dot gnu.org 2011-05-30 14:35 ` hp at gcc dot gnu.org 2011-05-30 14:59 ` nils@script-solution.de 2011-05-30 15:11 ` hp at gcc dot gnu.org 2011-05-30 15:30 ` nils@script-solution.de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49211-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).