[llvm-dev] PGO — opt -instrprof pass programatically?

Connor Gray via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 31 11:43:44 PDT 2017


Hi,

I’m working to add PGO to the IR I’m producing. Currently I’m using opt -instrprof to expand the llvm.instrprof_increment calls into runtime calls. I’d like to be able to do this programmatically instead, and avoid calling an external process.

I gather from what I’ve read online that this is implemented inside of opt and clang using the InstrProf pass, but, frustratingly, I haven’t been able to track down how or where it’s invoked, or even defined. I’m aware of a large amount of the logic in InstrProf.cpp, but that doesn’t have a clear entry point. What I’ve read online always makes use of opt or clang, but does not show how to run this pass programatically. 

Is this even possible to do cleanly, or are the implementations closely tied to opt/clang?

If somebody knows of any tutorials or examples of this they could share, that would be very helpful. Otherwise, direction towards the important locations in source would be useful.


Thanks in advance,
Connor


More information about the llvm-dev mailing list