@@ -222,10 +222,9 @@ instance ToIR (TT Name) where
223 | (P (DCon t a) n _, args) <- unApply tm = do
223 | (P (DCon t a) n _, args) <- unApply tm = do
224 cg <- idris_callgraph <$> getIState
224 cg <- idris_callgraph <$> getIState
225− case lookupCtxtExact n cg of
225+ let used = maybe [] (map fst . usedpos) $ lookupCtxtExact n cg
226− Just (CGInfo _ _ _ _ usedpos)
227− -> irCon env t a n [if i `elem` map fst usedpos then a else Erased | (i,a) <- zip [0..] args]
226+ args' = [if i `elem` used then a else Erased | (i,a) <- zip [0..] args]
228− Nothing -> return LNothing -- no usage info -> not used at all
227+ irCon env t a n args'
230 | (P (TCon t a) n _, args) <- unApply tm
229 | (P (TCon t a) n _, args) <- unApply tm
231 = return LNothing
230 = return LNothing
@@ -238,14 +237,19 @@ instance ToIR (TT Name) where
238 Just (arity, op) | length args == arity
237 Just (arity, op) | length args == arity
239 -> LOp op <$> mapM (ir' env) args
238 -> LOp op <$> mapM (ir' env) args
240+ _ -> applyName n ist args
242+{- collapsibility is turned off for now
242 -- if it's collapsible, compile to LNothing
244 -- if it's collapsible, compile to LNothing
243 | (collapsible <$> lookupCtxtExact n (idris_optimisation ist)) == Just True
245 | (collapsible <$> lookupCtxtExact n (idris_optimisation ist)) == Just True
244 -> return LNothing
246 -> return LNothing
246 -- otherwise, compile normally
248 -- otherwise, compile normally
247 | otherwise -> applyName n ist args
249 | otherwise -> applyName n ist args
249 | (f, args) <- unApply tm
253 | (f, args) <- unApply tm
250 = do f' <- ir' env f
254 = do f' <- ir' env f
251 args' <- mapM (ir' env) args
255 args' <- mapM (ir' env) args
@@ -266,7 +270,7 @@ instance ToIR (TT Name) where
266 [Operator ty ar op] -> ar
270 [Operator ty ar op] -> ar
269− used = fromMaybe [] (map fst . usedpos <$> lookupCtxtExact n (idris_callgraph ist))
273+ used = maybe [] (map fst . usedpos) $ lookupCtxtExact n (idris_callgraph ist)
270 fst4 (x,_,_,_) = x
274 fst4 (x,_,_,_) = x
272-- ir' env (P _ (NS (UN "Z") ["Nat", "Prelude"]) _)
276-- ir' env (P _ (NS (UN "Z") ["Nat", "Prelude"]) _)