• simonpj@microsoft.com's avatar
    Add -fspec-inline-join-points to SpecConstr · 44d4bf2c
    simonpj@microsoft.com authored
    This patch addresses a problem that Roman found in SpecConstr.  Consider:
    foo :: Maybe Int -> Maybe Int -> Int
    foo a b = let j b = foo a b
               case b of
                 Nothing -> ...
                 Just n  -> case a of
                              Just m  -> ... j (Just (n+1)) ...
                              Nothing -> ... j (Just (n-1)) ...
    We want to make specialised versions for 'foo' for the patterns
    	Nothing  (Just v)
    	(Just a) (Just b)
    Two problems, caused by the join point j.  First, j does not
    scrutinise b, so j won't be specialised f for the (Just v) pattern.
    Second, j is defined where the free var 'a' is not evaluated.
    Both are solved by brutally inlining j at its call sites.  This risks
    major code bloat, but it's relatively quick to implement.  The flag
    causes brutal inlining for a 
    	non-recursive binding
    	of a function
    	whose RHS contains calls
    	of a recursive function
    The (experimental) flag is static for now, and I have not even
    documented it properly.
StaticFlags.hs 19.9 KB