Register Allocator Bug

Simon Marlow simonmar at microsoft.com
Mon Jan 17 07:03:20 EST 2005


On 16 January 2005 05:37, Wolfgang Thaller wrote:

> On x86-linux, with the latest HEAD, the following code triggers a
> register allocation bug:
> 
> #include "Cmm.h"
> foo {
> 	I32 bar;				// bar get's assigned to
%eax
> 	foreign "C" bar ();	// %eax is correctly saved accross this
call
> 	foreign "C" bar ();	// But this call clobbers it.
> 	jump bar;				// here we'll probably
crash.
> }

I think you have a missing 'bar = R1;' here, after the declaration of
bar.

> This gets compiled to:
> 
> .text
> 	.align 4,0x90
> .globl foo
> foo:
> 	movl %esi,%eax
> 	movl %eax,64(%esp)
> 	call *%eax
> 	addl $0,%esp
> 	movl 64(%esp),%eax
> 	call *%eax
> 	addl $0,%esp
> 	jmp *%eax

Thanks, fix committed.

Cheers,
	Simon


More information about the Cvs-ghc mailing list