GSoC 2023 Week 6 - RegAlloc Experiments

This blog post is related to my GSoC 2023 Project.

This week, I spent most of my time just analyzing code. I was digging mainly through profiles of RegAllocGreedy, and I was trying to find areas to improve. While I wasn’t able to do much in general, I was able to get one useful patch out of it: https://reviews.llvm.org/D152781.

While going through the profiles, I noticed that a fair bit of time was being spent in the function BlockFrequency::operator+=. I initially tried to see if I could optimize it, but there was not much to be done there. Then I noticed that it wasn’t being inlined, so I asked around and got to know that LLVM in general is not built using LTO. As this function is called quite a lot, such a simple thing not being inlined led to an unnecessary overhead. By moving this method into the header so that it could be inlined everywhere, a 0.1% improvement was gained.

I also tried a few other experiments, which led to no useful gains:

I also looked for a long time into RegAllocFast, however it is a very small file and very well optimized, so I couldn’t find anything to optimize in there. Similarly, FastISel also didn’t seem to have too much to optimize in it either, though I did certainly try :).