From: Matthijs Kooijman Date: Wed, 19 Aug 2009 10:32:00 +0000 (+0200) Subject: Don't try to inline non-normalizeable top level functions. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=537f5cc89c2a2581b0d7023320e1ade723a01759;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git 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. --- 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)