Add dead code elimination (DCE) pass

This should make it much easier (in the future) to use the standard
library when unused functions contain unimplemented features. But more
importantly, it makes later passes better and makes compiling faster by
not having to scan dead code.
This commit is contained in:
Ayke van Laethem
2018-08-19 20:44:55 +02:00
parent fae4c7f555
commit 7460e10894
3 changed files with 89 additions and 0 deletions
+1
View File
@@ -205,6 +205,7 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
for _, pkg := range packageList {
c.ir.AddPackage(pkg)
}
c.ir.SimpleDCE() // remove most dead code
c.ir.AnalyseCallgraph() // set up callgraph
c.ir.AnalyseInterfaceConversions() // determine which types are converted to an interface
c.ir.AnalyseBlockingRecursive() // make all parents of blocking calls blocking (transitively)