<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 31, 2017 at 11:43 AM, Connor Gray via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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.</blockquote><div><br></div><div>The intrinsic call won't be lowered into calls, but into counter update inline sequence.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I’d like to be able to do this programmatically instead, and avoid calling an external process.<br></blockquote><div><br></div><div>Looks like you want to implement the instrumentation lowering.  Why do you want to do that? Can you just invoke the InstrProfiling (lowering) pass?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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.<br>
<br>
Is this even possible to do cleanly, or are the implementations closely tied to opt/clang?<br>
<br>
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.<br></blockquote><div><br></div><div>You should look at Transforms/Instrumentation/InstrProfiling.cpp.  The file named InstrProf.cpp under ProfileData dir defines common APIs for instr-gen, lowering, and profile reading/writing. </div><div><br></div><div>David</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Thanks in advance,<br>
Connor<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div></div>