summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/X86/RegInfo.hs
diff options
context:
space:
mode:
authordias@eecs.harvard.edu <unknown>2009-03-03 15:02:28 +0000
committerdias@eecs.harvard.edu <unknown>2009-03-03 15:02:28 +0000
commit31a9d04804d9cacda35695c5397590516b964964 (patch)
tree1253be42d69db8ab7a6d104e2eda8d03a44a9be2 /compiler/nativeGen/X86/RegInfo.hs
parent6d38e24ea3da7ca9b435e9b1e59b2de8fcd91da4 (diff)
downloadhaskell-31a9d04804d9cacda35695c5397590516b964964.tar.gz
A few bug fixes; some improvements spurred by paper writing
Among others: - Fixed Stg->C-- translation of let-no-escapes -- it's important to use the right continuation... - Fixed infinite recursion in X86 backend (shortcutJump mishandled infinite loops) - Fixed yet another wrong calling convention -- primops take args only in vanilla regs, but they may return results on the stack! - Removed StackInfo from LGraph and Block -- now in LastCall and CmmZ - Updated avail-variable and liveness code
Diffstat (limited to 'compiler/nativeGen/X86/RegInfo.hs')
-rw-r--r--compiler/nativeGen/X86/RegInfo.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/nativeGen/X86/RegInfo.hs b/compiler/nativeGen/X86/RegInfo.hs
index a3bf8e4655..39ff4063b0 100644
--- a/compiler/nativeGen/X86/RegInfo.hs
+++ b/compiler/nativeGen/X86/RegInfo.hs
@@ -51,14 +51,17 @@ canShortcut (JMP (OpImm imm)) = Just (DestImm imm)
canShortcut _ = Nothing
+-- The helper ensures that we don't follow cycles.
shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
-shortcutJump fn insn@(JXX cc id) =
- case fn id of
- Nothing -> insn
- Just (DestBlockId id') -> shortcutJump fn (JXX cc id')
- Just (DestImm imm) -> shortcutJump fn (JXX_GBL cc imm)
-
-shortcutJump _ other = other
+shortcutJump fn insn = shortcutJump' fn emptyBlockSet insn
+ where shortcutJump' fn seen insn@(JXX cc id) =
+ if elemBlockSet id seen then insn
+ else case fn id of
+ Nothing -> insn
+ Just (DestBlockId id') -> shortcutJump' fn seen' (JXX cc id')
+ Just (DestImm imm) -> shortcutJump' fn seen' (JXX_GBL cc imm)
+ where seen' = extendBlockSet seen id
+ shortcutJump' _ _ other = other
-- Here because it knows about JumpDest