Lazification of Function Arguments

Hi LLVMers,

We have implemented a compiler optimization onto LLVM 14.0 that replaces strict with lazy evaluation of function parameters whenever such modification is deemed profitable. We call this transformation “Lazification”. The optimization involves a static analysis to identify function calls that are candidates for lazification, plus a code extraction technique that generates closures to be lazily activated. Code extraction uses an adaptation of the classic program slicing technique adapted for the static single assignment (SSA) representation that LLVM uses.

If lazification is guided by profiling information, then it can sometimes deliver speedups on benchmarks compiled with clang -O3. We saw a speedup of 11.1% on Prolang’s Bison and a speedup of 4.6% on SPEC CPU2017’s perlbench. We saw regressions too: there is still much to be tested and improved in our implementation of lazification.

For those interested, the code is here:

To know more about the transformation, we have a technical report here:

In case there is anyone else interested, it will be nice to talk about the implementation. There are lots and lots of heuristics that we are still considering trying!



1 Like