Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/4c53d93a7690b89b44f6d52380de867527800924

>---------------------------------------------------------------

commit 4c53d93a7690b89b44f6d52380de867527800924
Author: Edward Z. Yang <[email protected]>
Date:   Fri Feb 18 01:17:45 2011 +0000

    New codegen: GC calling convention must use registers.
    
    Previously, on register-deficient architectures like x86-32,
    the new code generator would emit code for calls to stg_gc_l1,
    stg_gc_d1 and stg_gc_f1 that pushed their single argument on
    to the stack, while the functions themselves expected the
    argument to live in L1, D1 and F1 (respectively).  This was
    because cmmCall with the GC calling convention allocated real
    registers, not virtual registers.
    
    This patch modifies the code for assigning registers/stack slots
    to use the right calling convention for GC and adds an assertion
    to ensure it did it properly.

>---------------------------------------------------------------

 compiler/cmm/CmmCallConv.hs |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/compiler/cmm/CmmCallConv.hs b/compiler/cmm/CmmCallConv.hs
index 24adb99..e7d0acc 100644
--- a/compiler/cmm/CmmCallConv.hs
+++ b/compiler/cmm/CmmCallConv.hs
@@ -47,7 +47,8 @@ assignArgumentsPos conv arg_ty reps = assignments
                (_,   NativeDirectCall) -> getRegsWithoutNode
                ([_], NativeReturn)     -> allRegs
                (_,   NativeReturn)     -> getRegsWithNode
-               (_,   GC)               -> getRegsWithNode
+               -- GC calling convention *must* put values in registers
+               (_,   GC)               -> allRegs
                (_,   PrimOpCall)       -> allRegs
                ([_], PrimOpReturn)     -> allRegs
                (_,   PrimOpReturn)     -> getRegsWithNode
@@ -61,6 +62,7 @@ assignArgumentsPos conv arg_ty reps = assignments
       (reg_assts, stk_args) = assign_regs [] reps regs
       stk_args' = case conv of NativeReturn -> part
                                PrimOpReturn -> part
+                               GC | length stk_args /= 0 -> panic "Failed to 
allocate registers for GC call"
                                _            -> stk_args
                   where part = uncurry (++)
                                        (L.partition (not . isGcPtrType . 
arg_ty) stk_args)



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to