From d1cc3c109d28a1ea46ece0a213ad3aa1e6c206ac Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 1 Jan 2020 22:42:11 +0100 Subject: [PATCH] compiler: add globaldce pass to start of optimization pipeline This reduces code size in a few cases when tested against the drivers smoketests (although there was one minor increase) without significantly increasing compile time. In fact, in my testing compile time appears to be going down a little bit (around 1%, within the noise). --- compiler/optimizer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/optimizer.go b/compiler/optimizer.go index bcdd4843..17b782e8 100644 --- a/compiler/optimizer.go +++ b/compiler/optimizer.go @@ -45,6 +45,7 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) []er // Run some preparatory passes for the Go optimizer. goPasses := llvm.NewPassManager() defer goPasses.Dispose() + goPasses.AddGlobalDCEPass() goPasses.AddGlobalOptimizerPass() goPasses.AddConstantPropagationPass() goPasses.AddAggressiveDCEPass()