diff options
author | Simon Marlow <marlowsd@gmail.com> | 2012-03-02 15:41:34 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2012-03-06 13:28:27 +0000 |
commit | 9a32e71d912985a6fd8e3491518ac357f2e8686b (patch) | |
tree | d39f6fc3c2835b9749e4760a0bd3fd974e68ef6c /compiler/cmm/CmmOpt.hs | |
parent | 1ca4986cb654a9b30028eeb2d08a37dd4491cc41 (diff) | |
download | haskell-9a32e71d912985a6fd8e3491518ac357f2e8686b.tar.gz |
fixes to the mini-inliner (fixes stage2 crashes)
Diffstat (limited to 'compiler/cmm/CmmOpt.hs')
-rw-r--r-- | compiler/cmm/CmmOpt.hs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs index 105453e784..8abf54eba1 100644 --- a/compiler/cmm/CmmOpt.hs +++ b/compiler/cmm/CmmOpt.hs @@ -178,7 +178,8 @@ cmmMiniInlineStmts platform uses (stmt@(CmmAssign (CmmLocal (LocalReg u _)) expr cmmMiniInlineStmts platform uses stmts' where isTiny (CmmLit _) = True - isTiny (CmmReg _) = True + isTiny (CmmReg (CmmGlobal _)) = True + -- not CmmLocal: that might invalidate the usage analysis results isTiny _ = False foldExp (CmmMachOp op args) = cmmMachOpFold platform op args @@ -200,7 +201,7 @@ lookForInlineMany u expr stmts = lookForInlineMany' u expr regset stmts lookForInlineMany' :: Unique -> CmmExpr -> RegSet -> [CmmStmt] -> (Int, [CmmStmt]) lookForInlineMany' _ _ _ [] = (0, []) lookForInlineMany' u expr regset stmts@(stmt : rest) - | Just n <- lookupUFM (countUses stmt) u + | Just n <- lookupUFM (countUses stmt) u, okToInline expr stmt = case lookForInlineMany' u expr regset rest of (m, stmts) -> let z = n + m in z `seq` (z, inlineStmt u expr stmt : stmts) @@ -220,7 +221,7 @@ lookForInline u expr stmts = lookForInline' u expr regset stmts lookForInline' :: Unique -> CmmExpr -> RegSet -> [CmmStmt] -> Maybe [CmmStmt] lookForInline' _ _ _ [] = panic "lookForInline' []" lookForInline' u expr regset (stmt : rest) - | Just 1 <- lookupUFM (countUses stmt) u, ok_to_inline + | Just 1 <- lookupUFM (countUses stmt) u, okToInline expr stmt = Just (inlineStmt u expr stmt : rest) | okToSkip stmt u expr regset @@ -231,15 +232,15 @@ lookForInline' u expr regset (stmt : rest) | otherwise = Nothing - where - -- we don't inline into CmmCall if the expression refers to global - -- registers. This is a HACK to avoid global registers clashing with - -- C argument-passing registers, really the back-end ought to be able - -- to handle it properly, but currently neither PprC nor the NCG can - -- do it. See also CgForeignCall:load_args_into_temps. - ok_to_inline = case stmt of - CmmCall{} -> hasNoGlobalRegs expr - _ -> True + +-- we don't inline into CmmCall if the expression refers to global +-- registers. This is a HACK to avoid global registers clashing with +-- C argument-passing registers, really the back-end ought to be able +-- to handle it properly, but currently neither PprC nor the NCG can +-- do it. See also CgForeignCall:load_args_into_temps. +okToInline :: CmmExpr -> CmmStmt -> Bool +okToInline expr CmmCall{} = hasNoGlobalRegs expr +okToInline _ _ = True -- Expressions aren't side-effecting. Temporaries may or may not -- be single-assignment depending on the source (the old code |