aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-04-05 23:45:36 +0200
committerRon Evans <[email protected]>2021-04-08 12:31:26 +0200
commit25dac32a88eb8260ed4ceeb0c4b32c888c1896c7 (patch)
tree2b5cd8b66330291c35902e8f27396c6065fc643d
parent56cf69a66beb337bbed6683854656a428aac7b0a (diff)
downloadtinygo-25dac32a88eb8260ed4ceeb0c4b32c888c1896c7.tar.gz
tinygo-25dac32a88eb8260ed4ceeb0c4b32c888c1896c7.zip
transform: use IPSCCP pass instead of the constant propagation pass
The constant propagation pass is removed in LLVM 12, so this pass needs to be replaced anyway. The direct replacement would be the SCCP (sparse conditional constant propagation) pass, but perhaps a better replacement is the IPSCCP pass, which is an interprocedural version of the SCCP pass and propagates constants across function calls if possible. This is not always a code size reduction, but it appears to reduce code size in a majority of cases. It certainly reduces code size in almost all WebAssembly tests I did.
-rw-r--r--transform/optimizer.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/transform/optimizer.go b/transform/optimizer.go
index 051f929cb..cf570a2d4 100644
--- a/transform/optimizer.go
+++ b/transform/optimizer.go
@@ -56,7 +56,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
defer goPasses.Dispose()
goPasses.AddGlobalDCEPass()
goPasses.AddGlobalOptimizerPass()
- goPasses.AddConstantPropagationPass()
+ goPasses.AddIPSCCPPass()
goPasses.AddAggressiveDCEPass()
goPasses.AddFunctionAttrsPass()
goPasses.Run(mod)