[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libjit-developers] Register allocation bug
From: |
Evin Robertson |
Subject: |
[Libjit-developers] Register allocation bug |
Date: |
Sat, 30 Oct 2004 21:03:51 -0400 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040926) |
The program at the end of this email segfaults with libjit 0.0.4 using
the x86 back-end.
The problem appears to be with register allocation.
The second to last line of procedure run is miscompiled. It generates
a series of codes like:
40200206: b9 c8 23 06 08 mov $0x80623c8,%ecx
4020020b: 8b 4d e4 mov 0xffffffe4(%ebp),%ecx
4020020e: 89 09 mov %ecx,(%ecx)
It loads the address of a global into ecx, then loads the value of the
local variable into ecx as well. It attempts the write, but the
destination address has been overwritten.
I don't understand the register allocation stuff well enough to repair
the bug myself.
program tempcall;
Var a, b, c, d, e, f, g, h : Integer;
Procedure do_thing;
begin
WriteLn(a, " ", c, " ", d);
end;
Procedure run;
Var as, bs, cs, ds, es, fs, gs, hs : Integer;
begin
a := 1; b := 2; c := 3; d := 4; e := 5; f := 6; g := 7; h := 8;
do_thing;
as := a; bs := b; cs := c; ds := d; es := e; fs := f; gs := g; hs:=h;
a := 0; b := 0; c := 0; d := 0; e := 0; f := 0; g := 0; h := 0;
do_thing;
a := as; b := bs; c := cs; d := ds; e := es; f := fs; g := gs; h:=hs;
do_thing;
end;
begin
run;
end.
- [Libjit-developers] Register allocation bug,
Evin Robertson <=