Closed mrkgnao closed 6 years ago
My guess is that this is where the magic happens:
performTransforms :: Program -> Program
performTransforms =
Annotate.runPass . TCO.runPass . DCE.runPass . Renamer.runPass
Do you have an example where DCE makes at least one line of a difference?
I think every program - even a simple main = pure ()
-- has tons of dead code that DCE eliminates. In particular, if you disable the DCE pass and try compiling that program, you will find lots of *peek*
functions (byte-level operations, I think) that DCE removes otherwise.
Edit: you're right that that's where you need to look.
Hi, I've implemented something, you can find in my fork.
We might consider adding some specialized arguments parsing library, but maybe the project is still too young.
I'm pretty confident the DCE on github/master is not doing much to the output. Or I am missing something obvious. :) with all optimisation in place without DCE
Idea
The
idris
executable can pass arguments to code generators likeidris-codegen-vim
via a flag:We can use this to enable or disable specific optimisations from the command-line. This will be useful when we work on mutual tail-call optimisation, since that will likely be buggy in the initial stages and should preferably be turned off by default.
For starters, a
--disable-dead-code-elimination
flag would be a good proof-of-concept.How
The
getOpts
function in the top-levelMain
module controls the handling of command-line arguments. We need to parse flags, send them through as additional parameters to thecodegenVim
function, which will eventually use them to choose what optimisations does.Further plans
Later, we can expand this into optimisation levels (
-O0
or-O2
etc) when we start running heavier transformations.