From 9c5838466769fb9d5fd2cc4cc677852fd798af03 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 25 Mar 2011 16:12:34 +0000 Subject: [PATCH] Fix #4914 (I hope) Here's a bit of erroneous code: 00000c5c : c5c: 8b 45 08 mov 0x8(%ebp),%eax c5f: d9 46 03 flds 0x3(%esi) c62: dd d9 fstp %st(1) c64: d9 55 08 fsts 0x8(%ebp) c67: 89 c6 mov %eax,%esi c69: c7 45 00 24 0c 00 00 movl $0xc24,0x0(%ebp) c70: f7 c6 03 00 00 00 test $0x3,%esi c76: 75 ac jne c24 So we should be doing some ffrees before the jne. The code that inserts the ffrees wasn't expecting to do it for a conditional jump, because they are usually local, but we have a late optimisation that shortcuts jumps-to-jumps, and that can result in a non-local conditional jump. This at least fixes an instance of the bug that I was able to reproduce, let's hope there aren't any more. --- compiler/nativeGen/X86/Instr.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/nativeGen/X86/Instr.hs b/compiler/nativeGen/X86/Instr.hs index 28b7997..d05b08a 100644 --- a/compiler/nativeGen/X86/Instr.hs +++ b/compiler/nativeGen/X86/Instr.hs @@ -735,6 +735,7 @@ i386_insert_ffrees blocks where p insn r = case insn of CALL _ _ -> GFREE : insn : r JMP _ -> GFREE : insn : r + JXX_GBL _ _ -> GFREE : insn : r _ -> insn : r -- if you ever add a new FP insn to the fake x86 FP insn set, -- 1.7.10.4