[PATCH] D21771: [OptRemark] RFC: Add hotness attribute
Adam Nemet via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 16:40:12 PDT 2016
anemet added a comment.
In http://reviews.llvm.org/D21771#474673, @hfinkel wrote:
> Exactly. Looks like we both agree on packaging this as an analysis pass...
Yes, sorry if it wasn't completely clear. I was more and more convinced as I was replying...
> I think we should add some global state (perhaps something that is set when setDiagnosticHandler is called, or via some nearby API) that indicates whether diagnostic "hotness" is requested. We should package these wrappers as an analysis pass, and that pass should have a hard requirement on BFI.
> Regarding making BFI lazy, I think we probably need to do this, at least in the trivial sense: Add a Boolean to BFI indicating whether or not 'calculate' has been called, and add 'if (!Calculated) calculate()' to BFI::getBlockFreq, BFI::getBlockProfileCount and BFI::setBlockFreq, remove the call to calculate in runOnFunction. There is a more-complicated sense of making BFI lazy -- only computing frequencies for parts of the function as required -- but that's a larger project.
> Then if we make no BFI calls, then requiring it is free. I think then the infrastructure will just work for us.
Yes this should work.
I guess what you're saying is that we can't make the pass conditionally dependent on BFI because we have no access to the LLVM context in getAnalysisUsage. So while this may work for a command-line option, it does not work for a global in the LLVM context sense?
More information about the llvm-commits