[project @ 2002-05-29 13:44:18 by simonmar]
authorsimonmar <unknown>
Wed, 29 May 2002 13:44:18 +0000 (13:44 +0000)
committersimonmar <unknown>
Wed, 29 May 2002 13:44:18 +0000 (13:44 +0000)
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

index 96e9858..9be5c67 100644 (file)
@@ -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
            }
        }