About Implementation of Pettis-Hansen's / Gloy's Code Layout Transformation in LLVM

Hi;

I was planning to implement a profile guided optimization technique in LLVM. In the open source projects list of the LLVM site; I saw “code layout” is a transformation that can be worth looking at as it will use of profiles (possibly path profiles).

So I was thinking of implementing either Pettis-Hansen’s (Profile guided code positioning, Pettis & Hansen) or Gloy’s (Procedure Placement Using Temporal-Ordering Information, Gloy, Smith) procedure placement algorithm in LLVM because first of all I have not seen any implementation of it in LLVM till** and second, these are the classic procedure placement algorithms.

So I would like to get some advice from the seniors -

  1. Has there been any attempt to implement these before that I don’t know about. And what was the success/ failure of that implementation?

  2. Gloy’s algorithm aims at reducing the I-Cache misses. But how wise would it be to aim at that to optimize performance while the LLVM already does something to reduce I-Cache misses? To rephrase my question, is there really any scope of improvement for I-Cache misses? (I know the answer depends on the kind of application we are trying to compile, but let’s say we are using applications which can have a large number of I-Cache conflict misses and have a large Working Set as well e.g gcc, go, postscript etc. I really don’t know how well LLVM handles I-Cache misses for these programs. I mentioned them because these are the benchmarks Gloy used to measure performance of his transformation and they have interesting instruction memory behaviour )

  3. Is this a good idea in terms of the complexity of implementing it? (To be frank, I will be doing this work for my Master’s thesis and I have just more than a year in my hand)

Any comment on my idea (whether it is stupid / wise / can’t tell without actually implementing it) would be appreciated. Also any pointers to how I-Cache misses are handled (reduced) by LLVM will be good.

Thank you for your help;

** - I have seen that there is already PH’s Basic Block Placement transformation is implemented in LLVM but not Code Layout.