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.
This commit is contained in:
Ayke van Laethem
2021-04-05 23:45:36 +02:00
committed by Ron Evans
parent 56cf69a66b
commit 25dac32a88
+1 -1
View File
@@ -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)