This is another code cleanup suggested by Sean Silva in review of http://reviews.llvm.org/D17864.
It uses a helper function to find all the direct-calls-sites in a function. This makes the caller cleaner.
I also split the code into a separated file as this will be shared by another source file for indirect-call-promotion transformation (D17864).
Thanks,
-Rong
Nit: I think we usually say static inline.