From 537f5cc89c2a2581b0d7023320e1ade723a01759 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 19 Aug 2009 12:32:00 +0200 Subject: [PATCH] Don't try to inline non-normalizeable top level functions. Since we do normalization before inlining, we should only try this with functions that can be normalized. --- "c\316\273ash/CLasH/Normalize.hs" | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 38ee353..1f5ee42 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -324,10 +324,11 @@ inlinetoplevel, inlinetopleveltop :: Transform -- Any system name is candidate for inlining. Never inline user-defined -- functions, to preserver structure. inlinetoplevel expr@(Var f) | not $ isUserDefined f = do + norm <- isNormalizeable f -- See if this is a top level binding for which we have a body body_maybe <- Trans.lift $ getGlobalBind f - case body_maybe of - Just body -> do + if norm && Maybe.isJust body_maybe + then do -- Get the normalized version norm <- Trans.lift $ getNormalized f if needsInline norm @@ -335,9 +336,9 @@ inlinetoplevel expr@(Var f) | not $ isUserDefined f = do change norm else return expr - -- No body, this is probably a local variable or builtin or external - -- function. - Nothing -> return expr + else + -- No body or not normalizeable. + return expr -- Leave all other expressions unchanged inlinetoplevel expr = return expr inlinetopleveltop = everywhere ("inlinetoplevel", inlinetoplevel) -- 2.30.2