• Edward Z. Yang's avatar
    Unsafe foreign calls (fat machine instructions) do not kill all registers. · 8a0ab97b
    Edward Z. Yang authored
    
    
    The new code generator was doing some interesting spilling across
    unsafe foreign calls:
    
         _c1ao::I32 = Hp - 4;
         I32[Sp - 20] = _c1ao::I32;
         foreign "ccall"
           newCAF((BaseReg, PtrHint), (R1, PtrHint))[_unsafe_call_];
         _c1ao::I32 = I32[Sp - 20];
    
    This is fairly unnecessary, and resulted from over-conservative
    liveness analysis from CmmLive.  We can see that the old code
    generator only saved volatile registers across unsafe foreign calls:
    spilling variables was done by saveVolatileVarsAndRegs, which was
    only performed for ordinary calls.
    
    This commit removes the excess kill from the liveness analysis, as well
    as the *redundant* excess kill from spilling-and-reloading, and adds a
    note to CmmNode to this effect.  The only registers we need to kill
    are the ones that the foreign call assigns to, just like any other
    machine instruction.
    Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
    8a0ab97b
CmmSpillReload.hs 15 KB