Mangler problem building libraries/ with gcc 3.0.4

Simon Marlow simonmar at microsoft.com
Fri Mar 1 04:56:49 EST 2002


> Ah no, I've changed my mind.  This is problematic.  You 
> probably weren't hitting the right bit of code in your tests 
> to show up the problem.
> 
> In -monly-3-regs,  the mangler must insert code to re-load 
> the contents of %edi before doing a jump, and if the jump 
> involves %edi itself then it tries to rearrange things so 
> that it doesn't.  However in this case it couldn't find a way 
> to rearrange the code.
> 
> The solution is going to be to have a fall-through case, to 
> transform a jump involving %edi into
> 
> 	movl %edi, %eax
> 	jmp  ... %eax ...
> 
> as long as the jump doesn't also involve %eax.
> 
> Gruesome, but it should work.

Right, I've done this.  It turned out that the mangler was already doing
this, just not in a general enough way.  Gcc 3.0.4 should cause fewer
problems after the patch below.

Cheers,
	Simon

*** ghc-asm.lprl	2001/11/12 14:09:03	1.69
--- ghc-asm.lprl	2002/03/01 09:47:39	1.70
***************
*** 1304,1317 ****
  
      if ($StolenX86Regs <= 2 ) { # YURGH! spurious uses of esi?
  	s/^\tmovl\s+(.*),\s*\%esi\n\tjmp\s+\*%esi\n/\tmovl
$1,\%eax\n\tjmp \*\%eax\n/g;
! 	s/^\tjmp\s+\*(-?\d*)\((.*\%esi.*)\)\n/\tmovl $2,\%eax\n\tjmp
\*$1\(\%eax\)\n/g;
  	s/^\tjmp\s+\*\%esi\n/\tmovl \%esi,\%eax\n\tjmp \*\%eax\n/g;
  	die "$Pgm: (mangler) still have jump involving \%esi!\n$_"
  	    if /(jmp|call)\s+.*\%esi/;
      }
      if ($StolenX86Regs <= 3 ) { # spurious uses of edi?
  	s/^\tmovl\s+(.*),\s*\%edi\n\tjmp\s+\*%edi\n/\tmovl
$1,\%eax\n\tjmp \*\%eax\n/g;
! 	s/^\tjmp\s+\*(-?\d*\(.*\%edi.*\))\n/\tmovl $1,\%eax\n\tjmp
\*\%eax\n/g;
  	s/^\tjmp\s+\*\%edi\n/\tmovl \%edi,\%eax\n\tjmp \*\%eax\n/g;
  	die "$Pgm: (mangler) still have jump involving \%edi!\n$_"
  	    if /(jmp|call)\s+.*\%edi/;
--- 1304,1317 ----
  
      if ($StolenX86Regs <= 2 ) { # YURGH! spurious uses of esi?
  	s/^\tmovl\s+(.*),\s*\%esi\n\tjmp\s+\*%esi\n/\tmovl
$1,\%eax\n\tjmp \*\%eax\n/g;
! 	s/^\tjmp\s+\*(.*\(.*\%esi.*\))\n/\tmovl $1,\%eax\n\tjmp
\*\%eax\n/g;
  	s/^\tjmp\s+\*\%esi\n/\tmovl \%esi,\%eax\n\tjmp \*\%eax\n/g;
  	die "$Pgm: (mangler) still have jump involving \%esi!\n$_"
  	    if /(jmp|call)\s+.*\%esi/;
      }
      if ($StolenX86Regs <= 3 ) { # spurious uses of edi?
  	s/^\tmovl\s+(.*),\s*\%edi\n\tjmp\s+\*%edi\n/\tmovl
$1,\%eax\n\tjmp \*\%eax\n/g;
! 	s/^\tjmp\s+\*(.*\(.*\%edi.*\))\n/\tmovl $1,\%eax\n\tjmp
\*\%eax\n/g;
  	s/^\tjmp\s+\*\%edi\n/\tmovl \%edi,\%eax\n\tjmp \*\%eax\n/g;
  	die "$Pgm: (mangler) still have jump involving \%edi!\n$_"
  	    if /(jmp|call)\s+.*\%edi/;



More information about the Glasgow-haskell-bugs mailing list