[project @ 2002-05-29 13:44:18 by simonmar]
[ghc-hetmet.git] / 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
            }
        }