@@ -60,7 +60,7 @@ compile codegen f tm
60 let (residDeps, (reachableNames', minUse)) = minimalUsage depMap
60 let (residDeps, (reachableNames', minUse)) = minimalUsage depMap
61 reachableNames = sUN "prim__subBigInt" : sUN "prim__addBigInt" : S.toList reachableNames'
61 reachableNames = sUN "prim__subBigInt" : sUN "prim__addBigInt" : S.toList reachableNames'
62 iLOG $ "RESIDUAL DEPS:\n" ++ unlines (map printItem . M.toList $ residDeps)
62 iLOG $ "RESIDUAL DEPS:\n" ++ unlines (map printItem . M.toList $ residDeps)
63− iLOG $ "REACHABLE NAMES: " ++ show reachableNames
63+ iLOG $ "REACHABLE NAMES:\n" ++ unlines (map show reachableNames)
65 let fmtDepMap = unlines . map (\(n,is) -> show n ++ " -> " ++ show (IS.toList is)) . M.toList
65 let fmtDepMap = unlines . map (\(n,is) -> show n ++ " -> " ++ show (IS.toList is)) . M.toList
66 iLOG $ "MINIMAL USAGE:\n" ++ fmtDepMap minUse
66 iLOG $ "MINIMAL USAGE:\n" ++ fmtDepMap minUse
@@ -276,16 +276,13 @@ instance ToIR (TT Name) where
276 Just tm -> return tm
276 Just tm -> return tm
278 let collapse
278 let collapse
279− = case lookupCtxtExact n
280− (idris_optimisation i) of
279+ = case lookupCtxtExact n (idris_optimisation i) of
281 Just oi -> collapsible oi
280 Just oi -> collapsible oi
282 _ -> False
281 _ -> False
284− = case lookupCtxtExact n
283+ = case lookupCtxtExact n (idris_callgraph i) of
285− (idris_callgraph i) of
286− Just (CGInfo _ _ _ _ usedpos) ->
284+ Just (CGInfo _ _ _ _ usedpos) -> Just usedpos
287− usedpos
285+ _ -> Nothing
288− _ -> [] -- TODO: is this correct?
289 if collapse
286 if collapse
290 then return LNothing
287 then return LNothing
@@ -296,9 +293,10 @@ instance ToIR (TT Name) where
296 = do f' <- ir' env f
293 = do f' <- ir' env f
297 args' <- mapM (ir' env) args
294 args' <- mapM (ir' env) args
298 return (LApp False f' args')
295 return (LApp False f' args')
299− where mkUsed u i [] = []
296+ where mkUsed (Just u) i [] = []
300− mkUsed u i (x : xs) | i `elem` u = x : mkUsed u (i + 1) xs
297+ mkUsed (Just u) i (x : xs) | i `elem` u = x : mkUsed (Just u) (i + 1) xs
301− | otherwise = LNothing : mkUsed u (i + 1) xs
298+ | otherwise = LNothing : mkUsed (Just u) (i + 1) xs
299+ mkUsed Nothing _ xs = xs
302-- ir' env (P _ (NS (UN "Z") ["Nat", "Prelude"]) _)
300-- ir' env (P _ (NS (UN "Z") ["Nat", "Prelude"]) _)
303-- = return $ LConst (BI 0)
301-- = return $ LConst (BI 0)
304 ir' env (P _ n _) = return $ LV (Glob n)
302 ir' env (P _ n _) = return $ LV (Glob n)