I have implemented indirect call value profiling in LDC, using Clang’s code for inspiration, and it appears to work great. An often recurring indirect call is nicely promoted to a comparison and a direct call (I am using a modified LLVM with the indirect call promotion pass added).
However, I am wondering if I can go one step further: instead of indexing into a vtable and doing the comparison on the function address, profile the vtable pointer and do the comparison on the vtable pointer.
Does LLVM have support for this already, or do I have to code this myself?
Or perhaps I am dreaming and this doesn’t make sense?