From 9605d81c7c2fd3de0c07500a7f8a141eed89defc Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 2 Aug 2005 14:04:19 +0000 Subject: [PATCH] [project @ 2005-08-02 14:04:19 by simonmar] save + restore caller-saves registers around foreign calls --- ghc/compiler/nativeGen/AsmCodeGen.lhs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/nativeGen/AsmCodeGen.lhs b/ghc/compiler/nativeGen/AsmCodeGen.lhs index 831accf..93b385f 100644 --- a/ghc/compiler/nativeGen/AsmCodeGen.lhs +++ b/ghc/compiler/nativeGen/AsmCodeGen.lhs @@ -346,8 +346,14 @@ fixAssign (CmmAssign (CmmGlobal reg) src) fixAssign (CmmCall target results args vols) = mapAndUnzipUs fixResult results `thenUs` \ (results',stores) -> - returnUs (CmmCall target results' args vols : concat stores) + returnUs (caller_save ++ + CmmCall target results' args vols : + caller_restore ++ + concat stores) where + -- we also save/restore any caller-saves STG registers here + (caller_save, caller_restore) = callerSaveVolatileRegs vols + fixResult g@(CmmGlobal reg,hint) = case get_GlobalReg_reg_or_addr reg of Left realreg -> returnUs (g, []) -- 1.7.10.4