From 1f1287d7591e3cfe19a2cd5fde23175753cb91d7 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 29 May 2002 13:44:18 +0000 Subject: [PATCH] [project @ 2002-05-29 13:44:18 by simonmar] gcc 3.1 broke the mangler again... this time it seems gcc is adding spurious writes to the stack in the prologue, triggered perhaps by inline functions. The code generated for uses of ASSIGN_DBL() and ASSIGN_INT64() is really terrible - we should really submit a bug report to the gcc folks for this one. Anyway, this patch should get us going again; we now toss the spurious instructions back into the main part of the code (just in case they happened to be there for a good reason). --- ghc/driver/mangler/ghc-asm.lprl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ghc/driver/mangler/ghc-asm.lprl b/ghc/driver/mangler/ghc-asm.lprl index 96e9858..9be5c67 100644 --- a/ghc/driver/mangler/ghc-asm.lprl +++ b/ghc/driver/mangler/ghc-asm.lprl @@ -664,12 +664,26 @@ sub mangle_asm { if ( $c =~ /--- BEGIN ---/ ) { if (($p, $r) = split(/--- BEGIN ---/, $c)) { + # remove junk whitespace around the split point + $p =~ s/\t+$//; + $r =~ s/^\s*\n//; + if ($TargetPlatform =~ /^i386-/) { $p =~ s/^\tpushl\s+\%edi\n//; $p =~ s/^\tpushl\s+\%esi\n//; $p =~ s/^\tpushl\s+\%ebx\n//; $p =~ s/^\tsubl\s+\$\d+,\s*\%esp\n//; $p =~ s/^\tmovl\s+\$\d+,\s*\%eax\n\tcall\s+__alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/); + + # GCC 3.1 is in the habit of adding spurious writes to the + # stack in the prologue. Just to be on the safe side, + # chuck these over the fence into the main code. + while ($p =~ /^\tmovl\s+(\$\d+|\%edi),\s*\d*\(\%esp\)\n/) { + # print "Spurious instruction: $&"; + $p = $` . $'; + $r = $& . $r; + } + } elsif ($TargetPlatform =~ /^m68k-/) { $p =~ s/^\tlink a6,#-?\d.*\n//; $p =~ s/^\tpea a6@\n\tmovel sp,a6\n//; @@ -727,7 +741,6 @@ sub mangle_asm { # glue together what's left $c = $p . $r; - $c =~ s/\n\t\n/\n/; # junk blank line } } -- 1.7.10.4