To this day, we still do too little when it comes to optimizing well
known library calls.
Given that various libraries, especially the C/C++ standard library, are
relatively clear defined, and LLVM has all the infrastructure already in
place, e.g., SimplifyLibCalls.cpp, it seems odd that we still miss so
many optimization opportunities.
To show how easy it is, and how much impact it can have, I crafted a
very simple, yet very effective patch which will hopefully only be the
first of its kind.
The attached twelve line addition to SimplifyLibCalls.cpp provides
subsequent passes with a better understanding of the "getenv" function.
This function was chosen to showcase the enormous impact well placed
information can have on real world software, including LLVM itself.
While you could take my word for it, I would encourage you to try it out
yourself. Apply the patch and create *a new build* of LLVM to compare
against your existing one. I firmly believe the result will be rather
surprising for most.
With a bit of luck we may even see more patches like this one today.
Even if you are all too busy today, there is always next year I guess.
Thanks in advance,
0001-LibCalls-Improve-optimizations-for-getenv-library-ca.patch (1.64 KB)