<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 9, 2017 at 11:15 AM, Adam Nemet <span dir="ltr"><<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Brian,<div><br></div><div>It’s great to hear that you find the opt-viewer useful.  To your questions, specifically:</div><div><br><div><blockquote type="cite"><div>On Jun 9, 2017, at 9:02 AM, Brian Gesiak <<a href="mailto:modocache@gmail.com" target="_blank">modocache@gmail.com</a>> wrote:</div><br class="m_-4036649313619511437Apple-interchange-newline"><div><div dir="ltr">Hello!<div>(+cc Adam Nemet, since he presented on optimization remarks at LLVM Dev Mtg 2016)</div><div><br></div><div>I have a large C++ program, which I am compiling using a sampling profile generated via perf and AutoFDO. I'd like to use this profile in order to show the hotness of each code path that is displayed in the new optimization remarks viewer tool (<a href="https://www.youtube.com/watch?v=qq0q1hfzidg" target="_blank">https://www.youtube.com/<wbr>watch?v=qq0q1hfzidg</a>).</div><div><br></div><div>It seems, however, that the '-fdiagnostics-show-hotness' option emits a warning when used with '-fprofile-sample-use': "warning: argument '-fdiagnostics-show-hotness' requires profile-guided optimization information”.</div></div></div></blockquote><div><br></div><div>I think this is probably an oversight and we should accept -fprofile-sample-use as well.  I think that simply no one has tried to use the opt-viewer with sample-based profiling so far.  (We don’t have this support on macOS, so I’ve only been using PGO.)</div><br></div></div></div></blockquote><div><br></div><div>Agreed. Patches to fix the problem are welcome :)</div><div><br></div><div>David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Looking at the code in Clang that generates the warning, it appears that the warning is emitted unless instrumentation profile data is provided. Am I correct in understanding that sampling profile data cannot be used to determine the hotness of the code paths displayed via opt-viewer?</div><div><br></div><div>If this is correct, I am curious if this is a hard limitation, or whether I can do some work on CodeGen or ORE to make it possible to use a sampling profile. I ask because, while I'm excited to use optimization remarks, getting an instrumentation profile of my program would be difficult -- it's performance-critical and I can't release an instrumented build.</div></div></div></blockquote><div><br></div><div>I don’t think there is any hard limitation.  The information from instrumentation- and sample-based profiling are exposed through the same interface/analysis (BlockFrequencyInfo) within the compiler which is what the optimization remark facility uses.</div><div><br></div><div>So I’d say that this should just work modulo some differences in accuracy due the sampling vs instrumentation.  Despite the warning, do we already get hotness in the remarks?  It seems we should since we still set DiagnosticsWithHotness in CodeGenOpts [1] and in turn would call setDiagnosticHotnessRequested with true in the LLVM Context [2].  This is what then controls whether we emit hotness in the remark in LLVM [3].</div><div><br></div><div>If this does not work, you probably wan to debug through this path of execution and see where we fail.  Let me know if I can help further.</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Sorry if this is a dumb question -- I don't have much experience using PGO -- and thanks for all the work on opt-viewer! It's really fun to use.</div></div></div></blockquote><div><br></div><div>Not dumb at all, thanks for bringing this up.</div><div><br></div><div>Adam</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>- Brian Gesiak</div></div>
</div></blockquote></div><br></div><div>[1] <a href="https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/CompilerInvocation.cpp#L887" target="_blank">https://github.com/llvm-<wbr>mirror/clang/blob/master/lib/<wbr>Frontend/CompilerInvocation.<wbr>cpp#L887</a></div><div>[2] <a href="https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenAction.cpp#L231" target="_blank">https://github.com/llvm-<wbr>mirror/clang/blob/master/lib/<wbr>CodeGen/CodeGenAction.cpp#L231</a></div><div>[3] <a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Analysis/OptimizationDiagnosticInfo.cpp#L179" target="_blank">https://github.com/llvm-<wbr>mirror/llvm/blob/master/lib/<wbr>Analysis/<wbr>OptimizationDiagnosticInfo.<wbr>cpp#L179</a></div><div><br></div></div></blockquote></div><br></div></div>