From 25dac32a88eb8260ed4ceeb0c4b32c888c1896c7 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 5 Apr 2021 23:45:36 +0200 Subject: [PATCH] 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. --- transform/optimizer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transform/optimizer.go b/transform/optimizer.go index 051f929c..cf570a2d 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)